import { getTranslations, setRequestLocale } from 'next-intl/server'
import { PageShell } from '@/components/PageShell'
import { getRealmName } from '@/lib/realm'
import { isResetTokenValid } from '@/lib/recover'
import { ResetForm } from './ResetForm'
// Consulta el token en la BD al abrirse: no se puede prerenderizar.
export const dynamic = 'force-dynamic'
export default async function ResetPasswordPage({
params,
searchParams,
}: {
params: Promise<{ locale: string }>
searchParams: Promise<{ token?: string }>
}) {
const { locale } = await params
setRequestLocale(locale)
const { token } = await searchParams
const t = await getTranslations('Reset')
// El enlace es de un solo uso y dura 1 hora. Antes el formulario se pintaba
// igualmente y solo al enviarlo te enterabas de que el enlace ya no servĂa.
if (!(await isResetTokenValid(token ?? ''))) {
const realm = await getRealmName()
return (