feat: unify competition schedule and results
This commit is contained in:
1 parent
4e10998794
commit
c9140b8622
12 files changed
+910
-245
No files matched your search
@@ -51,6 +51,11 @@ export interface SeriesDefinition {
|
|||||||
{ position: 'B'; source: ParticipantSource },
|
{ position: 'B'; source: ParticipantSource },
|
||||||
];
|
];
|
||||||
rule: SeriesRule;
|
rule: SeriesRule;
|
||||||
|
schedule?: {
|
||||||
|
date: string;
|
||||||
|
time: string | null;
|
||||||
|
timeZone: 'Asia/Seoul';
|
||||||
|
};
|
||||||
activation?: {
|
activation?: {
|
||||||
type: 'grand-final-reset-required';
|
type: 'grand-final-reset-required';
|
||||||
grandFinalSeriesId: string;
|
grandFinalSeriesId: string;
|
||||||
|
|||||||
@@ -1,6 +1,110 @@
|
|||||||
import { projectSeries } from './series-projector';
|
import { projectSeries } from './series-projector';
|
||||||
|
|
||||||
describe('projectSeries', () => {
|
describe('projectSeries', () => {
|
||||||
|
it.each([
|
||||||
|
['a known local time', '21:30'],
|
||||||
|
['an unknown local time', null],
|
||||||
|
] as const)('preserves an optional Series schedule with %s', (_, time) => {
|
||||||
|
const schedule = {
|
||||||
|
date: '2026-07-15',
|
||||||
|
time,
|
||||||
|
timeZone: 'Asia/Seoul' as const,
|
||||||
|
};
|
||||||
|
const definition = {
|
||||||
|
...seriesDefinition({
|
||||||
|
id: `series-scheduled-${time ?? 'unknown'}`,
|
||||||
|
stage: 'upper',
|
||||||
|
rule: { type: 'first-to' as const, winsRequired: 1, maxGames: 1 },
|
||||||
|
}),
|
||||||
|
schedule,
|
||||||
|
};
|
||||||
|
|
||||||
|
const projection = projectSeries({
|
||||||
|
definition,
|
||||||
|
participants: ['team-8', 'team-3'],
|
||||||
|
facts: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(projection).toMatchObject({
|
||||||
|
status: 'ready',
|
||||||
|
schedule,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps an existing definition without a schedule explicitly unscheduled', () => {
|
||||||
|
const definition = seriesDefinition({
|
||||||
|
id: 'series-unscheduled',
|
||||||
|
stage: 'upper',
|
||||||
|
rule: { type: 'first-to', winsRequired: 1, maxGames: 1 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const projection = projectSeries({
|
||||||
|
definition,
|
||||||
|
participants: ['team-8', 'team-3'],
|
||||||
|
facts: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(projection).not.toHaveProperty('schedule');
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'an impossible calendar date',
|
||||||
|
{ date: '2026-02-30', time: '21:30', timeZone: 'Asia/Seoul' },
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'an out-of-range local time',
|
||||||
|
{ date: '2026-07-15', time: '24:00', timeZone: 'Asia/Seoul' },
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'a non-canonical time zone',
|
||||||
|
{ date: '2026-07-15', time: '21:30', timeZone: 'UTC' },
|
||||||
|
],
|
||||||
|
])('rejects a Series schedule with %s', (_, schedule) => {
|
||||||
|
const definition = {
|
||||||
|
...seriesDefinition({
|
||||||
|
id: `series-invalid-schedule-${schedule.date}-${schedule.time}`,
|
||||||
|
stage: 'upper',
|
||||||
|
rule: { type: 'first-to' as const, winsRequired: 1, maxGames: 1 },
|
||||||
|
}),
|
||||||
|
schedule,
|
||||||
|
} as unknown as Parameters<typeof projectSeries>[0]['definition'];
|
||||||
|
|
||||||
|
expectInvariant(
|
||||||
|
() =>
|
||||||
|
projectSeries({
|
||||||
|
definition,
|
||||||
|
participants: ['team-8', 'team-3'],
|
||||||
|
facts: [],
|
||||||
|
}),
|
||||||
|
'SERIES_DEFINITION_INVALID',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([null, false, ''])(
|
||||||
|
'rejects a non-object Series schedule value %p',
|
||||||
|
(schedule) => {
|
||||||
|
const definition = {
|
||||||
|
...seriesDefinition({
|
||||||
|
id: 'series-invalid-schedule-shape',
|
||||||
|
stage: 'upper',
|
||||||
|
rule: { type: 'first-to' as const, winsRequired: 1, maxGames: 1 },
|
||||||
|
}),
|
||||||
|
schedule,
|
||||||
|
} as unknown as Parameters<typeof projectSeries>[0]['definition'];
|
||||||
|
|
||||||
|
expectInvariant(
|
||||||
|
() =>
|
||||||
|
projectSeries({
|
||||||
|
definition,
|
||||||
|
participants: ['team-8', 'team-3'],
|
||||||
|
facts: [],
|
||||||
|
}),
|
||||||
|
'SERIES_DEFINITION_INVALID',
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
it('keeps a fixed-games pair in progress until every game slot is filled', () => {
|
it('keeps a fixed-games pair in progress until every game slot is filled', () => {
|
||||||
const definition = seriesDefinition({
|
const definition = seriesDefinition({
|
||||||
id: 'series-pair',
|
id: 'series-pair',
|
||||||
|
|||||||
@@ -13,6 +13,12 @@ export type SeriesRule =
|
|||||||
drawPolicy: 'allow' | 'tiebreak-required';
|
drawPolicy: 'allow' | 'tiebreak-required';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface SeriesSchedule {
|
||||||
|
date: string;
|
||||||
|
time: string | null;
|
||||||
|
timeZone: 'Asia/Seoul';
|
||||||
|
}
|
||||||
|
|
||||||
export interface SeriesDefinitionLike {
|
export interface SeriesDefinitionLike {
|
||||||
id: string;
|
id: string;
|
||||||
code?: string;
|
code?: string;
|
||||||
@@ -26,6 +32,7 @@ export interface SeriesDefinitionLike {
|
|||||||
source: Readonly<Record<string, unknown>>;
|
source: Readonly<Record<string, unknown>>;
|
||||||
}>;
|
}>;
|
||||||
rule: SeriesRule;
|
rule: SeriesRule;
|
||||||
|
schedule?: SeriesSchedule;
|
||||||
gameSlots: ReadonlyArray<{
|
gameSlots: ReadonlyArray<{
|
||||||
id: string;
|
id: string;
|
||||||
seriesId: string;
|
seriesId: string;
|
||||||
@@ -75,6 +82,7 @@ interface SeriesProjectionBase {
|
|||||||
code?: string;
|
code?: string;
|
||||||
stage: SeriesDefinitionLike['stage'];
|
stage: SeriesDefinitionLike['stage'];
|
||||||
rule: SeriesRule;
|
rule: SeriesRule;
|
||||||
|
schedule?: SeriesSchedule;
|
||||||
entries: [SeriesProjectionEntry, SeriesProjectionEntry];
|
entries: [SeriesProjectionEntry, SeriesProjectionEntry];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,6 +319,15 @@ function validateDefinition(definition: SeriesDefinitionLike): void {
|
|||||||
`Series ${definition.id} must define exactly the local A and B slots`,
|
`Series ${definition.id} must define exactly the local A and B slots`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const schedule: unknown = definition.schedule;
|
||||||
|
if (schedule !== undefined) {
|
||||||
|
assertCompetitionInvariant(
|
||||||
|
isSeriesSchedule(schedule),
|
||||||
|
'SERIES_DEFINITION_INVALID',
|
||||||
|
`Series ${definition.id} has an invalid schedule`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const requiredSlots =
|
const requiredSlots =
|
||||||
definition.rule.type === 'fixed-games'
|
definition.rule.type === 'fixed-games'
|
||||||
? definition.rule.gameCount
|
? definition.rule.gameCount
|
||||||
@@ -753,6 +770,7 @@ function projectionBase(
|
|||||||
...(definition.code ? { code: definition.code } : {}),
|
...(definition.code ? { code: definition.code } : {}),
|
||||||
stage: definition.stage,
|
stage: definition.stage,
|
||||||
rule: definition.rule,
|
rule: definition.rule,
|
||||||
|
...(definition.schedule ? { schedule: { ...definition.schedule } } : {}),
|
||||||
entries: [
|
entries: [
|
||||||
{ slot: 'A', teamId: participants[0], gameWins: 0 },
|
{ slot: 'A', teamId: participants[0], gameWins: 0 },
|
||||||
{ slot: 'B', teamId: participants[1], gameWins: 0 },
|
{ slot: 'B', teamId: participants[1], gameWins: 0 },
|
||||||
@@ -760,6 +778,35 @@ function projectionBase(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isValidLocalDate(value: string): boolean {
|
||||||
|
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
||||||
|
if (!match) return false;
|
||||||
|
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));
|
||||||
|
return (
|
||||||
|
date.getUTCFullYear() === year &&
|
||||||
|
date.getUTCMonth() === month - 1 &&
|
||||||
|
date.getUTCDate() === day
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSeriesSchedule(value: unknown): value is SeriesSchedule {
|
||||||
|
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const schedule = value as Record<string, unknown>;
|
||||||
|
return (
|
||||||
|
typeof schedule.date === 'string' &&
|
||||||
|
isValidLocalDate(schedule.date) &&
|
||||||
|
(schedule.time === null ||
|
||||||
|
(typeof schedule.time === 'string' &&
|
||||||
|
/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(schedule.time))) &&
|
||||||
|
schedule.timeZone === 'Asia/Seoul'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function entriesFor(
|
function entriesFor(
|
||||||
participants: [string, string],
|
participants: [string, string],
|
||||||
winsByTeam: Map<string, number>,
|
winsByTeam: Map<string, number>,
|
||||||
|
|||||||
@@ -55,14 +55,14 @@ export function CompetitionGameHistory({
|
|||||||
to={detailPath}
|
to={detailPath}
|
||||||
state={{
|
state={{
|
||||||
backTo: historyBackTo,
|
backTo: historyBackTo,
|
||||||
backLabel: "경기 결과로 돌아가기",
|
backLabel: "경기 일정·결과로 돌아가기",
|
||||||
}}
|
}}
|
||||||
className="block min-h-11 border-l-2 border-l-transparent px-2 py-2 text-xs text-base-content transition-colors hover:border-l-primary hover:bg-primary/[0.06] active:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary motion-reduce:transition-none"
|
className="grid min-h-14 items-center px-2 py-2 text-xs leading-5 text-base-content transition-colors hover:bg-primary/[0.06] active:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary motion-reduce:transition-none"
|
||||||
>
|
>
|
||||||
{content}
|
{content}
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
<div className="min-h-11 border-l-2 border-l-transparent px-2 py-2 text-xs text-base-content">
|
<div className="grid min-h-14 items-center px-2 py-2 text-xs leading-5 text-base-content">
|
||||||
{content}
|
{content}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -84,50 +84,57 @@ function GameHistoryRowContent({
|
|||||||
duration: string | null;
|
duration: string | null;
|
||||||
linked: boolean;
|
linked: boolean;
|
||||||
}) {
|
}) {
|
||||||
|
const startedAt = formatCompetitionHistoryTime(game.startedAt);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span className="grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1.5 md:grid-cols-[minmax(10rem,1fr)_minmax(12rem,2fr)_minmax(10rem,1fr)] md:gap-4">
|
||||||
className={
|
<span className="col-span-2 row-start-1 min-w-0 break-words text-center font-semibold leading-5 md:col-span-1 md:col-start-2 md:row-start-1">
|
||||||
linked
|
|
||||||
? "grid grid-cols-[3.75rem_3.25rem_minmax(0,1fr)_3.5rem] items-center gap-2 md:grid-cols-[4.5rem_4rem_minmax(0,1fr)_4.5rem_6rem] md:gap-4"
|
|
||||||
: "grid grid-cols-[3.75rem_3.25rem_minmax(0,1fr)_3.5rem] items-center gap-2 md:grid-cols-[4.5rem_4rem_minmax(0,1fr)_4.5rem] md:gap-4"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span className="font-bold text-content-muted">
|
|
||||||
{game.ordinal}게임
|
|
||||||
</span>
|
|
||||||
<time
|
|
||||||
dateTime={game.startedAt}
|
|
||||||
className="font-mono tabular-nums text-content-muted"
|
|
||||||
>
|
|
||||||
{formatCompetitionHistoryTime(game.startedAt) ?? "—"}
|
|
||||||
</time>
|
|
||||||
<span className="min-w-0 break-words font-semibold">
|
|
||||||
{winnerName} 승
|
{winnerName} 승
|
||||||
</span>
|
</span>
|
||||||
<span
|
|
||||||
className="text-right font-mono tabular-nums text-content-muted"
|
<span className="col-start-1 row-start-2 flex min-w-0 items-center gap-3 text-content-muted md:col-start-1 md:row-start-1">
|
||||||
>
|
<span className="shrink-0 font-bold leading-5">
|
||||||
{duration ? (
|
{game.ordinal}게임
|
||||||
<>
|
</span>
|
||||||
<span className="sr-only">경기 시간 </span>
|
{startedAt ? (
|
||||||
{duration}
|
<time
|
||||||
</>
|
dateTime={game.startedAt}
|
||||||
|
className="shrink-0 font-mono leading-5 tabular-nums"
|
||||||
|
>
|
||||||
|
{startedAt}
|
||||||
|
</time>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<span className="shrink-0 font-mono leading-5 tabular-nums">
|
||||||
<span aria-hidden="true">—</span>
|
<span aria-hidden="true">—</span>
|
||||||
<span className="sr-only">경기 시간 기록 없음</span>
|
<span className="sr-only">시작 시각 기록 없음</span>
|
||||||
</>
|
</span>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
{linked && (
|
|
||||||
<span className="col-span-4 mt-1 flex items-center justify-end gap-0.5 font-bold text-content-subtle md:col-span-1 md:mt-0">
|
<span className="col-start-2 row-start-2 flex min-w-0 items-center justify-end gap-3 leading-5 md:col-start-3 md:row-start-1">
|
||||||
<span>상세 분석</span>
|
<span className="shrink-0 text-right font-mono tabular-nums text-content-muted">
|
||||||
<ChevronRight
|
{duration ? (
|
||||||
className="h-3.5 w-3.5 shrink-0 text-primary"
|
<>
|
||||||
aria-hidden="true"
|
<span className="sr-only">경기 시간 </span>
|
||||||
/>
|
{duration}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<span aria-hidden="true">—</span>
|
||||||
|
<span className="sr-only">경기 시간 기록 없음</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
)}
|
{linked && (
|
||||||
|
<span className="flex shrink-0 items-center justify-end gap-0.5 font-bold text-content-subtle">
|
||||||
|
<span>상세 분석</span>
|
||||||
|
<ChevronRight
|
||||||
|
className="h-3.5 w-3.5 shrink-0 text-primary"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -24,17 +24,18 @@ export function CompetitionResults({
|
|||||||
const teamById = new Map(
|
const teamById = new Map(
|
||||||
competition.teams.map((team) => [team.teamId, team]),
|
competition.teams.map((team) => [team.teamId, team]),
|
||||||
);
|
);
|
||||||
|
const seriesHistory =
|
||||||
|
view === "bracket" ? [] : createCompetitionSeriesHistory(projection);
|
||||||
|
|
||||||
if (view === "games") {
|
if (view === "games") {
|
||||||
const hasSeriesHistory =
|
const hasSeriesHistory = seriesHistory.length > 0;
|
||||||
createCompetitionSeriesHistory(projection).length > 0;
|
|
||||||
return (
|
return (
|
||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
{hasSeriesHistory ? (
|
{hasSeriesHistory ? (
|
||||||
<CompetitionSeriesHistory
|
<CompetitionSeriesHistory
|
||||||
communityId={competition.communityId}
|
communityId={competition.communityId}
|
||||||
matchId={competition.matchId}
|
matchId={competition.matchId}
|
||||||
projection={projection}
|
history={seriesHistory}
|
||||||
teamById={teamById}
|
teamById={teamById}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -42,7 +43,7 @@ export function CompetitionResults({
|
|||||||
className="border border-dashed border-base-content/15 px-4 py-8 text-center text-sm text-base-content/45"
|
className="border border-dashed border-base-content/15 px-4 py-8 text-center text-sm text-base-content/45"
|
||||||
role="status"
|
role="status"
|
||||||
>
|
>
|
||||||
기록된 공식 경기가 없습니다.
|
예정되거나 기록된 공식 경기가 없습니다.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -62,7 +63,7 @@ export function CompetitionResults({
|
|||||||
Competition
|
Competition
|
||||||
</p>
|
</p>
|
||||||
<h2 id="competition-heading" className="mt-1 text-lg font-bold">
|
<h2 id="competition-heading" className="mt-1 text-lg font-bold">
|
||||||
공식 경기 결과
|
공식 경기 일정·결과
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
@@ -114,7 +115,7 @@ export function CompetitionResults({
|
|||||||
<CompetitionSeriesHistory
|
<CompetitionSeriesHistory
|
||||||
communityId={competition.communityId}
|
communityId={competition.communityId}
|
||||||
matchId={competition.matchId}
|
matchId={competition.matchId}
|
||||||
projection={projection}
|
history={seriesHistory}
|
||||||
teamById={teamById}
|
teamById={teamById}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import type {
|
import type {
|
||||||
CommunityId,
|
CommunityId,
|
||||||
CompetitionProjection,
|
|
||||||
CompetitionTeamView,
|
CompetitionTeamView,
|
||||||
MatchId,
|
MatchId,
|
||||||
TeamId,
|
TeamId,
|
||||||
@@ -9,14 +8,16 @@ import { ChevronDown } from "lucide-react";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useLocation } from "react-router";
|
import { useLocation } from "react-router";
|
||||||
import {
|
import {
|
||||||
createCompetitionSeriesHistory,
|
formatCompetitionHistoryDate,
|
||||||
formatCompetitionHistoryDayHeading,
|
|
||||||
formatCompetitionHistoryTime,
|
|
||||||
getSeriesHistoryRecordLabel,
|
getSeriesHistoryRecordLabel,
|
||||||
getSeriesHistoryResultLabel,
|
getSeriesHistoryResultLabel,
|
||||||
getSeriesHistoryStatusLabel,
|
getSeriesHistoryStatusLabel,
|
||||||
|
getSeriesHistoryTimePresentation,
|
||||||
|
isCompetitionHistoryCalendarDate,
|
||||||
shouldDisplaySeriesHistoryScore,
|
shouldDisplaySeriesHistoryScore,
|
||||||
|
type CompetitionSeriesHistoryDay,
|
||||||
type CompetitionSeriesHistoryRow,
|
type CompetitionSeriesHistoryRow,
|
||||||
|
type CompetitionSeriesHistorySeries,
|
||||||
} from "./competition-series-history";
|
} from "./competition-series-history";
|
||||||
import { CompetitionGameHistory } from "./CompetitionGameHistory";
|
import { CompetitionGameHistory } from "./CompetitionGameHistory";
|
||||||
import { bracketRoundLabel } from "./double-elimination-bracket-layout";
|
import { bracketRoundLabel } from "./double-elimination-bracket-layout";
|
||||||
@@ -25,22 +26,29 @@ import { isSeriesEntryWinner } from "./series-score-card-model";
|
|||||||
export function CompetitionSeriesHistory({
|
export function CompetitionSeriesHistory({
|
||||||
communityId,
|
communityId,
|
||||||
matchId,
|
matchId,
|
||||||
projection,
|
history,
|
||||||
teamById,
|
teamById,
|
||||||
}: {
|
}: {
|
||||||
communityId: CommunityId;
|
communityId: CommunityId;
|
||||||
matchId: MatchId;
|
matchId: MatchId;
|
||||||
projection: CompetitionProjection;
|
history: CompetitionSeriesHistoryDay[];
|
||||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||||
}) {
|
}) {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const historyPath = `${location.pathname}${location.search}`;
|
const historyPath = `${location.pathname}${location.search}`;
|
||||||
const history = createCompetitionSeriesHistory(projection);
|
|
||||||
if (history.length === 0) return null;
|
if (history.length === 0) return null;
|
||||||
const resultCount = history.reduce(
|
|
||||||
(count, day) => count + day.rows.length,
|
const rows = history.flatMap((day) => day.rows);
|
||||||
0,
|
const anchorRow =
|
||||||
);
|
rows.find((row) => row.series.status === "in-progress") ??
|
||||||
|
rows.find((row) => isFutureSeries(row.series)) ??
|
||||||
|
rows.at(-1);
|
||||||
|
const jumpLabel =
|
||||||
|
anchorRow?.series.status === "in-progress"
|
||||||
|
? "진행 중 경기로"
|
||||||
|
: anchorRow && isFutureSeries(anchorRow.series)
|
||||||
|
? "다음 경기로"
|
||||||
|
: "최근 결과로";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
@@ -53,18 +61,18 @@ export function CompetitionSeriesHistory({
|
|||||||
id="competition-series-history-heading"
|
id="competition-series-history-heading"
|
||||||
className="text-sm font-bold"
|
className="text-sm font-bold"
|
||||||
>
|
>
|
||||||
경기 결과 기록
|
경기 일정·결과
|
||||||
</h3>
|
</h3>
|
||||||
<p className="mt-0.5 text-xs text-content-muted">
|
<p className="mt-0.5 text-xs text-content-muted">
|
||||||
진행 중인 시리즈와 최종 결과를 실제 경기 기록 순서로 보여줍니다.
|
예정 경기부터 최종 결과까지 날짜순으로 보여줍니다.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{resultCount > 1 && (
|
{rows.length > 1 && anchorRow && (
|
||||||
<a
|
<a
|
||||||
href="#competition-series-history-latest"
|
href="#competition-series-history-current"
|
||||||
className="inline-flex min-h-11 shrink-0 items-center gap-1 px-2 text-xs font-bold text-content-muted transition-colors hover:bg-base-content/[0.03] hover:text-base-content focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary"
|
className="inline-flex min-h-11 shrink-0 items-center gap-1 px-2 text-xs font-bold text-content-muted transition-colors hover:bg-base-content/[0.03] hover:text-base-content focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary"
|
||||||
>
|
>
|
||||||
최신 결과로
|
{jumpLabel}
|
||||||
<ChevronDown
|
<ChevronDown
|
||||||
className="h-4 w-4 text-primary"
|
className="h-4 w-4 text-primary"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
@@ -73,63 +81,50 @@ export function CompetitionSeriesHistory({
|
|||||||
)}
|
)}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div
|
|
||||||
className="hidden border-b border-base-content/10 bg-base-200/30 px-4 py-2 text-[11px] font-bold text-content-muted lg:grid lg:grid-cols-[minmax(0,1fr)_9rem_11rem_8rem] lg:gap-4"
|
|
||||||
aria-hidden="true"
|
|
||||||
>
|
|
||||||
<span>경기 결과</span>
|
|
||||||
<span>라운드</span>
|
|
||||||
<span>기록 시각 · 상태</span>
|
|
||||||
<span className="text-right">게임 상세</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{history.map((day, dayIndex) => {
|
{history.map((day) => {
|
||||||
const headingId = historyDayHeadingId(day.dateKey);
|
const headingId = historyDayHeadingId(day.dateKey);
|
||||||
const dayHeading = formatCompetitionHistoryDayHeading(
|
const dateLabel = formatCompetitionHistoryDate(day.dateKey);
|
||||||
day.dateKey,
|
|
||||||
day.rows.length,
|
|
||||||
);
|
|
||||||
return (
|
return (
|
||||||
<section key={day.dateKey} aria-labelledby={headingId}>
|
<section key={day.dateKey} aria-labelledby={headingId}>
|
||||||
<h4
|
<h4
|
||||||
id={headingId}
|
id={headingId}
|
||||||
className="scroll-mt-24 border-b border-base-content/10 bg-base-200/60 px-4 py-3 text-sm font-bold"
|
className="scroll-mt-24 flex items-center justify-between gap-3 border-b border-base-content/10 bg-base-200/60 px-4 py-3 text-sm font-bold"
|
||||||
>
|
>
|
||||||
{day.dateKey === "unknown" ? (
|
{isCompetitionHistoryCalendarDate(day.dateKey) ? (
|
||||||
dayHeading
|
<time dateTime={day.dateKey}>{dateLabel}</time>
|
||||||
) : (
|
) : (
|
||||||
<time dateTime={day.dateKey}>
|
<span>{dateLabel}</span>
|
||||||
{dayHeading}
|
|
||||||
</time>
|
|
||||||
)}
|
)}
|
||||||
|
<span className="shrink-0 text-xs font-semibold text-content-muted">
|
||||||
|
{day.rows.length}경기
|
||||||
|
</span>
|
||||||
</h4>
|
</h4>
|
||||||
<ol className="divide-y divide-base-content/10">
|
<ol className="divide-y divide-base-content/10">
|
||||||
{day.rows.map((row, rowIndex) => {
|
{day.rows.map((row) => (
|
||||||
const isLatestResult =
|
<li
|
||||||
dayIndex === history.length - 1 &&
|
key={row.series.seriesId}
|
||||||
rowIndex === day.rows.length - 1;
|
id={
|
||||||
return (
|
row.series.seriesId === anchorRow?.series.seriesId
|
||||||
<li
|
? "competition-series-history-current"
|
||||||
key={row.series.seriesId}
|
: undefined
|
||||||
id={
|
}
|
||||||
isLatestResult
|
className={
|
||||||
? "competition-series-history-latest"
|
row.series.seriesId === anchorRow?.series.seriesId
|
||||||
: undefined
|
? "scroll-mt-24"
|
||||||
}
|
: undefined
|
||||||
className={isLatestResult ? "scroll-mt-24" : undefined}
|
}
|
||||||
>
|
>
|
||||||
<SeriesHistoryRow
|
<SeriesHistoryRow
|
||||||
row={row}
|
row={row}
|
||||||
teamById={teamById}
|
teamById={teamById}
|
||||||
communityId={communityId}
|
communityId={communityId}
|
||||||
matchId={matchId}
|
matchId={matchId}
|
||||||
historyPath={historyPath}
|
historyPath={historyPath}
|
||||||
currentHash={location.hash}
|
currentHash={location.hash}
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
);
|
))}
|
||||||
})}
|
|
||||||
</ol>
|
</ol>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
@@ -204,8 +199,6 @@ function SeriesSummary({
|
|||||||
}) {
|
}) {
|
||||||
const { series } = row;
|
const { series } = row;
|
||||||
const statusLabel = getSeriesHistoryStatusLabel(series);
|
const statusLabel = getSeriesHistoryStatusLabel(series);
|
||||||
const timeLabel = formatCompetitionHistoryTime(row.occurredAt);
|
|
||||||
const timeKind = row.timestampSource === "game-start" ? "시작" : "결정";
|
|
||||||
const roundLabel = bracketRoundLabel(
|
const roundLabel = bracketRoundLabel(
|
||||||
series.stage.type,
|
series.stage.type,
|
||||||
series.stage.roundNumber,
|
series.stage.roundNumber,
|
||||||
@@ -215,89 +208,98 @@ function SeriesSummary({
|
|||||||
row.games.length,
|
row.games.length,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
const showRecordLabel = hasGameDetails || !isFutureSeries(series);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className="block px-4 py-3 lg:grid lg:min-h-20 lg:grid-cols-[minmax(0,1fr)_9rem_11rem_8rem] lg:items-center lg:gap-4">
|
<span className="block px-4 py-3 lg:grid lg:min-h-20 lg:grid-cols-[minmax(13rem,1fr)_minmax(20rem,2fr)_minmax(13rem,1fr)] lg:items-center lg:gap-4">
|
||||||
<span className="block">
|
<span className="block min-w-0 lg:col-start-2 lg:row-start-1">
|
||||||
<SeriesMatchup row={row} teamById={teamById} />
|
<SeriesMatchup row={row} teamById={teamById} />
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span className="mt-3 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 lg:contents">
|
<span className="mt-3 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 lg:col-start-1 lg:row-start-1 lg:mt-0 lg:flex-col lg:items-start lg:gap-1.5">
|
||||||
|
<span className="flex min-w-0 flex-wrap items-center gap-2">
|
||||||
|
<HistoryTime row={row} />
|
||||||
|
<StatusLabel series={series} label={statusLabel} />
|
||||||
|
</span>
|
||||||
<span className="min-w-0 break-words text-xs leading-4 text-content-muted">
|
<span className="min-w-0 break-words text-xs leading-4 text-content-muted">
|
||||||
{roundLabel}
|
{roundLabel}
|
||||||
</span>
|
</span>
|
||||||
<span className="flex min-w-0 flex-wrap items-center gap-2">
|
|
||||||
<HistoryTime
|
|
||||||
occurredAt={row.occurredAt}
|
|
||||||
timeKind={timeKind}
|
|
||||||
timeLabel={timeLabel}
|
|
||||||
/>
|
|
||||||
<StatusLabel
|
|
||||||
label={statusLabel}
|
|
||||||
inProgress={series.status === "in-progress"}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span className="mt-2 flex min-h-6 items-center justify-end text-xs font-bold text-content-muted lg:mt-0">
|
{showRecordLabel && (
|
||||||
{hasGameDetails ? (
|
<span className="mt-2 flex min-h-6 items-center justify-end text-xs font-bold text-content-muted lg:col-start-3 lg:row-start-1 lg:mt-0">
|
||||||
<>
|
{hasGameDetails ? (
|
||||||
<span className="group-open:hidden">{closedRecordLabel}</span>
|
<>
|
||||||
<span className="hidden group-open:inline">
|
<span className="group-open:hidden">{closedRecordLabel}</span>
|
||||||
{getSeriesHistoryRecordLabel(series, row.games.length, true)}
|
<span className="hidden group-open:inline">
|
||||||
</span>
|
{getSeriesHistoryRecordLabel(series, row.games.length, true)}
|
||||||
<ChevronDown
|
</span>
|
||||||
className="ml-1 h-4 w-4 text-primary transition-transform group-open:rotate-180 motion-reduce:transition-none"
|
<ChevronDown
|
||||||
aria-hidden="true"
|
className="ml-1 h-4 w-4 text-primary transition-transform group-open:rotate-180 motion-reduce:transition-none"
|
||||||
/>
|
aria-hidden="true"
|
||||||
</>
|
/>
|
||||||
) : (
|
</>
|
||||||
<span>{closedRecordLabel}</span>
|
) : (
|
||||||
)}
|
<span>{closedRecordLabel}</span>
|
||||||
</span>
|
)}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function HistoryTime({
|
function HistoryTime({ row }: { row: CompetitionSeriesHistoryRow }) {
|
||||||
occurredAt,
|
const presentation = getSeriesHistoryTimePresentation(row);
|
||||||
timeKind,
|
const kindLabel =
|
||||||
timeLabel,
|
row.timestampSource === "decision"
|
||||||
}: {
|
? "결정"
|
||||||
occurredAt: string;
|
: row.timestampSource === "scheduled" ||
|
||||||
timeKind: "시작" | "결정";
|
row.timestampSource === "unavailable"
|
||||||
timeLabel: string | null;
|
? "예정"
|
||||||
}) {
|
: "시작";
|
||||||
return timeLabel ? (
|
|
||||||
<time
|
if (presentation.dateTime) {
|
||||||
dateTime={occurredAt}
|
return (
|
||||||
className="shrink-0 text-xs font-bold tabular-nums text-content-muted"
|
<time
|
||||||
>
|
dateTime={presentation.dateTime}
|
||||||
{timeKind} <span className="font-mono">{timeLabel}</span>
|
aria-label={`${kindLabel} 시각 ${presentation.text}`}
|
||||||
</time>
|
className="shrink-0 text-sm font-bold tabular-nums text-base-content"
|
||||||
) : (
|
>
|
||||||
<span className="shrink-0 text-xs font-bold text-content-muted">
|
{row.timestampSource === "decision" && (
|
||||||
<span aria-hidden="true">{timeKind} —</span>
|
<span className="mr-1 text-xs text-content-muted">결정</span>
|
||||||
<span className="sr-only">{timeKind} 시각 기록 없음</span>
|
)}
|
||||||
|
<span className="font-mono">{presentation.text}</span>
|
||||||
|
</time>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span className="shrink-0 text-sm font-bold text-content-muted">
|
||||||
|
<span aria-hidden="true" className="font-mono tabular-nums">
|
||||||
|
{presentation.text}
|
||||||
|
</span>
|
||||||
|
{presentation.screenReaderText && (
|
||||||
|
<span className="sr-only">{presentation.screenReaderText}</span>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StatusLabel({
|
function StatusLabel({
|
||||||
|
series,
|
||||||
label,
|
label,
|
||||||
inProgress,
|
|
||||||
}: {
|
}: {
|
||||||
|
series: CompetitionSeriesHistorySeries;
|
||||||
label: string;
|
label: string;
|
||||||
inProgress: boolean;
|
|
||||||
}) {
|
}) {
|
||||||
|
const tone =
|
||||||
|
series.status === "in-progress"
|
||||||
|
? "bg-primary/10 text-base-content"
|
||||||
|
: series.status === "inactive"
|
||||||
|
? "bg-info/10 text-base-content"
|
||||||
|
: "bg-base-200 text-content-muted";
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`shrink-0 px-1.5 py-0.5 text-xs font-bold ${tone}`}>
|
||||||
className={`shrink-0 px-1.5 py-0.5 text-xs font-bold ${
|
|
||||||
inProgress
|
|
||||||
? "border-l-2 border-primary bg-primary/10 text-base-content"
|
|
||||||
: "border-l-2 border-base-content/15 bg-base-200 text-base-content"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{label}
|
{label}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
@@ -317,7 +319,6 @@ function SeriesMatchup({
|
|||||||
const teamBWon = isSeriesEntryWinner(row.series, entryB.teamId);
|
const teamBWon = isSeriesEntryWinner(row.series, entryB.teamId);
|
||||||
const showScore = shouldDisplaySeriesHistoryScore(row.series);
|
const showScore = shouldDisplaySeriesHistoryScore(row.series);
|
||||||
const resultLabel = getSeriesHistoryResultLabel(row.series);
|
const resultLabel = getSeriesHistoryResultLabel(row.series);
|
||||||
const statusLabel = getSeriesHistoryStatusLabel(row.series);
|
|
||||||
const officialWinnerTeamId =
|
const officialWinnerTeamId =
|
||||||
row.series.status === "completed" && row.series.outcome.type !== "draw"
|
row.series.status === "completed" && row.series.outcome.type !== "draw"
|
||||||
? row.series.outcome.winnerTeamId
|
? row.series.outcome.winnerTeamId
|
||||||
@@ -327,11 +328,10 @@ function SeriesMatchup({
|
|||||||
: `${teamAName} 대 ${teamBName}`;
|
: `${teamAName} 대 ${teamBName}`;
|
||||||
const accessibleResult = [
|
const accessibleResult = [
|
||||||
matchupAnnouncement,
|
matchupAnnouncement,
|
||||||
resultLabel,
|
resultLabel === "VS" ? null : resultLabel,
|
||||||
officialWinnerTeamId
|
officialWinnerTeamId
|
||||||
? `${teamName(officialWinnerTeamId, teamById)} 승`
|
? `${teamName(officialWinnerTeamId, teamById)} 승`
|
||||||
: null,
|
: null,
|
||||||
statusLabel,
|
|
||||||
]
|
]
|
||||||
.filter((part): part is string => Boolean(part))
|
.filter((part): part is string => Boolean(part))
|
||||||
.join(", ");
|
.join(", ");
|
||||||
@@ -339,7 +339,7 @@ function SeriesMatchup({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span
|
<span
|
||||||
className="grid grid-cols-[minmax(0,1fr)_5rem_minmax(0,1fr)] items-center gap-2"
|
className="grid w-full grid-cols-[minmax(0,1fr)_4.5rem_minmax(0,1fr)] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_5rem_minmax(0,1fr)]"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
>
|
>
|
||||||
<TeamName name={teamAName} winner={teamAWon} align="right" />
|
<TeamName name={teamAName} winner={teamAWon} align="right" />
|
||||||
@@ -367,8 +367,10 @@ function SeriesMatchup({
|
|||||||
<span
|
<span
|
||||||
className={
|
className={
|
||||||
showScore
|
showScore
|
||||||
? "mt-0.5 text-[11px] font-bold leading-4 text-content-muted"
|
? "mt-0.5 text-xs font-bold leading-4 text-content-muted"
|
||||||
: "text-sm font-bold leading-5 text-base-content"
|
: row.series.status === "completed"
|
||||||
|
? "text-sm font-bold leading-5 text-base-content"
|
||||||
|
: "text-sm font-bold leading-5 text-content-muted"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{resultLabel}
|
{resultLabel}
|
||||||
@@ -393,26 +395,35 @@ function TeamName({
|
|||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={`min-w-0 break-words text-sm leading-5 ${
|
className={`flex min-h-10 min-w-0 items-center gap-1 text-sm leading-5 ${
|
||||||
align === "right" ? "text-right" : "text-left"
|
align === "right" ? "justify-end text-right" : "justify-start text-left"
|
||||||
} ${winner ? "font-bold text-base-content" : "text-content-subtle"}`}
|
} ${winner ? "font-bold text-base-content" : "text-content-subtle"}`}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
>
|
>
|
||||||
{name}
|
<span className="min-w-0 break-words">{name}</span>
|
||||||
{winner && (
|
{winner && (
|
||||||
<span className="ml-1 text-xs font-bold text-base-content">승</span>
|
<span className="shrink-0 text-xs font-bold text-base-content">승</span>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function teamName(
|
function teamName(
|
||||||
teamId: TeamId,
|
teamId: TeamId | null,
|
||||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>,
|
teamById: ReadonlyMap<TeamId, CompetitionTeamView>,
|
||||||
): string {
|
): string {
|
||||||
|
if (teamId === null) return "미정";
|
||||||
return teamById.get(teamId)?.name ?? "알 수 없는 팀";
|
return teamById.get(teamId)?.name ?? "알 수 없는 팀";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isFutureSeries(series: CompetitionSeriesHistorySeries): boolean {
|
||||||
|
return (
|
||||||
|
series.status === "inactive" ||
|
||||||
|
series.status === "waiting" ||
|
||||||
|
series.status === "ready"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function historyDayHeadingId(dateKey: string): string {
|
function historyDayHeadingId(dateKey: string): string {
|
||||||
return `competition-series-history-day-${dateKey}`;
|
return `competition-series-history-day-${dateKey}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,24 @@ import type {
|
|||||||
CompetitionProjection,
|
CompetitionProjection,
|
||||||
IsoDateTime,
|
IsoDateTime,
|
||||||
SeriesProjection,
|
SeriesProjection,
|
||||||
|
SeriesSchedule,
|
||||||
} from "@lolympus/contracts";
|
} from "@lolympus/contracts";
|
||||||
import { internalMatchGamePath } from "../../lib/internal-match-routes.ts";
|
import { internalMatchGamePath } from "../../lib/internal-match-routes.ts";
|
||||||
|
|
||||||
export type CompetitionSeriesHistorySeries = Extract<
|
export type CompetitionSeriesHistorySeries = SeriesProjection;
|
||||||
SeriesProjection,
|
|
||||||
{ status: "in-progress" | "completed" }
|
export type CompetitionSeriesHistoryTimestampSource =
|
||||||
>;
|
| "game-start"
|
||||||
|
| "decision"
|
||||||
|
| "scheduled"
|
||||||
|
| "unavailable";
|
||||||
|
|
||||||
export interface CompetitionSeriesHistoryRow {
|
export interface CompetitionSeriesHistoryRow {
|
||||||
series: CompetitionSeriesHistorySeries;
|
series: CompetitionSeriesHistorySeries;
|
||||||
games: CompetitionGameView[];
|
games: CompetitionGameView[];
|
||||||
occurredAt: IsoDateTime;
|
occurredAt: IsoDateTime | null;
|
||||||
timestampSource: "game-start" | "decision";
|
timestampSource: CompetitionSeriesHistoryTimestampSource;
|
||||||
|
dateKey: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CompetitionSeriesHistoryDay {
|
export interface CompetitionSeriesHistoryDay {
|
||||||
@@ -23,6 +28,12 @@ export interface CompetitionSeriesHistoryDay {
|
|||||||
rows: CompetitionSeriesHistoryRow[];
|
rows: CompetitionSeriesHistoryRow[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SeriesHistoryTimePresentation {
|
||||||
|
text: string;
|
||||||
|
dateTime: string | null;
|
||||||
|
screenReaderText: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
type HistoryProjection = Pick<CompetitionProjection, "series" | "games">;
|
type HistoryProjection = Pick<CompetitionProjection, "series" | "games">;
|
||||||
|
|
||||||
const KOREAN_WEEKDAYS = [
|
const KOREAN_WEEKDAYS = [
|
||||||
@@ -35,6 +46,9 @@ const KOREAN_WEEKDAYS = [
|
|||||||
"토",
|
"토",
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
const UNKNOWN_DATE_KEY = "unknown";
|
||||||
|
const UNKNOWN_RECORD_DATE_KEY = "record-unknown";
|
||||||
|
|
||||||
export function competitionHistoryGameDetailPath(
|
export function competitionHistoryGameDetailPath(
|
||||||
communityId: string,
|
communityId: string,
|
||||||
matchId: string,
|
matchId: string,
|
||||||
@@ -62,38 +76,72 @@ export function createCompetitionSeriesHistory(
|
|||||||
const games = [...(gamesBySeriesId.get(series.seriesId) ?? [])].sort(
|
const games = [...(gamesBySeriesId.get(series.seriesId) ?? [])].sort(
|
||||||
compareGames,
|
compareGames,
|
||||||
);
|
);
|
||||||
if (series.status === "in-progress") {
|
|
||||||
const occurredAt = earliestStartedAt(games);
|
|
||||||
if (!occurredAt) continue;
|
|
||||||
rows.push({
|
|
||||||
series,
|
|
||||||
games,
|
|
||||||
occurredAt,
|
|
||||||
timestampSource: "game-start",
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (series.status !== "completed") continue;
|
|
||||||
|
|
||||||
const gameStartedAt = earliestStartedAt(games);
|
switch (series.status) {
|
||||||
rows.push({
|
case "completed": {
|
||||||
series,
|
if (hasInvalidStartedAt(games)) {
|
||||||
games,
|
rows.push(missingRecordedGameTimeRow(series, games));
|
||||||
occurredAt: gameStartedAt ?? series.outcome.completedAt,
|
break;
|
||||||
timestampSource: gameStartedAt ? "game-start" : "decision",
|
}
|
||||||
});
|
const gameStartedAt = earliestStartedAt(games);
|
||||||
|
if (games.length > 0 && !gameStartedAt) {
|
||||||
|
rows.push(missingRecordedGameTimeRow(series, games));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const occurredAt = gameStartedAt ?? series.outcome.completedAt;
|
||||||
|
rows.push({
|
||||||
|
series,
|
||||||
|
games,
|
||||||
|
occurredAt,
|
||||||
|
timestampSource: gameStartedAt ? "game-start" : "decision",
|
||||||
|
dateKey:
|
||||||
|
dateKeyInTimeZone(occurredAt, timeZone) ??
|
||||||
|
UNKNOWN_RECORD_DATE_KEY,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "in-progress": {
|
||||||
|
if (hasInvalidStartedAt(games)) {
|
||||||
|
rows.push(missingRecordedGameTimeRow(series, games));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const gameStartedAt = earliestStartedAt(games);
|
||||||
|
if (gameStartedAt) {
|
||||||
|
rows.push({
|
||||||
|
series,
|
||||||
|
games,
|
||||||
|
occurredAt: gameStartedAt,
|
||||||
|
timestampSource: "game-start",
|
||||||
|
dateKey:
|
||||||
|
dateKeyInTimeZone(gameStartedAt, timeZone) ??
|
||||||
|
UNKNOWN_RECORD_DATE_KEY,
|
||||||
|
});
|
||||||
|
} else if (games.length > 0) {
|
||||||
|
rows.push(missingRecordedGameTimeRow(series, games));
|
||||||
|
} else if (series.schedule) {
|
||||||
|
rows.push(scheduledRow(series, games));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "ready":
|
||||||
|
case "waiting":
|
||||||
|
rows.push(scheduledRow(series, games));
|
||||||
|
break;
|
||||||
|
case "inactive":
|
||||||
|
if (series.schedule) rows.push(scheduledRow(series, games));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rows.sort(compareRows);
|
rows.sort(compareRows);
|
||||||
|
|
||||||
const days: CompetitionSeriesHistoryDay[] = [];
|
const days: CompetitionSeriesHistoryDay[] = [];
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
const dateKey = dateKeyInTimeZone(row.occurredAt, timeZone);
|
|
||||||
const currentDay = days.at(-1);
|
const currentDay = days.at(-1);
|
||||||
if (currentDay?.dateKey === dateKey) {
|
if (currentDay?.dateKey === row.dateKey) {
|
||||||
currentDay.rows.push(row);
|
currentDay.rows.push(row);
|
||||||
} else {
|
} else {
|
||||||
days.push({ dateKey, rows: [row] });
|
days.push({ dateKey: row.dateKey, rows: [row] });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return days;
|
return days;
|
||||||
@@ -102,13 +150,29 @@ export function createCompetitionSeriesHistory(
|
|||||||
export function getSeriesHistoryStatusLabel(
|
export function getSeriesHistoryStatusLabel(
|
||||||
series: CompetitionSeriesHistorySeries,
|
series: CompetitionSeriesHistorySeries,
|
||||||
): string {
|
): string {
|
||||||
if (series.status === "in-progress") return "진행 중";
|
switch (series.status) {
|
||||||
return "최종";
|
case "inactive":
|
||||||
|
return "필요 시";
|
||||||
|
case "waiting":
|
||||||
|
case "ready":
|
||||||
|
return "예정";
|
||||||
|
case "in-progress":
|
||||||
|
return "진행 중";
|
||||||
|
case "completed":
|
||||||
|
return "최종";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSeriesHistoryResultLabel(
|
export function getSeriesHistoryResultLabel(
|
||||||
series: CompetitionSeriesHistorySeries,
|
series: CompetitionSeriesHistorySeries,
|
||||||
): string | null {
|
): string | null {
|
||||||
|
if (
|
||||||
|
series.status === "inactive" ||
|
||||||
|
series.status === "waiting" ||
|
||||||
|
series.status === "ready"
|
||||||
|
) {
|
||||||
|
return "VS";
|
||||||
|
}
|
||||||
if (series.status === "in-progress") return null;
|
if (series.status === "in-progress") return null;
|
||||||
switch (series.outcome.type) {
|
switch (series.outcome.type) {
|
||||||
case "played":
|
case "played":
|
||||||
@@ -134,6 +198,13 @@ export function getSeriesHistoryRecordLabel(
|
|||||||
if (gameCount > 0) {
|
if (gameCount > 0) {
|
||||||
return expanded ? "게임 상세 접기" : `게임 상세 (${gameCount})`;
|
return expanded ? "게임 상세 접기" : `게임 상세 (${gameCount})`;
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
series.status === "inactive" ||
|
||||||
|
series.status === "waiting" ||
|
||||||
|
series.status === "ready"
|
||||||
|
) {
|
||||||
|
return "게임 전";
|
||||||
|
}
|
||||||
if (isGameLessDecision(series)) return "경기 없이 결정";
|
if (isGameLessDecision(series)) return "경기 없이 결정";
|
||||||
return "게임 기록 미등록";
|
return "게임 기록 미등록";
|
||||||
}
|
}
|
||||||
@@ -142,12 +213,58 @@ export function shouldDisplaySeriesHistoryScore(
|
|||||||
series: CompetitionSeriesHistorySeries,
|
series: CompetitionSeriesHistorySeries,
|
||||||
): boolean {
|
): boolean {
|
||||||
if (series.status === "in-progress") return true;
|
if (series.status === "in-progress") return true;
|
||||||
|
if (series.status !== "completed") return false;
|
||||||
if (series.outcome.type === "played") return true;
|
if (series.outcome.type === "played") return true;
|
||||||
return (
|
return (
|
||||||
series.outcome.type === "draw" && series.outcome.basis.type === "played"
|
series.outcome.type === "draw" && series.outcome.basis.type === "played"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getSeriesHistoryTimePresentation(
|
||||||
|
row: CompetitionSeriesHistoryRow,
|
||||||
|
): SeriesHistoryTimePresentation {
|
||||||
|
if (row.timestampSource === "scheduled") {
|
||||||
|
const schedule = row.series.schedule;
|
||||||
|
if (
|
||||||
|
schedule?.time &&
|
||||||
|
isValidLocalDate(schedule.date) &&
|
||||||
|
isValidLocalTime(schedule.time)
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
text: schedule.time,
|
||||||
|
dateTime: localScheduleDateTime(schedule),
|
||||||
|
screenReaderText: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (row.timestampSource === "unavailable") {
|
||||||
|
return {
|
||||||
|
text: "--:--",
|
||||||
|
dateTime: null,
|
||||||
|
screenReaderText: "시작 시간 미정",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const text = row.occurredAt
|
||||||
|
? formatCompetitionHistoryTime(row.occurredAt)
|
||||||
|
: null;
|
||||||
|
if (text && row.occurredAt) {
|
||||||
|
return {
|
||||||
|
text,
|
||||||
|
dateTime: row.occurredAt,
|
||||||
|
screenReaderText: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const kind = row.timestampSource === "decision" ? "결정" : "시작";
|
||||||
|
return {
|
||||||
|
text: "—",
|
||||||
|
dateTime: null,
|
||||||
|
screenReaderText: `${kind} 시각 기록 없음`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function formatSeriesGameDuration(
|
export function formatSeriesGameDuration(
|
||||||
durationSeconds: number,
|
durationSeconds: number,
|
||||||
): string | null {
|
): string | null {
|
||||||
@@ -163,8 +280,9 @@ export function formatSeriesGameDuration(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function formatCompetitionHistoryDate(dateKey: string): string {
|
export function formatCompetitionHistoryDate(dateKey: string): string {
|
||||||
|
if (dateKey === UNKNOWN_RECORD_DATE_KEY) return "기록 일시 미상";
|
||||||
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(dateKey);
|
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(dateKey);
|
||||||
if (!match) return "일시 정보 없음";
|
if (!match) return "일정 미정";
|
||||||
const year = Number(match[1]);
|
const year = Number(match[1]);
|
||||||
const month = Number(match[2]);
|
const month = Number(match[2]);
|
||||||
const day = Number(match[3]);
|
const day = Number(match[3]);
|
||||||
@@ -174,16 +292,13 @@ export function formatCompetitionHistoryDate(dateKey: string): string {
|
|||||||
date.getUTCMonth() !== month - 1 ||
|
date.getUTCMonth() !== month - 1 ||
|
||||||
date.getUTCDate() !== day
|
date.getUTCDate() !== day
|
||||||
) {
|
) {
|
||||||
return "일시 정보 없음";
|
return "일정 미정";
|
||||||
}
|
}
|
||||||
return `${month}월 ${day}일 (${KOREAN_WEEKDAYS[date.getUTCDay()]})`;
|
return `${month}월 ${padNumber(day)}일 (${KOREAN_WEEKDAYS[date.getUTCDay()]})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatCompetitionHistoryDayHeading(
|
export function isCompetitionHistoryCalendarDate(dateKey: string): boolean {
|
||||||
dateKey: string,
|
return isValidLocalDate(dateKey);
|
||||||
gameCount: number,
|
|
||||||
): string {
|
|
||||||
return `${formatCompetitionHistoryDate(dateKey)} · ${gameCount}경기`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatCompetitionHistoryTime(
|
export function formatCompetitionHistoryTime(
|
||||||
@@ -205,6 +320,47 @@ export function formatCompetitionHistoryTime(
|
|||||||
return hour && minute ? `${hour}:${minute}` : null;
|
return hour && minute ? `${hour}:${minute}` : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scheduledRow(
|
||||||
|
series: CompetitionSeriesHistorySeries,
|
||||||
|
games: CompetitionGameView[],
|
||||||
|
): CompetitionSeriesHistoryRow {
|
||||||
|
const schedule = series.schedule;
|
||||||
|
const dateKey =
|
||||||
|
schedule && isValidLocalDate(schedule.date)
|
||||||
|
? schedule.date
|
||||||
|
: UNKNOWN_DATE_KEY;
|
||||||
|
const occurredAt =
|
||||||
|
schedule?.time &&
|
||||||
|
isValidLocalTime(schedule.time) &&
|
||||||
|
dateKey !== UNKNOWN_DATE_KEY
|
||||||
|
? localScheduleDateTime(schedule)
|
||||||
|
: null;
|
||||||
|
return {
|
||||||
|
series,
|
||||||
|
games,
|
||||||
|
occurredAt,
|
||||||
|
timestampSource: occurredAt ? "scheduled" : "unavailable",
|
||||||
|
dateKey,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function missingRecordedGameTimeRow(
|
||||||
|
series: CompetitionSeriesHistorySeries,
|
||||||
|
games: CompetitionGameView[],
|
||||||
|
): CompetitionSeriesHistoryRow {
|
||||||
|
return {
|
||||||
|
series,
|
||||||
|
games,
|
||||||
|
occurredAt: null,
|
||||||
|
timestampSource: "game-start",
|
||||||
|
dateKey: UNKNOWN_RECORD_DATE_KEY,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function localScheduleDateTime(schedule: SeriesSchedule): IsoDateTime {
|
||||||
|
return `${schedule.date}T${schedule.time}:00+09:00`;
|
||||||
|
}
|
||||||
|
|
||||||
function compareGames(
|
function compareGames(
|
||||||
left: CompetitionGameView,
|
left: CompetitionGameView,
|
||||||
right: CompetitionGameView,
|
right: CompetitionGameView,
|
||||||
@@ -221,12 +377,32 @@ function compareRows(
|
|||||||
right: CompetitionSeriesHistoryRow,
|
right: CompetitionSeriesHistoryRow,
|
||||||
): number {
|
): number {
|
||||||
return (
|
return (
|
||||||
timestampValue(left.occurredAt) - timestampValue(right.occurredAt) ||
|
compareDateKeys(left.dateKey, right.dateKey) ||
|
||||||
|
rowTimeValue(left) - rowTimeValue(right) ||
|
||||||
left.series.stage.displayOrder - right.series.stage.displayOrder ||
|
left.series.stage.displayOrder - right.series.stage.displayOrder ||
|
||||||
left.series.seriesId.localeCompare(right.series.seriesId)
|
left.series.seriesId.localeCompare(right.series.seriesId)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function compareDateKeys(left: string, right: string): number {
|
||||||
|
if (left === right) return 0;
|
||||||
|
const leftRank = dateKeyRank(left);
|
||||||
|
const rightRank = dateKeyRank(right);
|
||||||
|
if (leftRank !== rightRank) return leftRank - rightRank;
|
||||||
|
return left.localeCompare(right);
|
||||||
|
}
|
||||||
|
|
||||||
|
function dateKeyRank(dateKey: string): number {
|
||||||
|
if (dateKey === UNKNOWN_RECORD_DATE_KEY) return 1;
|
||||||
|
if (dateKey === UNKNOWN_DATE_KEY) return 2;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rowTimeValue(row: CompetitionSeriesHistoryRow): number {
|
||||||
|
if (!row.occurredAt) return Number.POSITIVE_INFINITY;
|
||||||
|
return timestampValue(row.occurredAt);
|
||||||
|
}
|
||||||
|
|
||||||
function earliestStartedAt(games: CompetitionGameView[]): IsoDateTime | null {
|
function earliestStartedAt(games: CompetitionGameView[]): IsoDateTime | null {
|
||||||
let earliest: { value: number; startedAt: IsoDateTime } | null = null;
|
let earliest: { value: number; startedAt: IsoDateTime } | null = null;
|
||||||
for (const game of games) {
|
for (const game of games) {
|
||||||
@@ -239,9 +415,18 @@ function earliestStartedAt(games: CompetitionGameView[]): IsoDateTime | null {
|
|||||||
return earliest?.startedAt ?? null;
|
return earliest?.startedAt ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function dateKeyInTimeZone(value: IsoDateTime, timeZone: string): string {
|
function hasInvalidStartedAt(games: CompetitionGameView[]): boolean {
|
||||||
|
return games.some(
|
||||||
|
(game) => !Number.isFinite(timestampValue(game.startedAt)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function dateKeyInTimeZone(
|
||||||
|
value: IsoDateTime,
|
||||||
|
timeZone: string,
|
||||||
|
): string | null {
|
||||||
const date = new Date(value);
|
const date = new Date(value);
|
||||||
if (Number.isNaN(date.getTime())) return "unknown";
|
if (Number.isNaN(date.getTime())) return null;
|
||||||
const parts = new Intl.DateTimeFormat("en-US", {
|
const parts = new Intl.DateTimeFormat("en-US", {
|
||||||
timeZone,
|
timeZone,
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
@@ -253,7 +438,7 @@ function dateKeyInTimeZone(value: IsoDateTime, timeZone: string): string {
|
|||||||
const year = part("year");
|
const year = part("year");
|
||||||
const month = part("month");
|
const month = part("month");
|
||||||
const day = part("day");
|
const day = part("day");
|
||||||
return year && month && day ? `${year}-${month}-${day}` : "unknown";
|
return year && month && day ? `${year}-${month}-${day}` : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function timestampValue(value: IsoDateTime): number {
|
function timestampValue(value: IsoDateTime): number {
|
||||||
@@ -264,13 +449,31 @@ function timestampValue(value: IsoDateTime): number {
|
|||||||
function isGameLessDecision(
|
function isGameLessDecision(
|
||||||
series: CompetitionSeriesHistorySeries,
|
series: CompetitionSeriesHistorySeries,
|
||||||
): boolean {
|
): boolean {
|
||||||
if (series.status === "in-progress") return false;
|
if (series.status !== "completed") return false;
|
||||||
if (series.outcome.type === "draw") {
|
if (series.outcome.type === "draw") {
|
||||||
return series.outcome.basis.type !== "played";
|
return series.outcome.basis.type !== "played";
|
||||||
}
|
}
|
||||||
return series.outcome.type !== "played";
|
return series.outcome.type !== "played";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isValidLocalDate(value: string): boolean {
|
||||||
|
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
||||||
|
if (!match) return false;
|
||||||
|
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));
|
||||||
|
return (
|
||||||
|
date.getUTCFullYear() === year &&
|
||||||
|
date.getUTCMonth() === month - 1 &&
|
||||||
|
date.getUTCDate() === day
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isValidLocalTime(value: string): boolean {
|
||||||
|
return /^(?:[01]\d|2[0-3]):[0-5]\d$/.test(value);
|
||||||
|
}
|
||||||
|
|
||||||
function padNumber(value: number): string {
|
function padNumber(value: number): string {
|
||||||
return value.toString().padStart(2, "0");
|
return value.toString().padStart(2, "0");
|
||||||
}
|
}
|
||||||
@@ -26,9 +26,9 @@ export const MATCH_DETAIL_TAB_QUERY_KEY = "tab";
|
|||||||
|
|
||||||
const PUBLIC_MATCH_DETAIL_TABS: MatchDetailTab[] = [
|
const PUBLIC_MATCH_DETAIL_TABS: MatchDetailTab[] = [
|
||||||
{ id: "bracket", label: "대진표·순위" },
|
{ id: "bracket", label: "대진표·순위" },
|
||||||
{ id: "games", label: "경기 기록" },
|
{ id: "games", label: "경기 일정·결과" },
|
||||||
{ id: "teams", label: "팀" },
|
{ id: "teams", label: "팀" },
|
||||||
{ id: "info", label: "일정·안내" },
|
{ id: "info", label: "안내" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const OPERATIONS_TAB: MatchDetailTab = { id: "ops", label: "운영" };
|
const OPERATIONS_TAB: MatchDetailTab = { id: "ops", label: "운영" };
|
||||||
|
|||||||
@@ -97,15 +97,15 @@ function resolveBackTarget(
|
|||||||
return {
|
return {
|
||||||
to: state.backTo,
|
to: state.backTo,
|
||||||
label:
|
label:
|
||||||
typeof state.backLabel === "string"
|
typeof state.backLabel === "string" && state.backLabel.trim().length > 0
|
||||||
? state.backLabel
|
? state.backLabel.trim()
|
||||||
: "돌아가기",
|
: "돌아가기",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
to: fallbackTo,
|
to: fallbackTo,
|
||||||
label: "경기 결과로 돌아가기",
|
label: "경기 기록으로 돌아가기",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,13 @@ import {
|
|||||||
competitionHistoryGameDetailPath,
|
competitionHistoryGameDetailPath,
|
||||||
createCompetitionSeriesHistory,
|
createCompetitionSeriesHistory,
|
||||||
formatCompetitionHistoryDate,
|
formatCompetitionHistoryDate,
|
||||||
formatCompetitionHistoryDayHeading,
|
|
||||||
formatCompetitionHistoryTime,
|
formatCompetitionHistoryTime,
|
||||||
formatSeriesGameDuration,
|
formatSeriesGameDuration,
|
||||||
getSeriesHistoryRecordLabel,
|
getSeriesHistoryRecordLabel,
|
||||||
getSeriesHistoryResultLabel,
|
getSeriesHistoryResultLabel,
|
||||||
getSeriesHistoryStatusLabel,
|
getSeriesHistoryStatusLabel,
|
||||||
|
getSeriesHistoryTimePresentation,
|
||||||
|
isCompetitionHistoryCalendarDate,
|
||||||
shouldDisplaySeriesHistoryScore,
|
shouldDisplaySeriesHistoryScore,
|
||||||
} from "../src/components/competition/competition-series-history.ts";
|
} from "../src/components/competition/competition-series-history.ts";
|
||||||
import { isSeriesEntryWinner } from "../src/components/competition/series-score-card-model.ts";
|
import { isSeriesEntryWinner } from "../src/components/competition/series-score-card-model.ts";
|
||||||
@@ -140,7 +141,7 @@ test("groups and orders Series by the Asia/Seoul calendar day", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("includes recorded in-progress Series and game-less completed decisions only", () => {
|
test("includes recorded in-progress Series and game-less completed decisions", () => {
|
||||||
const teamA = teamId("team-a");
|
const teamA = teamId("team-a");
|
||||||
const teamB = teamId("team-b");
|
const teamB = teamId("team-b");
|
||||||
const running = inProgressSeries("running-recorded", teamA, teamB, 1, 0);
|
const running = inProgressSeries("running-recorded", teamA, teamB, 1, 0);
|
||||||
@@ -173,9 +174,6 @@ test("includes recorded in-progress Series and game-less completed decisions onl
|
|||||||
|
|
||||||
const history = createCompetitionSeriesHistory({
|
const history = createCompetitionSeriesHistory({
|
||||||
series: [
|
series: [
|
||||||
readySeries("ready", teamA, teamB),
|
|
||||||
waitingSeries("waiting"),
|
|
||||||
inactiveSeries("inactive"),
|
|
||||||
unrecordedRunning,
|
unrecordedRunning,
|
||||||
administrative,
|
administrative,
|
||||||
running,
|
running,
|
||||||
@@ -193,6 +191,231 @@ test("includes recorded in-progress Series and game-less completed decisions onl
|
|||||||
assert.equal(rows[1].occurredAt, administrative.outcome.completedAt);
|
assert.equal(rows[1].occurredAt, administrative.outcome.completedAt);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("includes ready and waiting Series in dated and final unscheduled groups", () => {
|
||||||
|
const teamA = teamId("future-team-a");
|
||||||
|
const teamB = teamId("future-team-b");
|
||||||
|
const scheduledReady = withSchedule(
|
||||||
|
readySeries("scheduled-ready", teamA, teamB),
|
||||||
|
{ date: "2026-07-15", time: "21:30", timeZone: "Asia/Seoul" },
|
||||||
|
);
|
||||||
|
const scheduledWaiting = withSchedule(waitingSeries("scheduled-waiting"), {
|
||||||
|
date: "2026-07-15",
|
||||||
|
time: null,
|
||||||
|
timeZone: "Asia/Seoul",
|
||||||
|
});
|
||||||
|
const unscheduledReady = {
|
||||||
|
...readySeries("unscheduled-ready", teamA, teamB),
|
||||||
|
stage: { type: "upper" as const, roundNumber: 1, displayOrder: 3 },
|
||||||
|
};
|
||||||
|
const unscheduledWaiting = {
|
||||||
|
...waitingSeries("unscheduled-waiting"),
|
||||||
|
stage: { type: "upper" as const, roundNumber: 1, displayOrder: 4 },
|
||||||
|
};
|
||||||
|
|
||||||
|
const history = createCompetitionSeriesHistory({
|
||||||
|
series: [
|
||||||
|
unscheduledWaiting,
|
||||||
|
scheduledWaiting,
|
||||||
|
unscheduledReady,
|
||||||
|
scheduledReady,
|
||||||
|
],
|
||||||
|
games: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
history.map(({ dateKey }) => dateKey),
|
||||||
|
["2026-07-15", "unknown"],
|
||||||
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
history[0].rows.map(({ series }) => series.seriesId),
|
||||||
|
[scheduledReady.seriesId, scheduledWaiting.seriesId],
|
||||||
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
history[1].rows.map(({ series }) => series.seriesId),
|
||||||
|
[unscheduledReady.seriesId, unscheduledWaiting.seriesId],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("keeps missing historical timestamps separate from unscheduled future Series", () => {
|
||||||
|
const teamA = teamId("missing-record-time-a");
|
||||||
|
const teamB = teamId("missing-record-time-b");
|
||||||
|
const historical = completedSeries({
|
||||||
|
id: "missing-record-time",
|
||||||
|
teamA,
|
||||||
|
teamB,
|
||||||
|
scoreA: 0,
|
||||||
|
scoreB: 0,
|
||||||
|
completedAt: "not-an-iso-date",
|
||||||
|
outcome: "administrative",
|
||||||
|
});
|
||||||
|
const future = readySeries("missing-schedule-date", teamA, teamB);
|
||||||
|
|
||||||
|
const history = createCompetitionSeriesHistory({
|
||||||
|
series: [future, historical],
|
||||||
|
games: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
history.map(({ dateKey }) => dateKey),
|
||||||
|
["record-unknown", "unknown"],
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
formatCompetitionHistoryDate(history[0].dateKey),
|
||||||
|
"기록 일시 미상",
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
formatCompetitionHistoryDate(history[1].dateKey),
|
||||||
|
"일정 미정",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("prefers recorded start and decision times over an attached schedule", () => {
|
||||||
|
const teamA = teamId("record-precedence-a");
|
||||||
|
const teamB = teamId("record-precedence-b");
|
||||||
|
const played = withSchedule(
|
||||||
|
completedSeries({
|
||||||
|
id: "recorded-start-precedence",
|
||||||
|
teamA,
|
||||||
|
teamB,
|
||||||
|
scoreA: 1,
|
||||||
|
scoreB: 0,
|
||||||
|
completedAt: "2026-07-12T12:00:00.000Z",
|
||||||
|
}),
|
||||||
|
{ date: "2026-08-01", time: "20:00", timeZone: "Asia/Seoul" },
|
||||||
|
);
|
||||||
|
const recordedGame = game({
|
||||||
|
id: "recorded-start-precedence-game",
|
||||||
|
seriesId: played.seriesId,
|
||||||
|
ordinal: 1,
|
||||||
|
displayNumber: 20,
|
||||||
|
blueTeamId: teamA,
|
||||||
|
redTeamId: teamB,
|
||||||
|
winnerTeamId: teamA,
|
||||||
|
startedAt: "2026-07-12T11:00:00.000Z",
|
||||||
|
});
|
||||||
|
const decided = withSchedule(
|
||||||
|
completedSeries({
|
||||||
|
id: "decision-precedence",
|
||||||
|
teamA,
|
||||||
|
teamB,
|
||||||
|
scoreA: 0,
|
||||||
|
scoreB: 0,
|
||||||
|
completedAt: "2026-07-13T11:00:00.000Z",
|
||||||
|
outcome: "administrative",
|
||||||
|
}),
|
||||||
|
{ date: "2026-08-02", time: "21:00", timeZone: "Asia/Seoul" },
|
||||||
|
);
|
||||||
|
const running = withSchedule(
|
||||||
|
inProgressSeries("running-start-precedence", teamA, teamB, 1, 0),
|
||||||
|
{ date: "2026-08-03", time: "22:00", timeZone: "Asia/Seoul" },
|
||||||
|
);
|
||||||
|
const runningGame = game({
|
||||||
|
id: "running-start-precedence-game",
|
||||||
|
seriesId: running.seriesId,
|
||||||
|
ordinal: 1,
|
||||||
|
displayNumber: 21,
|
||||||
|
blueTeamId: teamA,
|
||||||
|
redTeamId: teamB,
|
||||||
|
winnerTeamId: teamA,
|
||||||
|
startedAt: "2026-07-14T11:00:00.000Z",
|
||||||
|
});
|
||||||
|
|
||||||
|
const rows = createCompetitionSeriesHistory({
|
||||||
|
series: [running, decided, played],
|
||||||
|
games: [runningGame, recordedGame],
|
||||||
|
}).flatMap(({ rows }) => rows);
|
||||||
|
|
||||||
|
assert.equal(rows[0].timestampSource, "game-start");
|
||||||
|
assert.equal(rows[0].occurredAt, recordedGame.startedAt);
|
||||||
|
assert.equal(rows[1].timestampSource, "decision");
|
||||||
|
assert.equal(rows[1].occurredAt, decided.outcome.completedAt);
|
||||||
|
assert.equal(rows[2].timestampSource, "game-start");
|
||||||
|
assert.equal(rows[2].occurredAt, runningGame.startedAt);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("keeps Series with invalid recorded Game starts in the missing-record group", () => {
|
||||||
|
const teamA = teamId("invalid-game-start-a");
|
||||||
|
const teamB = teamId("invalid-game-start-b");
|
||||||
|
const scheduledRunning = withSchedule(
|
||||||
|
inProgressSeries("invalid-running-scheduled", teamA, teamB, 0, 0),
|
||||||
|
{ date: "2026-08-03", time: "22:00", timeZone: "Asia/Seoul" },
|
||||||
|
);
|
||||||
|
const unscheduledRunning = {
|
||||||
|
...inProgressSeries("invalid-running-unscheduled", teamA, teamB, 0, 0),
|
||||||
|
stage: { type: "upper" as const, roundNumber: 1, displayOrder: 2 },
|
||||||
|
};
|
||||||
|
const completed = completedSeries({
|
||||||
|
id: "invalid-completed-game-start",
|
||||||
|
teamA,
|
||||||
|
teamB,
|
||||||
|
scoreA: 1,
|
||||||
|
scoreB: 0,
|
||||||
|
displayOrder: 3,
|
||||||
|
completedAt: "2026-07-15T11:00:00.000Z",
|
||||||
|
});
|
||||||
|
const invalidGames = [scheduledRunning, unscheduledRunning, completed].map(
|
||||||
|
(series, index) =>
|
||||||
|
game({
|
||||||
|
id: `invalid-start-game-${index}`,
|
||||||
|
seriesId: series.seriesId,
|
||||||
|
ordinal: 1,
|
||||||
|
displayNumber: 30 + index,
|
||||||
|
blueTeamId: teamA,
|
||||||
|
redTeamId: teamB,
|
||||||
|
winnerTeamId: teamA,
|
||||||
|
startedAt: "not-an-iso-date",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
invalidGames.push(
|
||||||
|
game({
|
||||||
|
id: "mixed-valid-start-game",
|
||||||
|
seriesId: scheduledRunning.seriesId,
|
||||||
|
ordinal: 2,
|
||||||
|
displayNumber: 33,
|
||||||
|
blueTeamId: teamA,
|
||||||
|
redTeamId: teamB,
|
||||||
|
winnerTeamId: teamA,
|
||||||
|
startedAt: "2026-07-14T11:00:00.000Z",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const rows = createCompetitionSeriesHistory({
|
||||||
|
series: [completed, unscheduledRunning, scheduledRunning],
|
||||||
|
games: invalidGames,
|
||||||
|
}).flatMap(({ rows }) => rows);
|
||||||
|
|
||||||
|
assert.equal(rows.length, 3);
|
||||||
|
for (const row of rows) {
|
||||||
|
assert.equal(row.dateKey, "record-unknown");
|
||||||
|
assert.equal(row.timestampSource, "game-start");
|
||||||
|
assert.equal(row.occurredAt, null);
|
||||||
|
assert.deepEqual(getSeriesHistoryTimePresentation(row), {
|
||||||
|
text: "—",
|
||||||
|
dateTime: null,
|
||||||
|
screenReaderText: "시작 시각 기록 없음",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("hides unscheduled inactive Series but includes a scheduled conditional Series", () => {
|
||||||
|
const unscheduledInactive = inactiveSeries("inactive-unscheduled");
|
||||||
|
const scheduledInactive = withSchedule(
|
||||||
|
inactiveSeries("inactive-scheduled"),
|
||||||
|
{ date: "2026-07-16", time: null, timeZone: "Asia/Seoul" },
|
||||||
|
);
|
||||||
|
|
||||||
|
const rows = createCompetitionSeriesHistory({
|
||||||
|
series: [unscheduledInactive, scheduledInactive],
|
||||||
|
games: [],
|
||||||
|
}).flatMap(({ rows }) => rows);
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
rows.map(({ series }) => series.seriesId),
|
||||||
|
[scheduledInactive.seriesId],
|
||||||
|
);
|
||||||
|
assert.equal(getSeriesHistoryStatusLabel(scheduledInactive), "필요 시");
|
||||||
|
});
|
||||||
|
|
||||||
test("sorts tied timestamps deterministically and ignores orphan Games", () => {
|
test("sorts tied timestamps deterministically and ignores orphan Games", () => {
|
||||||
const teamA = teamId("team-a");
|
const teamA = teamId("team-a");
|
||||||
const teamB = teamId("team-b");
|
const teamB = teamId("team-b");
|
||||||
@@ -241,6 +464,13 @@ test("separates lifecycle status from played and adjudicated result labels", ()
|
|||||||
const teamA = teamId("team-a");
|
const teamA = teamId("team-a");
|
||||||
const teamB = teamId("team-b");
|
const teamB = teamId("team-b");
|
||||||
const running = inProgressSeries("running", teamA, teamB, 1, 0);
|
const running = inProgressSeries("running", teamA, teamB, 1, 0);
|
||||||
|
const ready = readySeries("ready-status", teamA, teamB);
|
||||||
|
const waiting = waitingSeries("waiting-status");
|
||||||
|
const conditional = withSchedule(inactiveSeries("conditional-status"), {
|
||||||
|
date: "2026-07-16",
|
||||||
|
time: null,
|
||||||
|
timeZone: "Asia/Seoul",
|
||||||
|
});
|
||||||
const played = completedSeries({
|
const played = completedSeries({
|
||||||
id: "played",
|
id: "played",
|
||||||
teamA,
|
teamA,
|
||||||
@@ -292,6 +522,9 @@ test("separates lifecycle status from played and adjudicated result labels", ()
|
|||||||
outcome: "administrative",
|
outcome: "administrative",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
assert.equal(getSeriesHistoryStatusLabel(ready), "예정");
|
||||||
|
assert.equal(getSeriesHistoryStatusLabel(waiting), "예정");
|
||||||
|
assert.equal(getSeriesHistoryStatusLabel(conditional), "필요 시");
|
||||||
assert.equal(getSeriesHistoryStatusLabel(running), "진행 중");
|
assert.equal(getSeriesHistoryStatusLabel(running), "진행 중");
|
||||||
for (const completed of [
|
for (const completed of [
|
||||||
played,
|
played,
|
||||||
@@ -304,6 +537,9 @@ test("separates lifecycle status from played and adjudicated result labels", ()
|
|||||||
assert.equal(getSeriesHistoryStatusLabel(completed), "최종");
|
assert.equal(getSeriesHistoryStatusLabel(completed), "최종");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert.equal(getSeriesHistoryResultLabel(ready), "VS");
|
||||||
|
assert.equal(getSeriesHistoryResultLabel(waiting), "VS");
|
||||||
|
assert.equal(getSeriesHistoryResultLabel(conditional), "VS");
|
||||||
assert.equal(getSeriesHistoryResultLabel(running), null);
|
assert.equal(getSeriesHistoryResultLabel(running), null);
|
||||||
assert.equal(getSeriesHistoryResultLabel(played), null);
|
assert.equal(getSeriesHistoryResultLabel(played), null);
|
||||||
assert.equal(getSeriesHistoryResultLabel(playedDraw), "무승부");
|
assert.equal(getSeriesHistoryResultLabel(playedDraw), "무승부");
|
||||||
@@ -341,6 +577,43 @@ test("describes recorded Games, decisions, and legacy missing records", () => {
|
|||||||
assert.equal(getSeriesHistoryRecordLabel(played, 0, false), "게임 기록 미등록");
|
assert.equal(getSeriesHistoryRecordLabel(played, 0, false), "게임 기록 미등록");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("presents known and unknown future times without an invalid time value", () => {
|
||||||
|
const teamA = teamId("time-team-a");
|
||||||
|
const teamB = teamId("time-team-b");
|
||||||
|
const knownTime = withSchedule(
|
||||||
|
readySeries("known-scheduled-time", teamA, teamB),
|
||||||
|
{ date: "2026-07-15", time: "21:30", timeZone: "Asia/Seoul" },
|
||||||
|
);
|
||||||
|
const unknownTime = withSchedule(
|
||||||
|
readySeries("unknown-scheduled-time", teamA, teamB),
|
||||||
|
{ date: "2026-07-15", time: null, timeZone: "Asia/Seoul" },
|
||||||
|
);
|
||||||
|
const rows = createCompetitionSeriesHistory({
|
||||||
|
series: [unknownTime, knownTime],
|
||||||
|
games: [],
|
||||||
|
}).flatMap(({ rows }) => rows);
|
||||||
|
const knownRow = rows.find(
|
||||||
|
({ series }) => series.seriesId === knownTime.seriesId,
|
||||||
|
);
|
||||||
|
const unknownRow = rows.find(
|
||||||
|
({ series }) => series.seriesId === unknownTime.seriesId,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.ok(knownRow);
|
||||||
|
assert.ok(unknownRow);
|
||||||
|
|
||||||
|
assert.deepEqual(getSeriesHistoryTimePresentation(knownRow), {
|
||||||
|
text: "21:30",
|
||||||
|
dateTime: "2026-07-15T21:30:00+09:00",
|
||||||
|
screenReaderText: null,
|
||||||
|
});
|
||||||
|
assert.deepEqual(getSeriesHistoryTimePresentation(unknownRow), {
|
||||||
|
text: "--:--",
|
||||||
|
dateTime: null,
|
||||||
|
screenReaderText: "시작 시간 미정",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test("shows a numeric score only for played records", () => {
|
test("shows a numeric score only for played records", () => {
|
||||||
const teamA = teamId("team-a");
|
const teamA = teamId("team-a");
|
||||||
const teamB = teamId("team-b");
|
const teamB = teamId("team-b");
|
||||||
@@ -423,25 +696,20 @@ test("formats recorded Game duration and omits unknown legacy zero values", () =
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("formats history dates and times explicitly in Asia/Seoul", () => {
|
test("formats history dates and times explicitly in Asia/Seoul", () => {
|
||||||
assert.equal(formatCompetitionHistoryDate("2026-07-05"), "7월 5일 (일)");
|
assert.equal(formatCompetitionHistoryDate("2026-07-05"), "7월 05일 (일)");
|
||||||
assert.equal(formatCompetitionHistoryDate("2026-07-13"), "7월 13일 (월)");
|
assert.equal(formatCompetitionHistoryDate("2026-07-13"), "7월 13일 (월)");
|
||||||
assert.equal(
|
|
||||||
formatCompetitionHistoryDayHeading("2026-07-05", 1),
|
|
||||||
"7월 5일 (일) · 1경기",
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
formatCompetitionHistoryDayHeading("2026-07-13", 2),
|
|
||||||
"7월 13일 (월) · 2경기",
|
|
||||||
);
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
formatCompetitionHistoryTime("2026-07-12T15:05:00.000Z"),
|
formatCompetitionHistoryTime("2026-07-12T15:05:00.000Z"),
|
||||||
"00:05",
|
"00:05",
|
||||||
);
|
);
|
||||||
assert.equal(formatCompetitionHistoryDate("unknown"), "일시 정보 없음");
|
assert.equal(formatCompetitionHistoryDate("unknown"), "일정 미정");
|
||||||
assert.equal(
|
assert.equal(
|
||||||
formatCompetitionHistoryDayHeading("unknown", 1),
|
formatCompetitionHistoryDate("record-unknown"),
|
||||||
"일시 정보 없음 · 1경기",
|
"기록 일시 미상",
|
||||||
);
|
);
|
||||||
|
assert.equal(isCompetitionHistoryCalendarDate("2026-07-05"), true);
|
||||||
|
assert.equal(isCompetitionHistoryCalendarDate("record-unknown"), false);
|
||||||
|
assert.equal(isCompetitionHistoryCalendarDate("unknown"), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
function playedSeriesWithGame({
|
function playedSeriesWithGame({
|
||||||
@@ -647,3 +915,14 @@ function seriesId(value: string): SeriesId {
|
|||||||
function teamId(value: string): TeamId {
|
function teamId(value: string): TeamId {
|
||||||
return value as TeamId;
|
return value as TeamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function withSchedule<T extends SeriesProjection>(
|
||||||
|
series: T,
|
||||||
|
schedule: {
|
||||||
|
date: string;
|
||||||
|
time: string | null;
|
||||||
|
timeZone: "Asia/Seoul";
|
||||||
|
},
|
||||||
|
): T & { schedule: typeof schedule } {
|
||||||
|
return { ...series, schedule };
|
||||||
|
}
|
||||||
@@ -27,7 +27,7 @@ test("uses tabs only in progress or when finished and exposes operations only to
|
|||||||
);
|
);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
publicTabs.map((tab) => tab.label),
|
publicTabs.map((tab) => tab.label),
|
||||||
["대진표·순위", "경기 기록", "팀", "일정·안내"],
|
["대진표·순위", "경기 일정·결과", "팀", "안내"],
|
||||||
);
|
);
|
||||||
|
|
||||||
const managerTabs = createMatchDetailTabs({
|
const managerTabs = createMatchDetailTabs({
|
||||||
|
|||||||
@@ -68,12 +68,19 @@ export interface GrandFinalResetActivationRule {
|
|||||||
|
|
||||||
export type SeriesActivationRule = GrandFinalResetActivationRule;
|
export type SeriesActivationRule = GrandFinalResetActivationRule;
|
||||||
|
|
||||||
|
export interface SeriesSchedule {
|
||||||
|
date: string;
|
||||||
|
time: string | null;
|
||||||
|
timeZone: "Asia/Seoul";
|
||||||
|
}
|
||||||
|
|
||||||
export interface SeriesDefinition {
|
export interface SeriesDefinition {
|
||||||
id: SeriesId;
|
id: SeriesId;
|
||||||
code?: string;
|
code?: string;
|
||||||
stage: SeriesStage;
|
stage: SeriesStage;
|
||||||
slots: [SeriesSlotDefinition, SeriesSlotDefinition];
|
slots: [SeriesSlotDefinition, SeriesSlotDefinition];
|
||||||
rule: SeriesRule;
|
rule: SeriesRule;
|
||||||
|
schedule?: SeriesSchedule;
|
||||||
activation?: SeriesActivationRule;
|
activation?: SeriesActivationRule;
|
||||||
gameSlots: GameSlotDefinition[];
|
gameSlots: GameSlotDefinition[];
|
||||||
}
|
}
|
||||||
@@ -106,6 +113,7 @@ interface SeriesProjectionBase {
|
|||||||
code?: string;
|
code?: string;
|
||||||
stage: SeriesStage;
|
stage: SeriesStage;
|
||||||
rule: SeriesRule;
|
rule: SeriesRule;
|
||||||
|
schedule?: SeriesSchedule;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PlayedSeriesOutcome {
|
export interface PlayedSeriesOutcome {
|
||||||
|
|||||||
Reference in new issue
Block a user