8bb18838ff
- lib/admin-forum.ts: listCategoriesWithForums, createCategory/deleteCategory (solo si vacía), createForum/deleteForum (borrado lógico), setForumVisibility. - API: /api/admin/forum(+/[id] DELETE/PATCH visibilidad) y /api/admin/forum/category(+/[id]) (403 sin admin). - UI: /admin/forum (AdminForumManager) — alta de categorías, alta/borrado de foros por categoría, mostrar/ocultar; tarjeta "Gestionar foros" en el índice del admin. - i18n es/en (Admin): 13 claves nuevas. Verificado: build OK, /admin/forum 307->login, APIs 403 sin admin. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
45 lines
1.9 KiB
TypeScript
45 lines
1.9 KiB
TypeScript
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
|
import { redirect, Link } from '@/i18n/navigation'
|
|
import { getSession } from '@/lib/session'
|
|
import { isAdmin } from '@/lib/admin'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
export default async function AdminPage({ params }: { params: Promise<{ locale: string }> }) {
|
|
const { locale } = await params
|
|
setRequestLocale(locale)
|
|
const t = await getTranslations('Admin')
|
|
const session = await getSession()
|
|
if (!session.bnetId) redirect({ href: '/login', locale })
|
|
if (!(await isAdmin(session))) redirect({ href: '/', locale })
|
|
|
|
const items: { href: string; label: string; icon: string }[] = [
|
|
{ href: '/admin/news', label: t('manageNews'), icon: '📰' },
|
|
{ href: '/admin/prices', label: t('managePrices'), icon: '💲' },
|
|
{ href: '/admin/votes', label: t('manageVotes'), icon: '🗳️' },
|
|
{ href: '/admin/gold', label: t('manageGold'), icon: '🪙' },
|
|
{ href: '/admin/users', label: t('manageUsers'), icon: '👤' },
|
|
{ href: '/admin/recruit', label: t('manageRecruit'), icon: '🎁' },
|
|
{ href: '/admin/forum', label: t('manageForum'), icon: '💬' },
|
|
]
|
|
|
|
return (
|
|
<main className="mx-auto max-w-3xl px-4 py-8">
|
|
<h1 className="mb-6 text-2xl font-bold text-amber-500">{t('title')}</h1>
|
|
<div className="grid gap-3 sm:grid-cols-2">
|
|
{items.map((it) => (
|
|
<Link
|
|
key={it.href}
|
|
href={it.href}
|
|
className="flex items-center gap-3 rounded-xl border border-nw-border/70 bg-nw-panel/80 p-4 shadow-lg shadow-black/30 backdrop-blur transition hover:border-nw-gold/60 hover:bg-nw-panel-2/70"
|
|
>
|
|
<span className="text-2xl" aria-hidden>{it.icon}</span>
|
|
<span className="font-semibold text-nw-text">{it.label}</span>
|
|
<span className="ml-auto text-nw-gold-light" aria-hidden>→</span>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</main>
|
|
)
|
|
}
|