import { getTranslations, setRequestLocale } from 'next-intl/server' import { getNoticias, getServerStatus, type Noticia, type ServerStatus } from '@/lib/home' // SSR por petición: los datos se leen DIRECTAMENTE de MySQL desde el servidor Next. export const dynamic = 'force-dynamic' async function getData(): Promise<{ noticias: Noticia[]; status: ServerStatus | null }> { const [news, status] = await Promise.allSettled([getNoticias(), getServerStatus()]) return { noticias: news.status === 'fulfilled' ? news.value : [], status: status.status === 'fulfilled' ? status.value : null, } } export default async function HomePage({ params }: { params: Promise<{ locale: string }> }) { const { locale } = await params setRequestLocale(locale) const t = await getTranslations('Home') const { noticias, status } = await getData() return (

{t('brand')}

{t('serverStatus')}

{status ? ( ) : (

{t('notAvailable')}

)}

{t('news')}

{noticias.length === 0 ? (

{t('noNews')}

) : ( noticias.map((n) => (

{n.titulo}

{n.fecha && {new Date(n.fecha).toLocaleString(locale)}}
{n.enlace && (

{t('link')}:{' '} {t('here')}

)}
)) )}
) }