import { Link } from "react-router"; import type { Route } from "./+types/$leagueId.sports-seasons.$sportsSeasonId"; import { loader } from "./$leagueId.sports-seasons.$sportsSeasonId.server"; import { SportSeasonDisplay } from "~/components/scoring/SportSeasonDisplay"; import { EventSchedule } from "~/components/sport-season/EventSchedule"; import { RegularSeasonStandings } from "~/components/sport-season/RegularSeasonStandings"; import { Button } from "~/components/ui/button"; import { Badge } from "~/components/ui/badge"; import { ArrowLeft, CheckCircle2, Clock, Zap } from "lucide-react"; export function meta({ data }: Route.MetaArgs): Route.MetaDescriptors { return [{ title: `${data?.sportsSeason?.name ?? "Sport Season"} — ${data?.league?.name ?? "League"} - Brackt` }]; } export { loader }; function getStatusBadge(status: string) { switch (status) { case "active": return ( Active ); case "upcoming": return ( Upcoming ); case "completed": return ( Completed ); default: return null; } } export default function SportSeasonDetail({ loaderData, }: Route.ComponentProps) { const { league, season, sportsSeason, scoringPattern, playoffMatches, playoffRounds, preEliminatedParticipants, participantPoints, partialScoreParticipantIds, seasonStandings, qpStandings, teamOwnerships, userParticipantIds, upcomingEvents, recentEvents, seasonIsFinalized, regularSeasonStandings, participantEvs, } = loaderData; const hasBracket = playoffMatches && playoffMatches.length > 0; const hasStandings = regularSeasonStandings && regularSeasonStandings.length > 0; const showOtLosses = hasStandings && regularSeasonStandings.some((s) => s.otLosses !== null); const simulatorType = sportsSeason.sport?.simulatorType; const standingsDisplayMode = simulatorType === "nhl_bracket" ? "nhl-divisions" : "flat"; // NBA: 10 teams make the postseason (6 auto-qualify + 4 play-in) // NHL: handled by the nhl-divisions mode (3 per div + 2 wild cards) const playoffSpots = simulatorType === "nba_bracket" ? 10 : 8; // Build ownership map for RegularSeasonStandings const ownershipMap = Object.fromEntries( teamOwnerships.map((o) => [ o.participantId, { teamName: o.teamName, ownerName: o.ownerName ?? "", teamId: o.teamId }, ]) ); return (

{sportsSeason.sport.name}

{sportsSeason.name} • {league.name} • {season.year} Season

{getStatusBadge(sportsSeason.status)}
{/* Regular season standings — show above bracket when no bracket exists yet */} {hasStandings && !hasBracket && (
)} {/* Event schedule - hidden for bracket sports (the bracket itself is the event) */} {scoringPattern !== "playoff_bracket" && (upcomingEvents.length > 0 || recentEvents.length > 0) && (
)} {/* Hide bracket display when standings exist but no bracket matches have been set yet */} {!(scoringPattern === "playoff_bracket" && hasStandings && !hasBracket) && = (sportsSeason.totalMajors || 0) && !sportsSeason.qualifyingPointsFinalized } teamOwnerships={teamOwnerships} userParticipantIds={userParticipantIds} scoringRules={season} showOwnership={true} />} {/* Regular season standings — show below bracket once bracket exists */} {hasStandings && hasBracket && (
)}
); }