import { prisma } from "@/lib/prisma" export const dynamic = "force-dynamic"; import Navigation from "@/components/Navigation" import Link from "next/link" import { notFound, redirect } from "next/navigation" import { canManageTournament } from "@/lib/permissions" import MatchEditor from "@/components/MatchEditor" interface PageProps { params: { id: string } } export default async function TournamentResultsPage({ params }: PageProps) { // Next.js 16 requires awaiting params const { id } = await params const tournamentId = parseInt(id, 10) if (isNaN(tournamentId)) { notFound() } // Check if user can manage this tournament const permission = await canManageTournament(tournamentId) if (!permission.allowed) { redirect("/auth/login") } const tournament = await prisma.event.findUnique({ where: { id: tournamentId }, }) if (!tournament) { notFound() } const matches = await prisma.match.findMany({ where: { eventId: tournamentId }, include: { player1P1: true, player1P2: true, player2P1: true, player2P2: true, }, orderBy: { playedAt: "desc" }, }) const players = await prisma.player.findMany({ orderBy: { name: "asc" }, }) return (
{/* Breadcrumb */} {/* Page Header */}

Enter Match Results

Record match results for {tournament.name}.

{/* Match Editor */}
{/* Existing Matches */} {matches.length > 0 && (

Recent Matches

{matches.slice(0, 10).map((match) => (

{match.playedAt?.toLocaleDateString()}

{match.player1P1?.name} + {match.player1P2?.name} vs{" "} {match.player2P1?.name} + {match.player2P2?.name}

match.team2Score ? 'text-green-600' : match.team1Score < match.team2Score ? 'text-red-600' : 'text-gray-600' }`}> {match.team1Score} - match.team1Score ? 'text-green-600' : match.team2Score < match.team1Score ? 'text-red-600' : 'text-gray-600' }`}> {match.team2Score}
))}
)}
) }