feat: add ScheduleDisplay component and wire up schedule page with Generator

This commit is contained in:
2026-04-26 22:03:21 -07:00
parent 8f7ca1362a
commit 799f5e1c63
4 changed files with 138 additions and 13 deletions
@@ -2,6 +2,8 @@ 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<{
@@ -27,6 +29,21 @@ export default async function TournamentSchedulePage({ params }: PageProps) {
player: true,
},
},
rounds: {
orderBy: { roundNumber: "asc" },
include: {
bracketMatchups: {
orderBy: { bracketPosition: "asc" },
include: {
player1P1: true,
player1P2: true,
player2P1: true,
player2P2: true,
match: true,
},
},
},
},
},
})
@@ -34,6 +51,9 @@ export default async function TournamentSchedulePage({ params }: PageProps) {
notFound()
}
const teamCount = tournament.participants.length
const existingRounds = tournament.rounds.length
return (
<div className="min-h-screen bg-gray-50">
<Navigation />
@@ -53,22 +73,31 @@ export default async function TournamentSchedulePage({ params }: PageProps) {
Schedule - {tournament.name}
</h1>
<div className="bg-white shadow rounded-lg p-6">
<div className="bg-white shadow rounded-lg p-6 mb-6">
<div className="flex justify-between items-center mb-6">
<h2 className="text-xl font-bold text-gray-900">
Tournament Schedule
</h2>
<button className="bg-green-600 text-white px-4 py-2 rounded-md text-sm font-medium hover:bg-green-700">
Generate Schedule
</button>
</div>
<p className="text-gray-500">
No schedule has been generated yet. Click "Generate Schedule" to create round matchups.
</p>
{existingRounds > 0 ? (
<ScheduleDisplay rounds={tournament.rounds} />
) : (
<p className="text-gray-500 mb-6">
No schedule has been generated yet. Click "Generate Schedule" to create round matchups.
</p>
)}
<div className="mt-6 pt-6 border-t border-gray-200">
<ScheduleGenerator
tournamentId={tournamentId}
teamCount={teamCount}
existingRounds={existingRounds}
/>
</div>
</div>
</div>
</main>
</div>
)
}
}