import type { Metadata } from 'next' import { setRequestLocale, getTranslations } from 'next-intl/server' import { redirect, Link } from '@/i18n/navigation' import { getSession } from '@/lib/session' import { getSanctions, type Sanction } from '@/lib/ban-history' import { PageShell } from '@/components/PageShell' import { ServiceBox } from '@/components/ServiceBox' export const dynamic = 'force-dynamic' export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }): Promise { const { locale } = await params const t = await getTranslations({ locale, namespace: 'History' }) return { title: t('ban.pageTitle') } } /** Fecha en formato DD-MM-YYYY HH:MM:SS. */ function fmt(d: Date): string { const p = (n: number) => String(n).padStart(2, '0') return `${p(d.getDate())}-${p(d.getMonth() + 1)}-${d.getFullYear()} ${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}` } /** Caja con la tabla de sanciones (baneos o muteos), o el vacío del diseño. */ async function SanctionBox({ title, emptyText, rows, showScope, }: { title: string emptyText: string rows: Sanction[] showScope: boolean }) { const t = await getTranslations('History') return (

{title}

{rows.length === 0 ? (
{emptyText}
) : ( {showScope && } {rows.map((s, i) => ( {showScope && ( )} ))}
{t('ban.thScope')}{t('ban.thReason')} {t('ban.thBy')} {t('ban.thDate')} {t('ban.thExpires')} {t('ban.thStatus')}
{s.scopeKey === 'character' ? t('ban.scope.character', { name: s.scopeName }) : t(`ban.scope.${s.scopeKey}`)} {s.reason} {s.by} {fmt(s.date)} {s.expires ? fmt(s.expires) : t('ban.permanent')} {t(`ban.status.${s.statusKey}`)}
)}
) } export default async function BanHistoryPage({ params }: { params: Promise<{ locale: string }> }) { const { locale } = await params setRequestLocale(locale) const t = await getTranslations('History') const session = await getSession() if (!session.bnetId) redirect({ href: '/login', locale }) if (!session.username) redirect({ href: '/select-account', locale }) const { bans, mutes } = await getSanctions(session.accountId!, session.bnetId) return (

{t('ban.intro1')}

{t.rich('ban.intro2', { s: (c) => {c} })}

{t('ban.intro3')}


{t('ban.important')}

{t('ban.autoBlock1')}

{t('ban.autoBlock2')}


{t.rich('ban.claim', { link: (c) => {c} })}

) }