From 3bd3120eb1433cbf9eb17b368ebbd6c3cea53b2e Mon Sep 17 00:00:00 2001 From: Park Dahyeon Date: Mon, 13 Jul 2026 10:41:44 +0000 Subject: [PATCH] feat: link competition games to detail analysis Route each result-history Game by its global display number and preserve the Competition return target. Refuse stale detail fallbacks so a missing requested Game cannot silently show another Game. --- .../competition/CompetitionGameHistory.tsx | 133 ++++++++++++++++++ .../competition/CompetitionResults.tsx | 2 + .../competition/CompetitionSeriesHistory.tsx | 80 +++++------ .../competition/competition-series-history.ts | 12 ++ apps/web/src/index.css | 6 + .../src/lib/internal-match-game-selection.ts | 14 ++ apps/web/src/pages/MatchGameDetailPage.tsx | 24 +++- .../test/competition-series-history.test.ts | 35 +++++ .../internal-match-game-selection.test.ts | 13 ++ docs/plans/86-series-result-history-ui.md | 80 +++++++++++ docs/specs/series-result-history-ui.md | 37 ++++- 11 files changed, 382 insertions(+), 54 deletions(-) create mode 100644 apps/web/src/components/competition/CompetitionGameHistory.tsx create mode 100644 apps/web/src/lib/internal-match-game-selection.ts create mode 100644 apps/web/test/internal-match-game-selection.test.ts diff --git a/apps/web/src/components/competition/CompetitionGameHistory.tsx b/apps/web/src/components/competition/CompetitionGameHistory.tsx new file mode 100644 index 00000000..e77a83f7 --- /dev/null +++ b/apps/web/src/components/competition/CompetitionGameHistory.tsx @@ -0,0 +1,133 @@ +import type { + CommunityId, + CompetitionTeamView, + MatchId, + TeamId, +} from "@lolympus/contracts"; +import { ChevronRight } from "lucide-react"; +import { Link } from "react-router"; +import { + competitionHistoryGameDetailPath, + formatCompetitionHistoryTime, + formatSeriesGameDuration, + type CompetitionSeriesHistoryRow, +} from "./competition-series-history"; + +export function CompetitionGameHistory({ + games, + teamById, + communityId, + matchId, + historyBackTo, +}: { + games: CompetitionSeriesHistoryRow["games"]; + teamById: ReadonlyMap; + communityId: CommunityId; + matchId: MatchId; + historyBackTo: string; +}) { + return ( +
    + {games.map((game) => { + const duration = formatSeriesGameDuration(game.durationSeconds); + const winnerName = teamById.get(game.winnerTeamId)?.name ?? "알 수 없는 팀"; + const detailPath = competitionHistoryGameDetailPath( + communityId, + matchId, + game, + ); + const content = ( + + ); + + return ( +
  1. + {detailPath ? ( + + {content} + + ) : ( +
    + {content} +
    + )} +
  2. + ); + })} +
+ ); +} + +function GameHistoryRowContent({ + game, + winnerName, + duration, + linked, +}: { + game: CompetitionSeriesHistoryRow["games"][number]; + winnerName: string; + duration: string | null; + linked: boolean; +}) { + return ( + + + Game {game.ordinal} + + + + {winnerName} 승 + + + {duration ? ( + <> + 경기 시간 + {duration} + + ) : ( + <> + + 경기 시간 기록 없음 + + )} + + {linked && ( + + 상세 분석 + + )} + + ); +} diff --git a/apps/web/src/components/competition/CompetitionResults.tsx b/apps/web/src/components/competition/CompetitionResults.tsx index 6c45f406..8aef7392 100644 --- a/apps/web/src/components/competition/CompetitionResults.tsx +++ b/apps/web/src/components/competition/CompetitionResults.tsx @@ -83,6 +83,8 @@ export function CompetitionResults({ )} diff --git a/apps/web/src/components/competition/CompetitionSeriesHistory.tsx b/apps/web/src/components/competition/CompetitionSeriesHistory.tsx index 354c3474..f1530a5a 100644 --- a/apps/web/src/components/competition/CompetitionSeriesHistory.tsx +++ b/apps/web/src/components/competition/CompetitionSeriesHistory.tsx @@ -1,34 +1,43 @@ import type { + CommunityId, CompetitionProjection, CompetitionTeamView, + MatchId, TeamId, } from "@lolympus/contracts"; import { ChevronDown } from "lucide-react"; +import { useLocation } from "react-router"; import { createCompetitionSeriesHistory, formatCompetitionHistoryDate, formatCompetitionHistoryTime, - formatSeriesGameDuration, getSeriesHistoryStatusLabel, shouldDisplaySeriesHistoryScore, type CompetitionSeriesHistoryRow, } from "./competition-series-history"; +import { CompetitionGameHistory } from "./CompetitionGameHistory"; import { bracketRoundLabel } from "./double-elimination-bracket-layout"; import { isSeriesEntryWinner } from "./series-score-card-model"; export function CompetitionSeriesHistory({ + communityId, + matchId, projection, teamById, }: { + communityId: CommunityId; + matchId: MatchId; projection: CompetitionProjection; teamById: ReadonlyMap; }) { + const location = useLocation(); + const historyBackTo = `${location.pathname}${location.search}${location.hash}`; const history = createCompetitionSeriesHistory(projection); if (history.length === 0) return null; return (
@@ -63,7 +72,13 @@ export function CompetitionSeriesHistory({
    {day.rows.map((row) => (
  1. - +
  2. ))}
@@ -78,9 +93,15 @@ export function CompetitionSeriesHistory({ function SeriesHistoryRow({ row, teamById, + communityId, + matchId, + historyBackTo, }: { row: CompetitionSeriesHistoryRow; teamById: ReadonlyMap; + communityId: CommunityId; + matchId: MatchId; + historyBackTo: string; }) { if (row.games.length === 0) { return ( @@ -90,10 +111,16 @@ function SeriesHistoryRow({ return (
- + - +
); } @@ -144,7 +171,7 @@ function SeriesSummary({ {row.games.length}게임 보기 게임 접기