import { isApiError } from '@impuestos/contracts'; import { setRequestLocale } from 'next-intl/server'; import { getT } from '@/i18n/t'; import { redirect } from '@/i18n/navigation'; import { Card } from '@/components/ui/card'; import { LanguageSwitcher } from '@/components/language-switcher'; import { serverApi } from '@/lib/api-server'; /** * Phase 0 shell. It exists to prove the whole chain end to end: browser to the Next * rewrite, to the API, through the typed client, with the session cookie intact. * The real dashboard (FLOWS.md Flow C) replaces this in phase 4. */ export default async function InicioPage({ params }: { params: Promise<{ locale: string }> }) { const { locale } = await params; setRequestLocale(locale); const t = await getT(locale); const api = await serverApi(); const profile = await api.getProfile().catch((error: unknown) => { if (!isApiError(error)) throw error; // 404 is the documented state for a user who has not finished setup yet. if (error.code === 'not_found') return null; if (error.code === 'unauthorized') redirect({ href: '/login', locale }); throw error; }); return (

{t('home.title')}

{profile ? ( <>

{t('setup.fullName')}

{profile.fullName}

) : ( <>

{t('setup.step1.title')}

{t('setup.income.help')}

)}
); }