Login: navegación completa tras autenticar (cabecera no se actualizaba)
Con router.push el layout persiste entre rutas, así que la cabecera seguía
mostrando "Conectar/Crear cuenta" tras el login hasta recargar. Ahora login y
select-account hacen window.location.assign(/{locale}/...) para que el servidor
re-renderice el layout/cabecera con la sesión nueva.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useTranslations } from 'next-intl'
|
||||
import { useRouter } from '@/i18n/navigation'
|
||||
import { useTranslations, useLocale } from 'next-intl'
|
||||
|
||||
interface GameAccount {
|
||||
id: number
|
||||
@@ -11,7 +10,7 @@ interface GameAccount {
|
||||
|
||||
export function SelectAccountForm({ accounts }: { accounts: GameAccount[] }) {
|
||||
const t = useTranslations('SelectAccount')
|
||||
const router = useRouter()
|
||||
const locale = useLocale()
|
||||
const [busy, setBusy] = useState<number | null>(null)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
@@ -27,7 +26,8 @@ export function SelectAccountForm({ accounts }: { accounts: GameAccount[] }) {
|
||||
body: JSON.stringify({ accountId: id }),
|
||||
})
|
||||
const data: { success?: boolean } = await res.json()
|
||||
if (data.success) router.push('/my-account')
|
||||
// Navegación completa: re-renderiza el layout/cabecera con la cuenta ya elegida.
|
||||
if (data.success) window.location.assign(`/${locale}/my-account`)
|
||||
else {
|
||||
setError(t('error'))
|
||||
setBusy(null)
|
||||
|
||||
Reference in New Issue
Block a user