import Game from '@/components/Game'; import NewsSection from '@/components/NewsSection'; import { getOrCreateSpecialPuzzle } from '@/lib/dailyPuzzle'; import { Link } from '@/lib/navigation'; import { PrismaClient } from '@prisma/client'; import { getLocalizedValue } from '@/lib/i18n'; import { getTranslations } from 'next-intl/server'; export const dynamic = 'force-dynamic'; const prisma = new PrismaClient(); interface PageProps { params: Promise<{ locale: string; name: string }>; } export default async function SpecialPage({ params }: PageProps) { const { locale, name } = await params; const decodedName = decodeURIComponent(name); const tNav = await getTranslations('Navigation'); const allSpecials = await prisma.special.findMany(); const currentSpecial = allSpecials.find(s => getLocalizedValue(s.name, locale) === decodedName); const now = new Date(); const isStarted = currentSpecial && (!currentSpecial.launchDate || currentSpecial.launchDate <= now); const isEnded = currentSpecial && (currentSpecial.endDate && currentSpecial.endDate < now); if (!currentSpecial || !isStarted) { return (

Special Not Available

This special has not launched yet or does not exist.

{tNav('home')}
); } if (isEnded) { return (

Special Ended

This special event has ended.

{tNav('home')}
); } // Need to handle getOrCreateSpecialPuzzle with localized name or ID // Ideally pass ID or full object, but existing function takes name string. // I'll need to update lib/dailyPuzzle.ts to handle this. const dailyPuzzle = await getOrCreateSpecialPuzzle(currentSpecial); const genres = await prisma.genre.findMany({ where: { active: true }, }); genres.sort((a, b) => getLocalizedValue(a.name, locale).localeCompare(getLocalizedValue(b.name, locale))); const specials = allSpecials; // Already fetched specials.sort((a, b) => getLocalizedValue(a.name, locale).localeCompare(getLocalizedValue(b.name, locale))); const activeSpecials = specials.filter(s => { const sStarted = !s.launchDate || s.launchDate <= now; const sEnded = s.endDate && s.endDate < now; return sStarted && !sEnded; }); return ( <>
{tNav('global')} {/* Genres */} {genres.map(g => { const gName = getLocalizedValue(g.name, locale); return ( {gName} ); })} {/* Separator if both exist */} {genres.length > 0 && activeSpecials.length > 0 && ( | )} {/* Specials */} {activeSpecials.map(s => { const sName = getLocalizedValue(s.name, locale); return ( ★ {sName} ); })}
); }