From 3c60081ece6045c0f0cc241a5770b5bdd55a0dc7 Mon Sep 17 00:00:00 2001
From: Park Dahyeon
Date: Mon, 13 Jul 2026 09:39:26 +0000
Subject: [PATCH] feat: add competition series result history
---
.../competition/CompetitionResults.tsx | 27 +-
.../competition/CompetitionSeriesHistory.tsx | 332 ++++++++++++++++++
.../competition/competition-series-history.ts | 56 +++
.../test/competition-series-history.test.ts | 87 +++++
docs/plans/86-series-result-history-ui.md | 45 +--
5 files changed, 503 insertions(+), 44 deletions(-)
create mode 100644 apps/web/src/components/competition/CompetitionSeriesHistory.tsx
diff --git a/apps/web/src/components/competition/CompetitionResults.tsx b/apps/web/src/components/competition/CompetitionResults.tsx
index c2d44c15..6c45f406 100644
--- a/apps/web/src/components/competition/CompetitionResults.tsx
+++ b/apps/web/src/components/competition/CompetitionResults.tsx
@@ -5,6 +5,7 @@ import type {
TeamId,
} from "@lolympus/contracts";
import { Link } from "react-router";
+import { CompetitionSeriesHistory } from "./CompetitionSeriesHistory";
import { DoubleEliminationBracket } from "./DoubleEliminationBracket";
import { createCompetitionBracketLayout } from "./competition-display-layout";
import { bracketRoundLabel } from "./double-elimination-bracket-layout";
@@ -81,28 +82,10 @@ export function CompetitionResults({
)}
- {projection.games.length > 0 && (
-
-
- 완료된 게임
-
-
- {projection.games.map((game) => (
- -
-
- Game {game.displayNumber}
-
-
- {teamById.get(game.winnerTeamId)?.name ?? "알 수 없는 팀"} 승
-
-
- ))}
-
-
- )}
+
);
}
diff --git a/apps/web/src/components/competition/CompetitionSeriesHistory.tsx b/apps/web/src/components/competition/CompetitionSeriesHistory.tsx
new file mode 100644
index 00000000..354c3474
--- /dev/null
+++ b/apps/web/src/components/competition/CompetitionSeriesHistory.tsx
@@ -0,0 +1,332 @@
+import type {
+ CompetitionProjection,
+ CompetitionTeamView,
+ TeamId,
+} from "@lolympus/contracts";
+import { ChevronDown } from "lucide-react";
+import {
+ createCompetitionSeriesHistory,
+ formatCompetitionHistoryDate,
+ formatCompetitionHistoryTime,
+ formatSeriesGameDuration,
+ getSeriesHistoryStatusLabel,
+ shouldDisplaySeriesHistoryScore,
+ type CompetitionSeriesHistoryRow,
+} from "./competition-series-history";
+import { bracketRoundLabel } from "./double-elimination-bracket-layout";
+import { isSeriesEntryWinner } from "./series-score-card-model";
+
+export function CompetitionSeriesHistory({
+ projection,
+ teamById,
+}: {
+ projection: CompetitionProjection;
+ teamById: ReadonlyMap;
+}) {
+ const history = createCompetitionSeriesHistory(projection);
+ if (history.length === 0) return null;
+
+ return (
+
+
+
+
+ {history.map((day) => {
+ const headingId = `competition-history-${day.dateKey}`;
+ return (
+
+
+ {day.dateKey === "unknown" ? (
+ formatCompetitionHistoryDate(day.dateKey)
+ ) : (
+
+ )}
+
+
+ {day.rows.map((row) => (
+ -
+
+
+ ))}
+
+
+ );
+ })}
+
+
+ );
+}
+
+function SeriesHistoryRow({
+ row,
+ teamById,
+}: {
+ row: CompetitionSeriesHistoryRow;
+ teamById: ReadonlyMap;
+}) {
+ if (row.games.length === 0) {
+ return (
+
+ );
+ }
+
+ return (
+
+
+
+
+
+
+ );
+}
+
+function SeriesSummary({
+ row,
+ teamById,
+ hasGameDetails,
+}: {
+ row: CompetitionSeriesHistoryRow;
+ teamById: ReadonlyMap;
+ hasGameDetails: boolean;
+}) {
+ const { series } = row;
+ const statusLabel = getSeriesHistoryStatusLabel(series);
+ const timeLabel =
+ row.timestampSource === "game-start"
+ ? formatCompetitionHistoryTime(row.occurredAt)
+ : null;
+ const roundLabel = bracketRoundLabel(
+ series.stage.type,
+ series.stage.roundNumber,
+ );
+
+ return (
+
+
+
+
+
+ {roundLabel}
+
+
+
+
+
+
+
+
+ {hasGameDetails ? (
+ <>
+ {row.games.length}게임 보기
+ 게임 접기
+
+ >
+ ) : (
+ 개별 기록 없음
+ )}
+
+
+ );
+}
+
+function HistoryTime({
+ occurredAt,
+ timeLabel,
+}: {
+ occurredAt: string;
+ timeLabel: string | null;
+}) {
+ return timeLabel ? (
+
+ ) : (
+
+ —
+ 시작 시간 기록 없음
+
+ );
+}
+
+function StatusLabel({
+ label,
+ inProgress,
+}: {
+ label: string;
+ inProgress: boolean;
+}) {
+ return (
+
+ {label}
+
+ );
+}
+
+function SeriesMatchup({
+ row,
+ teamById,
+}: {
+ row: CompetitionSeriesHistoryRow;
+ teamById: ReadonlyMap;
+}) {
+ const [entryA, entryB] = row.series.entries;
+ const teamAName = teamName(entryA.teamId, teamById);
+ const teamBName = teamName(entryB.teamId, teamById);
+ const teamAWon = isSeriesEntryWinner(row.series, entryA.teamId);
+ const teamBWon = isSeriesEntryWinner(row.series, entryB.teamId);
+ const showScore = shouldDisplaySeriesHistoryScore(row.series);
+ const officialWinnerTeamId =
+ row.series.status === "completed" && row.series.outcome.type !== "draw"
+ ? row.series.outcome.winnerTeamId
+ : null;
+ const winnerAnnouncement = officialWinnerTeamId
+ ? `, ${teamName(officialWinnerTeamId, teamById)} 승`
+ : "";
+ const accessibleResult = showScore
+ ? `${teamAName} ${entryA.gameWins} 대 ${entryB.gameWins} ${teamBName}${winnerAnnouncement}`
+ : `${teamAName} 대 ${teamBName}, ${getSeriesHistoryStatusLabel(row.series)}${winnerAnnouncement}`;
+
+ return (
+ <>
+
+
+
+ {showScore ? (
+ <>
+
+ {entryA.gameWins}
+
+ :
+
+ {entryB.gameWins}
+
+ >
+ ) : (
+ —
+ )}
+
+
+
+ {accessibleResult}
+ >
+ );
+}
+
+function TeamName({
+ name,
+ winner,
+ align,
+}: {
+ name: string;
+ winner: boolean;
+ align: "left" | "right";
+}) {
+ return (
+
+ {name}
+ {winner && (
+ 승
+ )}
+
+ );
+}
+
+function GameHistory({
+ games,
+ teamById,
+}: {
+ games: CompetitionSeriesHistoryRow["games"];
+ teamById: ReadonlyMap;
+}) {
+ return (
+
+ {games.map((game) => {
+ const duration = formatSeriesGameDuration(game.durationSeconds);
+ return (
+ -
+
+ Game {game.ordinal}
+
+
+
+ {teamName(game.winnerTeamId, teamById)} 승
+
+
+ {duration ?? "—"}
+
+
+ );
+ })}
+
+ );
+}
+
+function teamName(
+ teamId: TeamId,
+ teamById: ReadonlyMap,
+): string {
+ return teamById.get(teamId)?.name ?? "알 수 없는 팀";
+}
diff --git a/apps/web/src/components/competition/competition-series-history.ts b/apps/web/src/components/competition/competition-series-history.ts
index 5ae94c18..41bf63b8 100644
--- a/apps/web/src/components/competition/competition-series-history.ts
+++ b/apps/web/src/components/competition/competition-series-history.ts
@@ -24,6 +24,16 @@ export interface CompetitionSeriesHistoryDay {
type HistoryProjection = Pick;
+const KOREAN_WEEKDAYS = [
+ "일",
+ "월",
+ "화",
+ "수",
+ "목",
+ "금",
+ "토",
+] as const;
+
export function createCompetitionSeriesHistory(
projection: HistoryProjection,
timeZone = "Asia/Seoul",
@@ -95,6 +105,16 @@ export function getSeriesHistoryStatusLabel(
}
}
+export function shouldDisplaySeriesHistoryScore(
+ series: CompetitionSeriesHistorySeries,
+): boolean {
+ if (series.status === "in-progress") return true;
+ if (series.outcome.type === "played") return true;
+ return (
+ series.outcome.type === "draw" && series.outcome.basis.type === "played"
+ );
+}
+
export function formatSeriesGameDuration(
durationSeconds: number,
): string | null {
@@ -109,6 +129,42 @@ export function formatSeriesGameDuration(
return `${minutes}:${padNumber(seconds)}`;
}
+export function formatCompetitionHistoryDate(dateKey: string): string {
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(dateKey);
+ if (!match) return "일시 정보 없음";
+ const year = Number(match[1]);
+ const month = Number(match[2]);
+ const day = Number(match[3]);
+ const date = new Date(Date.UTC(year, month - 1, day));
+ if (
+ date.getUTCFullYear() !== year ||
+ date.getUTCMonth() !== month - 1 ||
+ date.getUTCDate() !== day
+ ) {
+ return "일시 정보 없음";
+ }
+ return `${padNumber(month)}월 ${padNumber(day)}일 (${KOREAN_WEEKDAYS[date.getUTCDay()]})`;
+}
+
+export function formatCompetitionHistoryTime(
+ value: IsoDateTime,
+ timeZone = "Asia/Seoul",
+): string | null {
+ const date = new Date(value);
+ if (Number.isNaN(date.getTime())) return null;
+ const parts = new Intl.DateTimeFormat("en-US", {
+ timeZone,
+ hour: "2-digit",
+ minute: "2-digit",
+ hourCycle: "h23",
+ }).formatToParts(date);
+ const part = (type: Intl.DateTimeFormatPartTypes) =>
+ parts.find((entry) => entry.type === type)?.value;
+ const hour = part("hour");
+ const minute = part("minute");
+ return hour && minute ? `${hour}:${minute}` : null;
+}
+
function compareGames(
left: CompetitionGameView,
right: CompetitionGameView,
diff --git a/apps/web/test/competition-series-history.test.ts b/apps/web/test/competition-series-history.test.ts
index 5094c399..c4bb2057 100644
--- a/apps/web/test/competition-series-history.test.ts
+++ b/apps/web/test/competition-series-history.test.ts
@@ -10,9 +10,13 @@ import type {
} from "@lolympus/contracts";
import {
createCompetitionSeriesHistory,
+ formatCompetitionHistoryDate,
+ formatCompetitionHistoryTime,
formatSeriesGameDuration,
getSeriesHistoryStatusLabel,
+ shouldDisplaySeriesHistoryScore,
} from "../src/components/competition/competition-series-history.ts";
+import { isSeriesEntryWinner } from "../src/components/competition/series-score-card-model.ts";
test("aggregates Games under their Series and preserves Series slot scores", () => {
const teamA = teamId("team-a");
@@ -265,6 +269,80 @@ test("returns explicit status labels for played and adjudicated outcomes", () =>
);
});
+test("shows a numeric score only for played records", () => {
+ const teamA = teamId("team-a");
+ const teamB = teamId("team-b");
+ const playedDraw = completedSeries({
+ id: "played-draw",
+ teamA,
+ teamB,
+ scoreA: 1,
+ scoreB: 1,
+ outcome: "draw",
+ });
+ const administrativeDraw = {
+ ...playedDraw,
+ seriesId: seriesId("administrative-draw"),
+ outcome: {
+ ...playedDraw.outcome,
+ basis: {
+ type: "administrative" as const,
+ decisionFactId: "draw-fact" as never,
+ },
+ },
+ };
+
+ assert.equal(
+ shouldDisplaySeriesHistoryScore(
+ inProgressSeries("running-score", teamA, teamB, 1, 0),
+ ),
+ true,
+ );
+ assert.equal(
+ shouldDisplaySeriesHistoryScore(
+ completedSeries({
+ id: "played-score",
+ teamA,
+ teamB,
+ scoreA: 2,
+ scoreB: 1,
+ }),
+ ),
+ true,
+ );
+ assert.equal(shouldDisplaySeriesHistoryScore(playedDraw), true);
+ assert.equal(shouldDisplaySeriesHistoryScore(administrativeDraw), false);
+ assert.equal(
+ shouldDisplaySeriesHistoryScore(
+ completedSeries({
+ id: "forfeit-score",
+ teamA,
+ teamB,
+ scoreA: 1,
+ scoreB: 1,
+ outcome: "forfeit",
+ }),
+ ),
+ false,
+ );
+});
+
+test("uses the official outcome winner even when adjudicated score order differs", () => {
+ const teamA = teamId("official-winner");
+ const teamB = teamId("score-leader");
+ const series = completedSeries({
+ id: "adjudicated-winner",
+ teamA,
+ teamB,
+ scoreA: 0,
+ scoreB: 1,
+ outcome: "forfeit",
+ });
+
+ assert.equal(isSeriesEntryWinner(series, teamA), true);
+ assert.equal(isSeriesEntryWinner(series, teamB), false);
+});
+
test("formats recorded Game duration and omits unknown legacy zero values", () => {
assert.equal(formatSeriesGameDuration(1_875), "31:15");
assert.equal(formatSeriesGameDuration(3_661), "1:01:01");
@@ -272,6 +350,15 @@ test("formats recorded Game duration and omits unknown legacy zero values", () =
assert.equal(formatSeriesGameDuration(-1), null);
});
+test("formats history dates and times explicitly in Asia/Seoul", () => {
+ assert.equal(formatCompetitionHistoryDate("2026-07-13"), "07월 13일 (월)");
+ assert.equal(
+ formatCompetitionHistoryTime("2026-07-12T15:05:00.000Z"),
+ "00:05",
+ );
+ assert.equal(formatCompetitionHistoryDate("unknown"), "일시 정보 없음");
+});
+
function playedSeriesWithGame({
id,
displayOrder,
diff --git a/docs/plans/86-series-result-history-ui.md b/docs/plans/86-series-result-history-ui.md
index 056f8eed..be01a428 100644
--- a/docs/plans/86-series-result-history-ui.md
+++ b/docs/plans/86-series-result-history-ui.md
@@ -27,13 +27,13 @@ and preserve all current Competition/API contracts.
**Acceptance criteria:**
-- [ ] Tests cover Series aggregation, ordinal Game order, KST date boundaries,
+- [x] Tests cover Series aggregation, ordinal Game order, KST date boundaries,
chronological order, outcome variants, and deterministic fallbacks.
-- [ ] The focused test fails because the model module does not yet exist.
+- [x] The focused test fails because the model module does not yet exist.
**Verification:**
-- [ ] Run the focused Node test and record the expected RED failure.
+- [x] Run the focused Node test and record the expected RED failure.
**Files likely touched:**
@@ -43,14 +43,14 @@ and preserve all current Competition/API contracts.
**Acceptance criteria:**
-- [ ] Only recorded in-progress and completed Series are returned.
-- [ ] Date grouping and format helpers are explicitly KST-aware.
-- [ ] Decision outcomes and missing legacy durations remain distinguishable.
+- [x] Only recorded in-progress and completed Series are returned.
+- [x] Date grouping and format helpers are explicitly KST-aware.
+- [x] Decision outcomes and missing legacy durations remain distinguishable.
**Verification:**
-- [ ] Focused history tests pass.
-- [ ] Existing web tests still pass.
+- [x] Focused history tests pass.
+- [x] Existing web tests still pass.
**Files likely touched:**
@@ -59,7 +59,7 @@ and preserve all current Competition/API contracts.
### Checkpoint: Model
-- [ ] Pure tests pass without a React or browser dependency.
+- [x] Pure tests pass without a React or browser dependency.
### Phase 2: Responsive Result UI
@@ -67,16 +67,16 @@ and preserve all current Competition/API contracts.
**Acceptance criteria:**
-- [ ] Desktop uses a flat schedule-like row; mobile stacks metadata and matchup
+- [x] Desktop uses a flat schedule-like row; mobile stacks metadata and matchup
without horizontal scrolling.
-- [ ] Status and official winner are communicated with visible text and typography,
+- [x] Status and official winner are communicated with visible text and typography,
not color alone.
-- [ ] Game-less decisions do not show fake start times or `0 : 0`.
+- [x] Game-less decisions do not show fake start times or `0 : 0`.
**Verification:**
-- [ ] Changed component files pass ESLint.
-- [ ] Web build succeeds.
+- [x] Changed component files pass ESLint.
+- [x] Web build succeeds.
**Files likely touched:**
@@ -86,15 +86,16 @@ and preserve all current Competition/API contracts.
**Acceptance criteria:**
-- [ ] Each Series with Games exposes a native keyboard-operable disclosure.
-- [ ] Games use Series-local ordinal, team-ID winner lookup, and omit unknown
+- [x] Each Series with Games exposes a native keyboard-operable disclosure.
+- [x] Games use Series-local ordinal, team-ID winner lookup, and omit unknown
zero-duration values.
-- [ ] The old completed-Game mini-card block is removed.
+- [x] The old completed-Game mini-card block is removed.
**Verification:**
-- [ ] Full web tests, lint, and build pass.
-- [ ] Source review checks heading order, disclosure semantics, and 320px layout.
+- [x] Full web tests, changed-file lint, and build pass. Repository-wide lint remains
+ blocked by pre-existing errors outside this change.
+- [x] Source review checks heading order, disclosure semantics, and 320px layout.
**Files likely touched:**
@@ -103,9 +104,9 @@ and preserve all current Competition/API contracts.
### Checkpoint: Complete
-- [ ] All specification success criteria are met.
-- [ ] Git diff contains only the feature spec, plan, tests, model, and UI integration.
-- [ ] Unrelated working-tree files are unchanged.
+- [x] All specification success criteria are met.
+- [x] Git diff contains only the feature spec, plan, tests, model, and UI integration.
+- [x] Unrelated working-tree files are unchanged.
## Risks and Mitigations