import { db } from "@/lib/db"; const stageLabel: Record = { GROUP: "مرحله گروهی", ROUND_OF_16: "یک‌هشتم نهایی", QUARTER_FINAL: "یک‌چهارم نهایی", SEMI_FINAL: "نیمه‌نهایی", THIRD_PLACE: "رده‌بندی", FINAL: "فینال", }; const statusStyle: Record = { SCHEDULED: "bg-gray-100 text-gray-600", LIVE: "bg-red-100 text-red-600 animate-pulse", FINISHED: "bg-green-100 text-green-700", }; const statusLabel: Record = { SCHEDULED: "برنامه‌ریزی شده", LIVE: "🔴 زنده", FINISHED: "پایان یافته", }; export default async function MatchesPage() { const matches = await db.match.findMany({ include: { homeTeam: true, awayTeam: true, round: true }, orderBy: { matchDate: "asc" }, }); const grouped = matches.reduce((acc, m) => { const key = m.stage; if (!acc[key]) acc[key] = []; acc[key].push(m); return acc; }, {} as Record); return (

بازی‌ها

{Object.entries(grouped).map(([stage, stageMatches]) => (

{stageLabel[stage] ?? stage}

{stageMatches.map((m) => (
{m.homeTeam.name} {m.homeTeam.flagUrl ?? "🏳️"}
{m.status === "FINISHED" || m.status === "LIVE" ? (
{m.homeScore} - {m.awayScore}
) : (
{new Date(m.matchDate).toLocaleDateString("fa-IR")}
)} {statusLabel[m.status]}
{m.awayTeam.flagUrl ?? "🏳️"} {m.awayTeam.name}
))}
))} {matches.length === 0 && (
هنوز بازی‌ای ثبت نشده
)}
); }