From dcd59074cfde917cf8cda99fcc661e25ee0fc04b Mon Sep 17 00:00:00 2001 From: adevopg Date: Tue, 14 Jul 2026 14:33:50 +0000 Subject: [PATCH] security-history: mostrar WOW1 + cuenta Battle.net en vez de 15#1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La columna Usuario mostraba el nombre interno de la cuenta de juego (15#1). Ahora muestra la etiqueta WOW1 (nº tras #; con varias serían WOW2, WOW3…) y debajo la cuenta Battle.net (email), sin añadir columnas. Helper wowAccountLabel extraído a lib/bnet.ts (mismo criterio que my-account). Co-Authored-By: Claude Opus 4.8 (1M context) --- .../app/[locale]/security-history/page.tsx | 29 ++++++++++++++----- web-next/lib/bnet.ts | 10 +++++++ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/web-next/app/[locale]/security-history/page.tsx b/web-next/app/[locale]/security-history/page.tsx index 06f32d7..a87d5d7 100644 --- a/web-next/app/[locale]/security-history/page.tsx +++ b/web-next/app/[locale]/security-history/page.tsx @@ -3,6 +3,7 @@ import { setRequestLocale } from 'next-intl/server' import { redirect } from '@/i18n/navigation' import { getSession } from '@/lib/session' import { getSecurityHistory } from '@/lib/security-history' +import { wowAccountLabel } from '@/lib/bnet' import { PageShell } from '@/components/PageShell' import { ServiceBox } from '@/components/ServiceBox' @@ -16,6 +17,21 @@ function fmt(d: Date): string { return `${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())} ${p(d.getDate())}-${p(d.getMonth() + 1)}-${d.getFullYear()}` } +/** Celda «Usuario»: cuenta de juego (WOW1) + cuenta Battle.net (email) debajo. */ +function UserCell({ label, bnet }: { label: string; bnet: string }) { + return ( + + {label} + {bnet && ( + <> +
+ {bnet} + + )} + + ) +} + export default async function SecurityHistoryPage({ params }: { params: Promise<{ locale: string }> }) { const { locale } = await params setRequestLocale(locale) @@ -24,8 +40,9 @@ export default async function SecurityHistoryPage({ params }: { params: Promise< if (!session.bnetId) redirect({ href: '/login', locale }) if (!session.username) redirect({ href: '/select-account', locale }) - const displayUser = session.username || session.bnetEmail || '—' - const { activity, realm, web } = await getSecurityHistory(session.accountId!, displayUser, session.bnetEmail || '') + const bnetEmail = session.bnetEmail || '' + const displayUser = wowAccountLabel(session.username || '') // «15#1» → «WOW1» + const { activity, realm, web } = await getSecurityHistory(session.accountId!, displayUser, bnetEmail) return ( @@ -84,9 +101,7 @@ export default async function SecurityHistoryPage({ params }: { params: Promise< {activity.map((a, i) => ( - - {a.user} - + {a.action} @@ -170,9 +185,7 @@ export default async function SecurityHistoryPage({ params }: { params: Promise< {web.map((c, i) => ( - - {c.user} - + {c.status} diff --git a/web-next/lib/bnet.ts b/web-next/lib/bnet.ts index a4e3b19..89d0673 100644 --- a/web-next/lib/bnet.ts +++ b/web-next/lib/bnet.ts @@ -146,3 +146,13 @@ export function normalizeEmail(email: string): string { export function makeGameAccountUsername(bnetId: number, index = 1): string { return `${bnetId}#${index}` } + +/** + * Nombre visible de una cuenta de juego: «15#1» → «WOW1» (el nº tras # es la + * cuenta de juego bajo la Battle.net; con varias serían WOW1, WOW2, WOW3…). + * El «15» es el id de la cuenta Battle.net y no debe mostrarse al usuario. + */ +export function wowAccountLabel(username: string): string { + const i = username.indexOf('#') + return i >= 0 ? `WOW${username.slice(i + 1)}` : username +}