import type { Metadata } from 'next' import { setRequestLocale, getTranslations } from 'next-intl/server' import { redirect } from '@/i18n/navigation' import { getSession } from '@/lib/session' import { getPaymentTransactions, type PaymentTx } from '@/lib/trans-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('trans.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())}` } function StatusBadge({ status }: { status: PaymentTx['status'] }) { return {status} } /** Caja de una pasarela con su tabla de transacciones (o "No hay movimientos"). */ async function PlatformBox({ name, logo, note, txs, }: { name: string logo: string note: string txs: PaymentTx[] }) { const t = await getTranslations('History') return (

{name} {name}

{t.rich('trans.paidNote', { s: (c) => {c} })}


{t('trans.important')} {note}


{txs.length === 0 ? (
{t('trans.noMovements')}
) : ( {txs.map((tx) => ( ))}
{t('trans.thTxId')} {t('trans.thStatus')} {t('trans.thConcept')} {t('trans.thCreatedAt')} {t('trans.thAmount')}
{tx.id} {tx.conceptKey ? t(`points.concept.${tx.conceptKey}`, tx.conceptArgs) : tx.conceptRaw} {fmt(tx.createdAt)} {tx.amount.toFixed(2)} €
)}
) } const LOGO_BASE = '/ns-themes/ns-ryu/ns-images/ns-logos' export default async function TransHistoryPage({ 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: '/log-in', locale }) if (!session.username) redirect({ href: '/select-account', locale }) const txs = await getPaymentTransactions(session.accountId!) const stripe = txs.filter((t) => t.platform === 'Stripe') const sumup = txs.filter((t) => t.platform === 'SumUp') return (

{t('trans.intro1')}


{t('trans.intro2')}

{t.rich('trans.intro3', { mail: (c) => {c}, })}





) }