import Game from '@/components/Game'; import { getOrCreateSpecialPuzzle } from '@/lib/dailyPuzzle'; import Link from 'next/link'; import { PrismaClient } from '@prisma/client'; export const dynamic = 'force-dynamic'; const prisma = new PrismaClient(); interface PageProps { params: Promise<{ name: string }>; } export default async function SpecialPage({ params }: PageProps) { const { name } = await params; const decodedName = decodeURIComponent(name); const currentSpecial = await prisma.special.findUnique({ where: { name: 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.

Go Home
); } if (isEnded) { return (

Special Ended

This special event has ended.

Go Home
); } const dailyPuzzle = await getOrCreateSpecialPuzzle(decodedName); const genres = await prisma.genre.findMany({ orderBy: { name: 'asc' } }); const specials = await prisma.special.findMany({ orderBy: { name: 'asc' } }); const activeSpecials = specials.filter(s => { const sStarted = !s.launchDate || s.launchDate <= now; const sEnded = s.endDate && s.endDate < now; return sStarted && !sEnded; }); return ( <>
Global {/* Genres */} {genres.map(g => ( {g.name} ))} {/* Separator if both exist */} {genres.length > 0 && activeSpecials.length > 0 && ( | )} {/* Specials */} {activeSpecials.map(s => ( ★ {s.name} ))}
); }