store: la ruta pasa a ser /store-<reino> y /store da 404
Como el original (/store-bennu). El slug sale de acore_auth.realmlist, así que no puede ser una carpeta fija: lo resuelve la ruta dinámica `[realm]`, que ya servía /<slug>-realm y /<slug>-players con este mismo patrón. Solo hubo que añadirle el tipo `store`; el contenido de la página se mueve a components/StorePage.tsx. /store da 404 sin código extra: al no existir ya la carpeta estática `store`, entra por `[realm]`, no resuelve y cae en el notFound() que ya estaba. Enlaces actualizados: el de /my-account (AccountTools, que es cliente y recibe el href ya calculado) y el cancelUrl de la pasarela, que devolvía a /store. Verificado: /es/store-trinity y /en/store-trinity dan 200 y la tienda carga el catálogo; /es/store y /en/store dan 404; un slug ajeno (/es/store-bennu) también 404; /es/trinity-realm y /es/trinity-players siguen bien; y el enlace de /my-account apunta a /es/store-trinity. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,7 +9,7 @@ type Tool = { href: string; icon: string; label: string; desc: string; labelClas
|
||||
/** Replica los paneles plegables «OPCIONES DE CUENTA / OPCIONES DE PERSONAJE»
|
||||
* del my-account de Django (acordeón por click), con las herramientas ya
|
||||
* implementadas en Next. */
|
||||
export function AccountTools({ isAdmin }: { isAdmin: boolean }) {
|
||||
export function AccountTools({ isAdmin, storeHref }: { isAdmin: boolean; storeHref: string }) {
|
||||
const t = useTranslations('Account')
|
||||
|
||||
const accountTools: Tool[] = [
|
||||
@@ -41,7 +41,8 @@ export function AccountTools({ isAdmin }: { isAdmin: boolean }) {
|
||||
{ href: '/transfer-character', icon: 'tranfer-char-icon', label: t('svcTransfer'), desc: t('svcTransferDesc') },
|
||||
{ href: '/restore-character', icon: 'restore-icon', label: t('svcRestoreChar'), desc: t('svcRestoreCharDesc') },
|
||||
{ href: '/restore-items', icon: 'prox-icon', label: t('svcRestoreItems'), desc: t('svcRestoreItemsDesc') },
|
||||
{ href: '/store', icon: 'store-icon', label: t('svcStoreItems'), desc: t('svcStoreItemsDesc') },
|
||||
// La tienda lleva el reino en la URL (/store-<slug>): lo calcula el server.
|
||||
{ href: storeHref, icon: 'store-icon', label: t('svcStoreItems'), desc: t('svcStoreItemsDesc') },
|
||||
{ href: '/send-gift', icon: 'send-gift-icon', label: t('svcSendGift'), desc: t('svcSendGiftDesc') },
|
||||
]
|
||||
const historyTools: Tool[] = [
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import { getTranslations } from 'next-intl/server'
|
||||
import { redirect } from '@/i18n/navigation'
|
||||
import { getSession } from '@/lib/session'
|
||||
import { getGameCharacters } from '@/lib/characters'
|
||||
import { getStoreBalances } from '@/lib/store'
|
||||
import { wowheadWotlkHome } from '@/lib/wowhead'
|
||||
import { PageShell } from '@/components/PageShell'
|
||||
import { ServiceBox } from '@/components/ServiceBox'
|
||||
import { StoreBrowser } from '@/components/StoreBrowser'
|
||||
import { StoreNews } from '@/components/StoreNews'
|
||||
|
||||
/**
|
||||
* Contenido de la tienda. Vive aquí y no en una ruta propia porque la URL lleva
|
||||
* el reino (`/store-<slug>`, como el original) y eso lo resuelve la ruta
|
||||
* dinámica `[realm]`, igual que /<slug>-realm y /<slug>-players.
|
||||
*/
|
||||
export async function StorePage({ locale, realm }: { locale: string; realm: string }) {
|
||||
const session = await getSession()
|
||||
if (!session.bnetId) redirect({ href: '/log-in', locale })
|
||||
if (!session.username) redirect({ href: '/select-account', locale })
|
||||
|
||||
const [chars, balances] = await Promise.all([
|
||||
getGameCharacters(session.accountId!),
|
||||
getStoreBalances(session.accountId!),
|
||||
])
|
||||
|
||||
const t = await getTranslations('Store')
|
||||
|
||||
return (
|
||||
<PageShell title={<>{t('title')} - <span className="blue-info">{realm.toUpperCase()}</span></>}>
|
||||
<ServiceBox>
|
||||
<br />
|
||||
<p>{t('infoTooltip')}</p>
|
||||
<p>
|
||||
{t.rich('infoDb', {
|
||||
link: (c) => (
|
||||
<a href={wowheadWotlkHome(locale)} target="_blank" rel="noopener noreferrer">
|
||||
{c}
|
||||
</a>
|
||||
),
|
||||
})}
|
||||
</p>
|
||||
<br />
|
||||
<StoreNews />
|
||||
</ServiceBox>
|
||||
|
||||
<StoreBrowser
|
||||
characters={chars.map((c) => ({ name: c.name, classCss: c.classCss }))}
|
||||
dp={balances.dp}
|
||||
vp={balances.vp}
|
||||
realm={realm}
|
||||
/>
|
||||
</PageShell>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user