feat(web): improve competition result history
Prioritize match outcomes, distinguish adjudicated results, and preserve detail context when navigating back.
This commit is contained in:
1 parent
dc77b37494
commit
43c25c05cd
5 files changed
+335
-143
No files matched your search
@@ -93,7 +93,7 @@ function GameHistoryRowContent({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<span className="font-bold text-content-muted">
|
<span className="font-bold text-content-muted">
|
||||||
Game {game.ordinal}
|
{game.ordinal}게임
|
||||||
</span>
|
</span>
|
||||||
<time
|
<time
|
||||||
dateTime={game.startedAt}
|
dateTime={game.startedAt}
|
||||||
|
|||||||
@@ -6,11 +6,14 @@ import type {
|
|||||||
TeamId,
|
TeamId,
|
||||||
} from "@lolympus/contracts";
|
} from "@lolympus/contracts";
|
||||||
import { ChevronDown } from "lucide-react";
|
import { ChevronDown } from "lucide-react";
|
||||||
|
import { useState } from "react";
|
||||||
import { useLocation } from "react-router";
|
import { useLocation } from "react-router";
|
||||||
import {
|
import {
|
||||||
createCompetitionSeriesHistory,
|
createCompetitionSeriesHistory,
|
||||||
formatCompetitionHistoryDate,
|
formatCompetitionHistoryDayHeading,
|
||||||
formatCompetitionHistoryTime,
|
formatCompetitionHistoryTime,
|
||||||
|
getSeriesHistoryRecordLabel,
|
||||||
|
getSeriesHistoryResultLabel,
|
||||||
getSeriesHistoryStatusLabel,
|
getSeriesHistoryStatusLabel,
|
||||||
shouldDisplaySeriesHistoryScore,
|
shouldDisplaySeriesHistoryScore,
|
||||||
type CompetitionSeriesHistoryRow,
|
type CompetitionSeriesHistoryRow,
|
||||||
@@ -31,56 +34,102 @@ export function CompetitionSeriesHistory({
|
|||||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||||
}) {
|
}) {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
|
const historyPath = `${location.pathname}${location.search}`;
|
||||||
const history = createCompetitionSeriesHistory(projection);
|
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,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
className="competition-series-history border border-base-content/10 bg-base-100"
|
className="competition-series-history border border-base-content/10 bg-base-100"
|
||||||
aria-labelledby="competition-series-history-heading"
|
aria-labelledby="competition-series-history-heading"
|
||||||
>
|
>
|
||||||
<header className="border-b border-base-content/10 px-4 py-3">
|
<header className="flex flex-wrap items-start justify-between gap-4 border-b border-base-content/10 px-4 py-3">
|
||||||
<h3
|
<div>
|
||||||
id="competition-series-history-heading"
|
<h3
|
||||||
className="text-sm font-bold"
|
id="competition-series-history-heading"
|
||||||
>
|
className="text-sm font-bold"
|
||||||
경기 결과 기록
|
>
|
||||||
</h3>
|
경기 결과 기록
|
||||||
<p className="mt-0.5 text-xs text-content-muted">
|
</h3>
|
||||||
진행 중인 시리즈와 종료 결과를 실제 경기 기록 순서로 보여줍니다.
|
<p className="mt-0.5 text-xs text-content-muted">
|
||||||
</p>
|
진행 중인 시리즈와 최종 결과를 실제 경기 기록 순서로 보여줍니다.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{resultCount > 1 && (
|
||||||
|
<a
|
||||||
|
href="#competition-series-history-latest"
|
||||||
|
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"
|
||||||
|
>
|
||||||
|
최신 결과로
|
||||||
|
<ChevronDown
|
||||||
|
className="h-4 w-4 text-primary"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
</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) => {
|
{history.map((day, dayIndex) => {
|
||||||
const headingId = `competition-history-${day.dateKey}`;
|
const headingId = historyDayHeadingId(day.dateKey);
|
||||||
|
const dayHeading = formatCompetitionHistoryDayHeading(
|
||||||
|
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="border-b border-base-content/10 bg-base-200/60 px-4 py-3 text-sm font-bold"
|
className="scroll-mt-24 border-b border-base-content/10 bg-base-200/60 px-4 py-3 text-sm font-bold"
|
||||||
>
|
>
|
||||||
{day.dateKey === "unknown" ? (
|
{day.dateKey === "unknown" ? (
|
||||||
formatCompetitionHistoryDate(day.dateKey)
|
dayHeading
|
||||||
) : (
|
) : (
|
||||||
<time dateTime={day.dateKey}>
|
<time dateTime={day.dateKey}>
|
||||||
{formatCompetitionHistoryDate(day.dateKey)}
|
{dayHeading}
|
||||||
</time>
|
</time>
|
||||||
)}
|
)}
|
||||||
</h4>
|
</h4>
|
||||||
<ol className="divide-y divide-base-content/10">
|
<ol className="divide-y divide-base-content/10">
|
||||||
{day.rows.map((row) => (
|
{day.rows.map((row, rowIndex) => {
|
||||||
<li key={row.series.seriesId}>
|
const isLatestResult =
|
||||||
<SeriesHistoryRow
|
dayIndex === history.length - 1 &&
|
||||||
row={row}
|
rowIndex === day.rows.length - 1;
|
||||||
teamById={teamById}
|
return (
|
||||||
communityId={communityId}
|
<li
|
||||||
matchId={matchId}
|
key={row.series.seriesId}
|
||||||
historyBackTo={historyBackTo}
|
id={
|
||||||
/>
|
isLatestResult
|
||||||
</li>
|
? "competition-series-history-latest"
|
||||||
))}
|
: undefined
|
||||||
|
}
|
||||||
|
className={isLatestResult ? "scroll-mt-24" : undefined}
|
||||||
|
>
|
||||||
|
<SeriesHistoryRow
|
||||||
|
row={row}
|
||||||
|
teamById={teamById}
|
||||||
|
communityId={communityId}
|
||||||
|
matchId={matchId}
|
||||||
|
historyPath={historyPath}
|
||||||
|
currentHash={location.hash}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</ol>
|
</ol>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
@@ -95,31 +144,50 @@ function SeriesHistoryRow({
|
|||||||
teamById,
|
teamById,
|
||||||
communityId,
|
communityId,
|
||||||
matchId,
|
matchId,
|
||||||
historyBackTo,
|
historyPath,
|
||||||
|
currentHash,
|
||||||
}: {
|
}: {
|
||||||
row: CompetitionSeriesHistoryRow;
|
row: CompetitionSeriesHistoryRow;
|
||||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||||
communityId: CommunityId;
|
communityId: CommunityId;
|
||||||
matchId: MatchId;
|
matchId: MatchId;
|
||||||
historyBackTo: string;
|
historyPath: string;
|
||||||
|
currentHash: string;
|
||||||
}) {
|
}) {
|
||||||
|
const detailsId = seriesHistoryDetailsId(row.series.seriesId);
|
||||||
|
const seriesHash = `#${detailsId}`;
|
||||||
|
const [expanded, setExpanded] = useState(currentHash === seriesHash);
|
||||||
|
|
||||||
if (row.games.length === 0) {
|
if (row.games.length === 0) {
|
||||||
return (
|
return (
|
||||||
<SeriesSummary row={row} teamById={teamById} hasGameDetails={false} />
|
<SeriesSummary
|
||||||
|
row={row}
|
||||||
|
teamById={teamById}
|
||||||
|
hasGameDetails={false}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<details className="group">
|
<details
|
||||||
<summary className="list-none cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary [&::-webkit-details-marker]:hidden">
|
id={detailsId}
|
||||||
<SeriesSummary row={row} teamById={teamById} hasGameDetails />
|
className="group scroll-mt-24"
|
||||||
|
open={expanded}
|
||||||
|
onToggle={(event) => setExpanded(event.currentTarget.open)}
|
||||||
|
>
|
||||||
|
<summary className="list-none cursor-pointer transition-colors hover:bg-base-content/[0.04] active:bg-base-content/[0.06] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary group-open:bg-base-content/[0.025] [&::-webkit-details-marker]:hidden">
|
||||||
|
<SeriesSummary
|
||||||
|
row={row}
|
||||||
|
teamById={teamById}
|
||||||
|
hasGameDetails
|
||||||
|
/>
|
||||||
</summary>
|
</summary>
|
||||||
<CompetitionGameHistory
|
<CompetitionGameHistory
|
||||||
games={row.games}
|
games={row.games}
|
||||||
teamById={teamById}
|
teamById={teamById}
|
||||||
communityId={communityId}
|
communityId={communityId}
|
||||||
matchId={matchId}
|
matchId={matchId}
|
||||||
historyBackTo={historyBackTo}
|
historyBackTo={`${historyPath}${seriesHash}`}
|
||||||
/>
|
/>
|
||||||
</details>
|
</details>
|
||||||
);
|
);
|
||||||
@@ -136,47 +204,55 @@ function SeriesSummary({
|
|||||||
}) {
|
}) {
|
||||||
const { series } = row;
|
const { series } = row;
|
||||||
const statusLabel = getSeriesHistoryStatusLabel(series);
|
const statusLabel = getSeriesHistoryStatusLabel(series);
|
||||||
const timeLabel =
|
const timeLabel = formatCompetitionHistoryTime(row.occurredAt);
|
||||||
row.timestampSource === "game-start"
|
const timeKind = row.timestampSource === "game-start" ? "시작" : "결정";
|
||||||
? formatCompetitionHistoryTime(row.occurredAt)
|
|
||||||
: null;
|
|
||||||
const roundLabel = bracketRoundLabel(
|
const roundLabel = bracketRoundLabel(
|
||||||
series.stage.type,
|
series.stage.type,
|
||||||
series.stage.roundNumber,
|
series.stage.roundNumber,
|
||||||
);
|
);
|
||||||
|
const closedRecordLabel = getSeriesHistoryRecordLabel(
|
||||||
|
series,
|
||||||
|
row.games.length,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className="block px-4 py-3 lg:grid lg:min-h-18 lg:grid-cols-[4.5rem_5rem_9rem_minmax(0,1fr)_6.5rem] lg:items-center lg:gap-4">
|
<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="flex min-w-0 items-center gap-2 lg:contents">
|
<span className="block">
|
||||||
<HistoryTime
|
<SeriesMatchup row={row} teamById={teamById} />
|
||||||
occurredAt={row.occurredAt}
|
</span>
|
||||||
timeLabel={timeLabel}
|
|
||||||
/>
|
<span className="mt-3 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 lg:contents">
|
||||||
<StatusLabel
|
|
||||||
label={statusLabel}
|
|
||||||
inProgress={series.status === "in-progress"}
|
|
||||||
/>
|
|
||||||
<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>
|
<span className="flex min-w-0 flex-wrap items-center gap-2">
|
||||||
|
<HistoryTime
|
||||||
<span className="mt-3 block lg:mt-0">
|
occurredAt={row.occurredAt}
|
||||||
<SeriesMatchup row={row} teamById={teamById} />
|
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">
|
<span className="mt-2 flex min-h-6 items-center justify-end text-xs font-bold text-content-muted lg:mt-0">
|
||||||
{hasGameDetails ? (
|
{hasGameDetails ? (
|
||||||
<>
|
<>
|
||||||
<span className="group-open:hidden">{row.games.length}게임 보기</span>
|
<span className="group-open:hidden">{closedRecordLabel}</span>
|
||||||
<span className="hidden group-open:inline">게임 접기</span>
|
<span className="hidden group-open:inline">
|
||||||
|
{getSeriesHistoryRecordLabel(series, row.games.length, true)}
|
||||||
|
</span>
|
||||||
<ChevronDown
|
<ChevronDown
|
||||||
className="ml-1 h-4 w-4 text-primary transition-transform group-open:rotate-180 motion-reduce:transition-none"
|
className="ml-1 h-4 w-4 text-primary transition-transform group-open:rotate-180 motion-reduce:transition-none"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<span>개별 기록 없음</span>
|
<span>{closedRecordLabel}</span>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
@@ -185,22 +261,24 @@ function SeriesSummary({
|
|||||||
|
|
||||||
function HistoryTime({
|
function HistoryTime({
|
||||||
occurredAt,
|
occurredAt,
|
||||||
|
timeKind,
|
||||||
timeLabel,
|
timeLabel,
|
||||||
}: {
|
}: {
|
||||||
occurredAt: string;
|
occurredAt: string;
|
||||||
|
timeKind: "시작" | "결정";
|
||||||
timeLabel: string | null;
|
timeLabel: string | null;
|
||||||
}) {
|
}) {
|
||||||
return timeLabel ? (
|
return timeLabel ? (
|
||||||
<time
|
<time
|
||||||
dateTime={occurredAt}
|
dateTime={occurredAt}
|
||||||
className="shrink-0 font-mono text-sm font-bold tabular-nums"
|
className="shrink-0 text-xs font-bold tabular-nums text-content-muted"
|
||||||
>
|
>
|
||||||
{timeLabel}
|
{timeKind} <span className="font-mono">{timeLabel}</span>
|
||||||
</time>
|
</time>
|
||||||
) : (
|
) : (
|
||||||
<span className="shrink-0 text-sm text-content-muted">
|
<span className="shrink-0 text-xs font-bold text-content-muted">
|
||||||
<span aria-hidden="true">—</span>
|
<span aria-hidden="true">{timeKind} —</span>
|
||||||
<span className="sr-only">시작 시간 기록 없음</span>
|
<span className="sr-only">{timeKind} 시각 기록 없음</span>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -238,27 +316,36 @@ function SeriesMatchup({
|
|||||||
const teamAWon = isSeriesEntryWinner(row.series, entryA.teamId);
|
const teamAWon = isSeriesEntryWinner(row.series, entryA.teamId);
|
||||||
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 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
|
||||||
: null;
|
: null;
|
||||||
const winnerAnnouncement = officialWinnerTeamId
|
const matchupAnnouncement = showScore
|
||||||
? `, ${teamName(officialWinnerTeamId, teamById)} 승`
|
? `${teamAName} ${entryA.gameWins} 대 ${entryB.gameWins} ${teamBName}`
|
||||||
: "";
|
: `${teamAName} 대 ${teamBName}`;
|
||||||
const accessibleResult = showScore
|
const accessibleResult = [
|
||||||
? `${teamAName} ${entryA.gameWins} 대 ${entryB.gameWins} ${teamBName}${winnerAnnouncement}`
|
matchupAnnouncement,
|
||||||
: `${teamAName} 대 ${teamBName}, ${getSeriesHistoryStatusLabel(row.series)}${winnerAnnouncement}`;
|
resultLabel,
|
||||||
|
officialWinnerTeamId
|
||||||
|
? `${teamName(officialWinnerTeamId, teamById)} 승`
|
||||||
|
: null,
|
||||||
|
statusLabel,
|
||||||
|
]
|
||||||
|
.filter((part): part is string => Boolean(part))
|
||||||
|
.join(", ");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span
|
<span
|
||||||
className="grid grid-cols-[minmax(0,1fr)_3.5rem_minmax(0,1fr)] items-center gap-2"
|
className="grid grid-cols-[minmax(0,1fr)_5rem_minmax(0,1fr)] items-center gap-2"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
>
|
>
|
||||||
<TeamName name={teamAName} winner={teamAWon} align="right" />
|
<TeamName name={teamAName} winner={teamAWon} align="right" />
|
||||||
<span className="flex items-center justify-center gap-1 font-mono text-base font-bold tabular-nums">
|
<span className="flex min-h-10 flex-col items-center justify-center">
|
||||||
{showScore ? (
|
{showScore ? (
|
||||||
<>
|
<span className="flex items-center justify-center gap-1 font-mono text-base font-bold tabular-nums">
|
||||||
<span
|
<span
|
||||||
className={
|
className={
|
||||||
teamAWon ? "text-base-content" : "text-content-muted"
|
teamAWon ? "text-base-content" : "text-content-muted"
|
||||||
@@ -274,9 +361,18 @@ function SeriesMatchup({
|
|||||||
>
|
>
|
||||||
{entryB.gameWins}
|
{entryB.gameWins}
|
||||||
</span>
|
</span>
|
||||||
</>
|
</span>
|
||||||
) : (
|
) : null}
|
||||||
<span className="text-content-disabled">—</span>
|
{resultLabel && (
|
||||||
|
<span
|
||||||
|
className={
|
||||||
|
showScore
|
||||||
|
? "mt-0.5 text-[11px] font-bold leading-4 text-content-muted"
|
||||||
|
: "text-sm font-bold leading-5 text-base-content"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{resultLabel}
|
||||||
|
</span>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
<TeamName name={teamBName} winner={teamBWon} align="left" />
|
<TeamName name={teamBName} winner={teamBWon} align="left" />
|
||||||
@@ -316,3 +412,11 @@ function teamName(
|
|||||||
): string {
|
): string {
|
||||||
return teamById.get(teamId)?.name ?? "알 수 없는 팀";
|
return teamById.get(teamId)?.name ?? "알 수 없는 팀";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function historyDayHeadingId(dateKey: string): string {
|
||||||
|
return `competition-series-history-day-${dateKey}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function seriesHistoryDetailsId(seriesId: string): string {
|
||||||
|
return `competition-series-history-series-${seriesId}`;
|
||||||
|
}
|
||||||
@@ -79,7 +79,7 @@ export function MatchDetailTabBar({
|
|||||||
onKeyDown={(event) => handleKeyDown(event, tab.id)}
|
onKeyDown={(event) => handleKeyDown(event, tab.id)}
|
||||||
className={`min-h-11 flex-none whitespace-nowrap border-b-2 px-4 text-xs font-bold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary ${
|
className={`min-h-11 flex-none whitespace-nowrap border-b-2 px-4 text-xs font-bold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary ${
|
||||||
selected
|
selected
|
||||||
? "border-primary bg-primary/5 text-primary"
|
? "border-primary bg-primary/5 text-base-content"
|
||||||
: "border-transparent text-base-content/45 hover:bg-base-content/[0.03] hover:text-base-content"
|
: "border-transparent text-base-content/45 hover:bg-base-content/[0.03] hover:text-base-content"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -103,20 +103,41 @@ export function getSeriesHistoryStatusLabel(
|
|||||||
series: CompetitionSeriesHistorySeries,
|
series: CompetitionSeriesHistorySeries,
|
||||||
): string {
|
): string {
|
||||||
if (series.status === "in-progress") return "진행 중";
|
if (series.status === "in-progress") return "진행 중";
|
||||||
|
return "최종";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSeriesHistoryResultLabel(
|
||||||
|
series: CompetitionSeriesHistorySeries,
|
||||||
|
): string | null {
|
||||||
|
if (series.status === "in-progress") return null;
|
||||||
switch (series.outcome.type) {
|
switch (series.outcome.type) {
|
||||||
case "played":
|
case "played":
|
||||||
return "종료";
|
return null;
|
||||||
case "draw":
|
case "draw":
|
||||||
return "무승부";
|
return series.outcome.basis.type === "played"
|
||||||
|
? "무승부"
|
||||||
|
: "판정 무승부";
|
||||||
case "walkover":
|
case "walkover":
|
||||||
return "부전승";
|
return "부전승";
|
||||||
case "forfeit":
|
case "forfeit":
|
||||||
return "기권승";
|
return "기권승";
|
||||||
case "administrative":
|
case "administrative":
|
||||||
return "판정";
|
return "판정승";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getSeriesHistoryRecordLabel(
|
||||||
|
series: CompetitionSeriesHistorySeries,
|
||||||
|
gameCount: number,
|
||||||
|
expanded: boolean,
|
||||||
|
): string {
|
||||||
|
if (gameCount > 0) {
|
||||||
|
return expanded ? "게임 상세 접기" : `게임 상세 (${gameCount})`;
|
||||||
|
}
|
||||||
|
if (isGameLessDecision(series)) return "경기 없이 결정";
|
||||||
|
return "게임 기록 미등록";
|
||||||
|
}
|
||||||
|
|
||||||
export function shouldDisplaySeriesHistoryScore(
|
export function shouldDisplaySeriesHistoryScore(
|
||||||
series: CompetitionSeriesHistorySeries,
|
series: CompetitionSeriesHistorySeries,
|
||||||
): boolean {
|
): boolean {
|
||||||
@@ -155,7 +176,14 @@ export function formatCompetitionHistoryDate(dateKey: string): string {
|
|||||||
) {
|
) {
|
||||||
return "일시 정보 없음";
|
return "일시 정보 없음";
|
||||||
}
|
}
|
||||||
return `${padNumber(month)}월 ${padNumber(day)}일 (${KOREAN_WEEKDAYS[date.getUTCDay()]})`;
|
return `${month}월 ${day}일 (${KOREAN_WEEKDAYS[date.getUTCDay()]})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatCompetitionHistoryDayHeading(
|
||||||
|
dateKey: string,
|
||||||
|
gameCount: number,
|
||||||
|
): string {
|
||||||
|
return `${formatCompetitionHistoryDate(dateKey)} · ${gameCount}경기`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatCompetitionHistoryTime(
|
export function formatCompetitionHistoryTime(
|
||||||
@@ -233,6 +261,16 @@ function timestampValue(value: IsoDateTime): number {
|
|||||||
return Number.isNaN(timestamp) ? Number.POSITIVE_INFINITY : timestamp;
|
return Number.isNaN(timestamp) ? Number.POSITIVE_INFINITY : timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isGameLessDecision(
|
||||||
|
series: CompetitionSeriesHistorySeries,
|
||||||
|
): boolean {
|
||||||
|
if (series.status === "in-progress") return false;
|
||||||
|
if (series.outcome.type === "draw") {
|
||||||
|
return series.outcome.basis.type !== "played";
|
||||||
|
}
|
||||||
|
return series.outcome.type !== "played";
|
||||||
|
}
|
||||||
|
|
||||||
function padNumber(value: number): string {
|
function padNumber(value: number): string {
|
||||||
return value.toString().padStart(2, "0");
|
return value.toString().padStart(2, "0");
|
||||||
}
|
}
|
||||||
@@ -12,8 +12,11 @@ import {
|
|||||||
competitionHistoryGameDetailPath,
|
competitionHistoryGameDetailPath,
|
||||||
createCompetitionSeriesHistory,
|
createCompetitionSeriesHistory,
|
||||||
formatCompetitionHistoryDate,
|
formatCompetitionHistoryDate,
|
||||||
|
formatCompetitionHistoryDayHeading,
|
||||||
formatCompetitionHistoryTime,
|
formatCompetitionHistoryTime,
|
||||||
formatSeriesGameDuration,
|
formatSeriesGameDuration,
|
||||||
|
getSeriesHistoryRecordLabel,
|
||||||
|
getSeriesHistoryResultLabel,
|
||||||
getSeriesHistoryStatusLabel,
|
getSeriesHistoryStatusLabel,
|
||||||
shouldDisplaySeriesHistoryScore,
|
shouldDisplaySeriesHistoryScore,
|
||||||
} from "../src/components/competition/competition-series-history.ts";
|
} from "../src/components/competition/competition-series-history.ts";
|
||||||
@@ -234,74 +237,108 @@ test("sorts tied timestamps deterministically and ignores orphan Games", () => {
|
|||||||
assert.equal(rows.every(({ games }) => games.length === 0), true);
|
assert.equal(rows.every(({ games }) => games.length === 0), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("returns explicit status labels for played and adjudicated outcomes", () => {
|
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 played = completedSeries({
|
||||||
|
id: "played",
|
||||||
|
teamA,
|
||||||
|
teamB,
|
||||||
|
scoreA: 2,
|
||||||
|
scoreB: 1,
|
||||||
|
});
|
||||||
|
const playedDraw = completedSeries({
|
||||||
|
id: "played-draw",
|
||||||
|
teamA,
|
||||||
|
teamB,
|
||||||
|
scoreA: 1,
|
||||||
|
scoreB: 1,
|
||||||
|
outcome: "draw",
|
||||||
|
});
|
||||||
|
const administrativeDraw = {
|
||||||
|
...playedDraw,
|
||||||
|
seriesId: seriesId("administrative-draw-label"),
|
||||||
|
outcome: {
|
||||||
|
...playedDraw.outcome,
|
||||||
|
basis: {
|
||||||
|
type: "administrative" as const,
|
||||||
|
decisionFactId: "draw-label-fact" as never,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const walkover = completedSeries({
|
||||||
|
id: "walkover",
|
||||||
|
teamA,
|
||||||
|
teamB,
|
||||||
|
scoreA: 0,
|
||||||
|
scoreB: 0,
|
||||||
|
outcome: "walkover",
|
||||||
|
});
|
||||||
|
const forfeit = completedSeries({
|
||||||
|
id: "forfeit",
|
||||||
|
teamA,
|
||||||
|
teamB,
|
||||||
|
scoreA: 1,
|
||||||
|
scoreB: 1,
|
||||||
|
outcome: "forfeit",
|
||||||
|
});
|
||||||
|
const administrative = completedSeries({
|
||||||
|
id: "administrative",
|
||||||
|
teamA,
|
||||||
|
teamB,
|
||||||
|
scoreA: 0,
|
||||||
|
scoreB: 0,
|
||||||
|
outcome: "administrative",
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(getSeriesHistoryStatusLabel(running), "진행 중");
|
||||||
|
for (const completed of [
|
||||||
|
played,
|
||||||
|
playedDraw,
|
||||||
|
administrativeDraw,
|
||||||
|
walkover,
|
||||||
|
forfeit,
|
||||||
|
administrative,
|
||||||
|
]) {
|
||||||
|
assert.equal(getSeriesHistoryStatusLabel(completed), "최종");
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.equal(getSeriesHistoryResultLabel(running), null);
|
||||||
|
assert.equal(getSeriesHistoryResultLabel(played), null);
|
||||||
|
assert.equal(getSeriesHistoryResultLabel(playedDraw), "무승부");
|
||||||
assert.equal(
|
assert.equal(
|
||||||
getSeriesHistoryStatusLabel(
|
getSeriesHistoryResultLabel(administrativeDraw),
|
||||||
inProgressSeries("running", teamA, teamB, 1, 0),
|
"판정 무승부",
|
||||||
),
|
|
||||||
"진행 중",
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
getSeriesHistoryStatusLabel(
|
|
||||||
completedSeries({ id: "played", teamA, teamB, scoreA: 2, scoreB: 1 }),
|
|
||||||
),
|
|
||||||
"종료",
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
getSeriesHistoryStatusLabel(
|
|
||||||
completedSeries({
|
|
||||||
id: "draw",
|
|
||||||
teamA,
|
|
||||||
teamB,
|
|
||||||
scoreA: 1,
|
|
||||||
scoreB: 1,
|
|
||||||
outcome: "draw",
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
"무승부",
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
getSeriesHistoryStatusLabel(
|
|
||||||
completedSeries({
|
|
||||||
id: "walkover",
|
|
||||||
teamA,
|
|
||||||
teamB,
|
|
||||||
scoreA: 0,
|
|
||||||
scoreB: 0,
|
|
||||||
outcome: "walkover",
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
"부전승",
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
getSeriesHistoryStatusLabel(
|
|
||||||
completedSeries({
|
|
||||||
id: "forfeit",
|
|
||||||
teamA,
|
|
||||||
teamB,
|
|
||||||
scoreA: 1,
|
|
||||||
scoreB: 1,
|
|
||||||
outcome: "forfeit",
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
"기권승",
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
getSeriesHistoryStatusLabel(
|
|
||||||
completedSeries({
|
|
||||||
id: "administrative",
|
|
||||||
teamA,
|
|
||||||
teamB,
|
|
||||||
scoreA: 0,
|
|
||||||
scoreB: 0,
|
|
||||||
outcome: "administrative",
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
"판정",
|
|
||||||
);
|
);
|
||||||
|
assert.equal(getSeriesHistoryResultLabel(walkover), "부전승");
|
||||||
|
assert.equal(getSeriesHistoryResultLabel(forfeit), "기권승");
|
||||||
|
assert.equal(getSeriesHistoryResultLabel(administrative), "판정승");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("describes recorded Games, decisions, and legacy missing records", () => {
|
||||||
|
const teamA = teamId("record-team-a");
|
||||||
|
const teamB = teamId("record-team-b");
|
||||||
|
const played = completedSeries({
|
||||||
|
id: "recorded-played",
|
||||||
|
teamA,
|
||||||
|
teamB,
|
||||||
|
scoreA: 2,
|
||||||
|
scoreB: 0,
|
||||||
|
});
|
||||||
|
const decision = completedSeries({
|
||||||
|
id: "recorded-decision",
|
||||||
|
teamA,
|
||||||
|
teamB,
|
||||||
|
scoreA: 0,
|
||||||
|
scoreB: 0,
|
||||||
|
outcome: "walkover",
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(getSeriesHistoryRecordLabel(played, 2, false), "게임 상세 (2)");
|
||||||
|
assert.equal(getSeriesHistoryRecordLabel(played, 2, true), "게임 상세 접기");
|
||||||
|
assert.equal(getSeriesHistoryRecordLabel(decision, 0, false), "경기 없이 결정");
|
||||||
|
assert.equal(getSeriesHistoryRecordLabel(played, 0, false), "게임 기록 미등록");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("shows a numeric score only for played records", () => {
|
test("shows a numeric score only for played records", () => {
|
||||||
@@ -386,12 +423,25 @@ 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-13"), "07월 13일 (월)");
|
assert.equal(formatCompetitionHistoryDate("2026-07-05"), "7월 5일 (일)");
|
||||||
|
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(
|
||||||
|
formatCompetitionHistoryDayHeading("unknown", 1),
|
||||||
|
"일시 정보 없음 · 1경기",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
function playedSeriesWithGame({
|
function playedSeriesWithGame({
|
||||||
|
|||||||
Reference in new issue
Block a user