import { getTranslations, setRequestLocale } from 'next-intl/server'
import { redirect, Link } from '@/i18n/navigation'
import { getSession } from '@/lib/session'
import { getAccountDashboard } from '@/lib/account'
import { LogoutButton } from '@/components/LogoutButton'
export const dynamic = 'force-dynamic'
export default async function AccountPage({ params }: { params: Promise<{ locale: string }> }) {
const { locale } = await params
setRequestLocale(locale)
const t = await getTranslations('Account')
const session = await getSession()
if (!session.bnetId) redirect({ href: '/login', locale })
if (!session.username) redirect({ href: '/select-account', locale })
const data = await getAccountDashboard(session)
const card = 'nw-card'
return (
{t('title')}
{t('bnetAccount')}: {data.bnetEmail}
{t('gameAccount')}: {data.gameAccount}
{t('securityToken')}:{' '}
{data.securityTokenDate
? `${t('requested')} โ ${new Date(data.securityTokenDate).toLocaleString(locale)}`
: t('notRequested')}
{t('points')}
{t('dp')}: {data.dp}
{t('vp')}: {data.vp}
{t('battlepayCredits')}: {data.battlepayCredits}
{t('characters')}
{data.characters.length === 0 ? (
{t('noCharacters')}
) : (
{data.characters.map((c) => (
{/* eslint-disable-next-line @next/next/no-img-element */}
{c.name}
{t('level')} {c.level} ยท {c.raceName} {c.className}
๐
{c.zone}
{c.gold}g {c.silver}s {c.copper}c
))}
)}
)
}
function ServicesPanel({ t }: { t: (k: string) => string }) {
const groups: { title: string; items: { href: string; label: string }[] }[] = [
{
title: t('servicesTitle'),
items: [
{ href: '/rename', label: t('svcRename') },
{ href: '/customize', label: t('svcCustomize') },
{ href: '/change-race', label: t('svcChangeRace') },
{ href: '/change-faction', label: t('svcChangeFaction') },
{ href: '/level-up', label: t('svcLevelUp') },
{ href: '/gold', label: t('svcGold') },
{ href: '/transfer', label: t('svcTransfer') },
],
},
{
title: t('utilitiesTitle'),
items: [
{ href: '/revive', label: t('svcRevive') },
{ href: '/unstuck', label: t('svcUnstuck') },
{ href: '/security-token', label: t('svcToken') },
],
},
{
title: t('accountSettings'),
items: [
{ href: '/change-password', label: t('svcChangePassword') },
{ href: '/change-email', label: t('svcChangeEmail') },
],
},
{
title: t('communityTitle'),
items: [
{ href: '/vote-points', label: t('svcVote') },
{ href: '/recruit', label: t('svcRecruit') },
{ href: '/battlepay', label: t('svcStore') },
],
},
]
return (
{groups.map((g) => (
{g.title}
{g.items.map((it) => (
-
{it.label}
))}
))}
)
}