import type { BracketRoundView, CompetitionDetailResponse, CompetitionOutcome, TeamId, } from "@lolympus/contracts"; import { Link } from "react-router"; import { CompetitionSeriesHistory } from "./CompetitionSeriesHistory"; import { DoubleEliminationBracket } from "./DoubleEliminationBracket"; import { createCompetitionSeriesHistory } from "./competition-series-history"; import { createCompetitionBracketLayout } from "./competition-display-layout"; import { bracketRoundLabel } from "./double-elimination-bracket-layout"; import { RoundRobinTable } from "./RoundRobinTable"; import { SeriesScoreCard } from "./SeriesScoreCard"; export function CompetitionResults({ competition, view = "all", }: { competition: CompetitionDetailResponse; view?: "all" | "bracket" | "games"; }) { const { projection } = competition; const teamById = new Map( competition.teams.map((team) => [team.teamId, team]), ); if (view === "games") { const hasSeriesHistory = createCompetitionSeriesHistory(projection).length > 0; return (
{hasSeriesHistory ? ( ) : (

기록된 공식 경기가 없습니다.

)}
); } const seriesById = new Map( projection.series.map((series) => [series.seriesId, series]), ); const doubleEliminationLayout = createCompetitionBracketLayout(competition); return (

Competition

공식 경기 결과

revision {competition.revision} 팀 진행
{projection.outcome && ( )} {projection.formatType === "round-robin" && ( )} {projection.rounds.length > 0 ? ( projection.formatType === "double-elimination" && doubleEliminationLayout ? ( ) : ( ) ) : (

편성된 공식 대진이 없습니다.

)} {view === "all" && ( )}
); } function GenericRoundGrid({ rounds, seriesById, teamById, }: { rounds: BracketRoundView[]; seriesById: Map< string, CompetitionDetailResponse["projection"]["series"][number] >; teamById: Map; }) { return (
{rounds.map((round) => ( ))}
); } function RoundColumn({ round, seriesById, teamById, }: { round: BracketRoundView; seriesById: Map< string, CompetitionDetailResponse["projection"]["series"][number] >; teamById: Map; }) { return (

{bracketRoundLabel(round.stage, round.roundNumber)}

{round.seriesIds.map((seriesId) => { const series = seriesById.get(seriesId); return series ? ( ) : null; })}
); } function OutcomeSummary({ outcome, teamById, }: { outcome: CompetitionOutcome; teamById: Map; }) { if (outcome.type === "paired-series") { return (

{outcome.completedSeriesIds.length + outcome.drawnSeriesIds.length}개 Series가 모두 종료되었습니다.

); } const leaders = outcome.type === "round-robin" ? outcome.leaderTeamIds : [outcome.championTeamId]; return (

{outcome.type === "round-robin" ? "1위" : "우승"} {leaders .map((teamId) => teamById.get(teamId)?.name ?? "알 수 없는 팀") .join(", ")}

); }