import Game from '@/components/Game'; import NewsSection from '@/components/NewsSection'; import OnboardingTour from '@/components/OnboardingTour'; import LanguageSwitcher from '@/components/LanguageSwitcher'; import { getOrCreateDailyPuzzle } from '@/lib/dailyPuzzle'; import { Link } from '@/lib/navigation'; import { PrismaClient } from '@prisma/client'; import { getTranslations } from 'next-intl/server'; import { getLocalizedValue } from '@/lib/i18n'; export const dynamic = 'force-dynamic'; const prisma = new PrismaClient(); export default async function Home({ params }: { params: { locale: string }; }) { const { locale } = await params; const t = await getTranslations('Home'); const tNav = await getTranslations('Navigation'); const dailyPuzzle = await getOrCreateDailyPuzzle(null); // Global puzzle const genres = await prisma.genre.findMany({ where: { active: true }, }); const specials = await prisma.special.findMany(); // Sort in memory genres.sort((a, b) => getLocalizedValue(a.name, locale).localeCompare(getLocalizedValue(b.name, locale))); specials.sort((a, b) => getLocalizedValue(a.name, locale).localeCompare(getLocalizedValue(b.name, locale))); const now = new Date(); const activeSpecials = specials.filter(s => { const isStarted = !s.launchDate || s.launchDate <= now; const isEnded = s.endDate && s.endDate < now; return isStarted && !isEnded; }); const upcomingSpecials = specials.filter(s => { return s.launchDate && s.launchDate > now; }); return ( <>
{tNav('global')} {t('globalTooltip')}
{/* Genres */} {genres.map(g => { const name = getLocalizedValue(g.name, locale); const subtitle = getLocalizedValue(g.subtitle, locale); return (
{name} {subtitle && {subtitle}}
); })} {/* Separator if both exist */} {genres.length > 0 && activeSpecials.length > 0 && ( | )} {/* Active Specials */} {activeSpecials.map(s => { const name = getLocalizedValue(s.name, locale); const subtitle = getLocalizedValue(s.subtitle, locale); return (
★ {name} {subtitle && {subtitle}}
{s.curator && ( {t('curatedBy')} {s.curator} )}
); })}
{/* Upcoming Specials */} {upcomingSpecials.length > 0 && (
{t('comingSoon')}: {upcomingSpecials.map(s => { const name = getLocalizedValue(s.name, locale); return ( ★ {name} ({s.launchDate ? new Date(s.launchDate).toLocaleDateString(locale, { day: '2-digit', month: '2-digit', year: 'numeric', timeZone: process.env.TZ }) : ''}) {s.curator && {t('curatedBy')} {s.curator}} ); })}
)}
); }