import { prisma } from "@/lib/prisma" import Navigation from "@/components/Navigation" import Link from "next/link" import { notFound } from "next/navigation" import { ScheduleGenerator } from "@/components/ScheduleGenerator" import { ScheduleDisplay } from "@/components/ScheduleDisplay" interface PageProps { params: Promise<{ id: string }> } // Force dynamic rendering and revalidate on each request export const dynamic = "force-dynamic" export const revalidate = 0 export default async function TournamentSchedulePage({ params }: PageProps) { const { id } = await params const tournamentId = parseInt(id, 10) if (isNaN(tournamentId)) { notFound() } console.log(`[Schedule Page] Fetching tournament ${tournamentId}`); const tournament = await prisma.event.findUnique({ where: { id: tournamentId }, include: { participants: { include: { player: true, }, }, rounds: { orderBy: { roundNumber: "asc" }, include: { bracketMatchups: { orderBy: { bracketPosition: "asc" }, include: { player1P1: true, player1P2: true, player2P1: true, player2P2: true, match: true, }, }, }, }, }, }) console.log(`[Schedule Page] Tournament ${tournamentId} has ${tournament?.rounds?.length || 0} rounds`); if (tournament?.rounds && tournament.rounds.length > 0) { console.log(`[Schedule Page] First round:`, JSON.stringify(tournament.rounds[0])); } if (!tournament) { notFound() } const teamCount = tournament.participants.length const existingRounds = tournament.rounds.length return (
← Back to Tournament

Schedule - {tournament.name}

Tournament Schedule

{existingRounds > 0 ? ( ) : (

No schedule has been generated yet. Click "Generate Schedule" to create round matchups.

)}
) }