import { Link } from "react-router"; import { ArrowLeft, Calendar } from "lucide-react"; import type { Route } from "./+types/$leagueId.sports-seasons.$sportsSeasonId.events.$eventId"; import { loader } from "./$leagueId.sports-seasons.$sportsSeasonId.events.$eventId.server"; import { formatEventDate } from "~/lib/date-utils"; import { Badge } from "~/components/ui/badge"; import { Card, CardContent, CardHeader, CardTitle, } from "~/components/ui/card"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "~/components/ui/table"; import { PlayoffBracket } from "~/components/scoring/PlayoffBracket"; import { GroupStageStandings } from "~/components/sport-season/GroupStageStandings"; import { Cs2MajorEventView } from "~/components/events/Cs2MajorEventView"; export function meta({ data }: Route.MetaArgs) { const eventName = data?.scoringEvent?.name ?? "Event"; const leagueName = data?.league?.name ?? "League"; return [{ title: `${eventName} — ${leagueName} — Brackt` }]; } export { loader }; type QpResult = { id: string; placement: number; qualifyingPointsAwarded: string | null; rawScore: string | null; seasonParticipantId: string; participantName: string | null; }; function QpResultsTable({ eventResults, ownershipMap, userParticipantIds, }: { eventResults: QpResult[]; ownershipMap: Record; userParticipantIds: string[]; }) { if (eventResults.length === 0) { return (

Results not yet available for this event.

); } return ( Results # Participant Manager QP {eventResults.map((r) => { const ownership = ownershipMap[r.seasonParticipantId]; const isUser = userParticipantIds.includes(r.seasonParticipantId); return ( {r.placement} {r.participantName ?? "—"} {isUser && } {ownership?.teamName ?? "—"} {r.qualifyingPointsAwarded !== null ? parseFloat(r.qualifyingPointsAwarded).toFixed(2) : r.rawScore !== null ? r.rawScore : "—"} ); })}
); } export default function EventDetailPage({ loaderData }: Route.ComponentProps) { const { league, sportsSeason, scoringEvent } = loaderData; const leagueId = league.id; const sportsSeasonId = sportsSeason.id; const ownershipMap = Object.fromEntries( loaderData.teamOwnerships.map((o) => [ o.participantId, { teamName: o.teamName, ownerName: o.ownerName ?? "", teamId: o.teamId }, ]) ); const eventDate = formatEventDate(scoringEvent.eventStartsAt as string | null) ?? formatEventDate(scoringEvent.eventDate) ?? "Date TBD"; return (
{/* Breadcrumb */}
{sportsSeason.name}

{scoringEvent.name}

{eventDate} {scoringEvent.isComplete && ( Complete )}
{/* CS2 Major view */} {loaderData.kind === "cs2" && ( )} {/* Bracket event (tennis/golf/soccer) */} {loaderData.kind === "bracket" && (
{loaderData.groupStandings.length > 0 && ( )} {loaderData.playoffMatches.length > 0 ? ( ) : (

Bracket not yet available.

)}
)} {/* Tennis Grand Slam major — draw bracket + qualifying-points results */} {loaderData.kind === "tennis" && (
{loaderData.playoffMatches.length > 0 ? ( ) : (

Bracket not yet available.

)}
)} {/* Results table (QP tournaments, racing events) */} {loaderData.kind === "results" && ( )}
); }