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
@@ -55,14 +55,14 @@ export function CompetitionGameHistory({
|
||||
to={detailPath}
|
||||
state={{
|
||||
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}
|
||||
</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}
|
||||
</div>
|
||||
)}
|
||||
@@ -84,50 +84,57 @@ function GameHistoryRowContent({
|
||||
duration: string | null;
|
||||
linked: boolean;
|
||||
}) {
|
||||
const startedAt = formatCompetitionHistoryTime(game.startedAt);
|
||||
|
||||
return (
|
||||
<span
|
||||
className={
|
||||
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">
|
||||
<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">
|
||||
<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">
|
||||
{winnerName} 승
|
||||
</span>
|
||||
<span
|
||||
className="text-right font-mono tabular-nums text-content-muted"
|
||||
>
|
||||
{duration ? (
|
||||
<>
|
||||
<span className="sr-only">경기 시간 </span>
|
||||
{duration}
|
||||
</>
|
||||
|
||||
<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">
|
||||
{game.ordinal}게임
|
||||
</span>
|
||||
{startedAt ? (
|
||||
<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 className="sr-only">경기 시간 기록 없음</span>
|
||||
</>
|
||||
<span className="sr-only">시작 시각 기록 없음</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>상세 분석</span>
|
||||
<ChevronRight
|
||||
className="h-3.5 w-3.5 shrink-0 text-primary"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
|
||||
<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 className="shrink-0 text-right font-mono tabular-nums text-content-muted">
|
||||
{duration ? (
|
||||
<>
|
||||
<span className="sr-only">경기 시간 </span>
|
||||
{duration}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<span aria-hidden="true">—</span>
|
||||
<span className="sr-only">경기 시간 기록 없음</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>
|
||||
);
|
||||
}
|
||||
@@ -24,17 +24,18 @@ export function CompetitionResults({
|
||||
const teamById = new Map(
|
||||
competition.teams.map((team) => [team.teamId, team]),
|
||||
);
|
||||
const seriesHistory =
|
||||
view === "bracket" ? [] : createCompetitionSeriesHistory(projection);
|
||||
|
||||
if (view === "games") {
|
||||
const hasSeriesHistory =
|
||||
createCompetitionSeriesHistory(projection).length > 0;
|
||||
const hasSeriesHistory = seriesHistory.length > 0;
|
||||
return (
|
||||
<div className="mb-6">
|
||||
{hasSeriesHistory ? (
|
||||
<CompetitionSeriesHistory
|
||||
communityId={competition.communityId}
|
||||
matchId={competition.matchId}
|
||||
projection={projection}
|
||||
history={seriesHistory}
|
||||
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"
|
||||
role="status"
|
||||
>
|
||||
기록된 공식 경기가 없습니다.
|
||||
예정되거나 기록된 공식 경기가 없습니다.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
@@ -62,7 +63,7 @@ export function CompetitionResults({
|
||||
Competition
|
||||
</p>
|
||||
<h2 id="competition-heading" className="mt-1 text-lg font-bold">
|
||||
공식 경기 결과
|
||||
공식 경기 일정·결과
|
||||
</h2>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
@@ -114,7 +115,7 @@ export function CompetitionResults({
|
||||
<CompetitionSeriesHistory
|
||||
communityId={competition.communityId}
|
||||
matchId={competition.matchId}
|
||||
projection={projection}
|
||||
history={seriesHistory}
|
||||
teamById={teamById}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type {
|
||||
CommunityId,
|
||||
CompetitionProjection,
|
||||
CompetitionTeamView,
|
||||
MatchId,
|
||||
TeamId,
|
||||
@@ -9,14 +8,16 @@ import { ChevronDown } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useLocation } from "react-router";
|
||||
import {
|
||||
createCompetitionSeriesHistory,
|
||||
formatCompetitionHistoryDayHeading,
|
||||
formatCompetitionHistoryTime,
|
||||
formatCompetitionHistoryDate,
|
||||
getSeriesHistoryRecordLabel,
|
||||
getSeriesHistoryResultLabel,
|
||||
getSeriesHistoryStatusLabel,
|
||||
getSeriesHistoryTimePresentation,
|
||||
isCompetitionHistoryCalendarDate,
|
||||
shouldDisplaySeriesHistoryScore,
|
||||
type CompetitionSeriesHistoryDay,
|
||||
type CompetitionSeriesHistoryRow,
|
||||
type CompetitionSeriesHistorySeries,
|
||||
} from "./competition-series-history";
|
||||
import { CompetitionGameHistory } from "./CompetitionGameHistory";
|
||||
import { bracketRoundLabel } from "./double-elimination-bracket-layout";
|
||||
@@ -25,22 +26,29 @@ import { isSeriesEntryWinner } from "./series-score-card-model";
|
||||
export function CompetitionSeriesHistory({
|
||||
communityId,
|
||||
matchId,
|
||||
projection,
|
||||
history,
|
||||
teamById,
|
||||
}: {
|
||||
communityId: CommunityId;
|
||||
matchId: MatchId;
|
||||
projection: CompetitionProjection;
|
||||
history: CompetitionSeriesHistoryDay[];
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||
}) {
|
||||
const location = useLocation();
|
||||
const historyPath = `${location.pathname}${location.search}`;
|
||||
const history = createCompetitionSeriesHistory(projection);
|
||||
if (history.length === 0) return null;
|
||||
const resultCount = history.reduce(
|
||||
(count, day) => count + day.rows.length,
|
||||
0,
|
||||
);
|
||||
|
||||
const rows = history.flatMap((day) => day.rows);
|
||||
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 (
|
||||
<section
|
||||
@@ -53,18 +61,18 @@ export function CompetitionSeriesHistory({
|
||||
id="competition-series-history-heading"
|
||||
className="text-sm font-bold"
|
||||
>
|
||||
경기 결과 기록
|
||||
경기 일정·결과
|
||||
</h3>
|
||||
<p className="mt-0.5 text-xs text-content-muted">
|
||||
진행 중인 시리즈와 최종 결과를 실제 경기 기록 순서로 보여줍니다.
|
||||
예정 경기부터 최종 결과까지 날짜순으로 보여줍니다.
|
||||
</p>
|
||||
</div>
|
||||
{resultCount > 1 && (
|
||||
{rows.length > 1 && anchorRow && (
|
||||
<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"
|
||||
>
|
||||
최신 결과로
|
||||
{jumpLabel}
|
||||
<ChevronDown
|
||||
className="h-4 w-4 text-primary"
|
||||
aria-hidden="true"
|
||||
@@ -73,63 +81,50 @@ export function CompetitionSeriesHistory({
|
||||
)}
|
||||
</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>
|
||||
{history.map((day, dayIndex) => {
|
||||
{history.map((day) => {
|
||||
const headingId = historyDayHeadingId(day.dateKey);
|
||||
const dayHeading = formatCompetitionHistoryDayHeading(
|
||||
day.dateKey,
|
||||
day.rows.length,
|
||||
);
|
||||
const dateLabel = formatCompetitionHistoryDate(day.dateKey);
|
||||
return (
|
||||
<section key={day.dateKey} aria-labelledby={headingId}>
|
||||
<h4
|
||||
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" ? (
|
||||
dayHeading
|
||||
{isCompetitionHistoryCalendarDate(day.dateKey) ? (
|
||||
<time dateTime={day.dateKey}>{dateLabel}</time>
|
||||
) : (
|
||||
<time dateTime={day.dateKey}>
|
||||
{dayHeading}
|
||||
</time>
|
||||
<span>{dateLabel}</span>
|
||||
)}
|
||||
<span className="shrink-0 text-xs font-semibold text-content-muted">
|
||||
{day.rows.length}경기
|
||||
</span>
|
||||
</h4>
|
||||
<ol className="divide-y divide-base-content/10">
|
||||
{day.rows.map((row, rowIndex) => {
|
||||
const isLatestResult =
|
||||
dayIndex === history.length - 1 &&
|
||||
rowIndex === day.rows.length - 1;
|
||||
return (
|
||||
<li
|
||||
key={row.series.seriesId}
|
||||
id={
|
||||
isLatestResult
|
||||
? "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>
|
||||
);
|
||||
})}
|
||||
{day.rows.map((row) => (
|
||||
<li
|
||||
key={row.series.seriesId}
|
||||
id={
|
||||
row.series.seriesId === anchorRow?.series.seriesId
|
||||
? "competition-series-history-current"
|
||||
: undefined
|
||||
}
|
||||
className={
|
||||
row.series.seriesId === anchorRow?.series.seriesId
|
||||
? "scroll-mt-24"
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<SeriesHistoryRow
|
||||
row={row}
|
||||
teamById={teamById}
|
||||
communityId={communityId}
|
||||
matchId={matchId}
|
||||
historyPath={historyPath}
|
||||
currentHash={location.hash}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</section>
|
||||
);
|
||||
@@ -204,8 +199,6 @@ function SeriesSummary({
|
||||
}) {
|
||||
const { series } = row;
|
||||
const statusLabel = getSeriesHistoryStatusLabel(series);
|
||||
const timeLabel = formatCompetitionHistoryTime(row.occurredAt);
|
||||
const timeKind = row.timestampSource === "game-start" ? "시작" : "결정";
|
||||
const roundLabel = bracketRoundLabel(
|
||||
series.stage.type,
|
||||
series.stage.roundNumber,
|
||||
@@ -215,89 +208,98 @@ function SeriesSummary({
|
||||
row.games.length,
|
||||
false,
|
||||
);
|
||||
const showRecordLabel = hasGameDetails || !isFutureSeries(series);
|
||||
|
||||
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">
|
||||
<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 min-w-0 lg:col-start-2 lg:row-start-1">
|
||||
<SeriesMatchup row={row} teamById={teamById} />
|
||||
</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">
|
||||
{roundLabel}
|
||||
</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 className="mt-2 flex min-h-6 items-center justify-end text-xs font-bold text-content-muted lg:mt-0">
|
||||
{hasGameDetails ? (
|
||||
<>
|
||||
<span className="group-open:hidden">{closedRecordLabel}</span>
|
||||
<span className="hidden group-open:inline">
|
||||
{getSeriesHistoryRecordLabel(series, row.games.length, true)}
|
||||
</span>
|
||||
<ChevronDown
|
||||
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>
|
||||
{showRecordLabel && (
|
||||
<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">
|
||||
{getSeriesHistoryRecordLabel(series, row.games.length, true)}
|
||||
</span>
|
||||
<ChevronDown
|
||||
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>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function HistoryTime({
|
||||
occurredAt,
|
||||
timeKind,
|
||||
timeLabel,
|
||||
}: {
|
||||
occurredAt: string;
|
||||
timeKind: "시작" | "결정";
|
||||
timeLabel: string | null;
|
||||
}) {
|
||||
return timeLabel ? (
|
||||
<time
|
||||
dateTime={occurredAt}
|
||||
className="shrink-0 text-xs font-bold tabular-nums text-content-muted"
|
||||
>
|
||||
{timeKind} <span className="font-mono">{timeLabel}</span>
|
||||
</time>
|
||||
) : (
|
||||
<span className="shrink-0 text-xs font-bold text-content-muted">
|
||||
<span aria-hidden="true">{timeKind} —</span>
|
||||
<span className="sr-only">{timeKind} 시각 기록 없음</span>
|
||||
function HistoryTime({ row }: { row: CompetitionSeriesHistoryRow }) {
|
||||
const presentation = getSeriesHistoryTimePresentation(row);
|
||||
const kindLabel =
|
||||
row.timestampSource === "decision"
|
||||
? "결정"
|
||||
: row.timestampSource === "scheduled" ||
|
||||
row.timestampSource === "unavailable"
|
||||
? "예정"
|
||||
: "시작";
|
||||
|
||||
if (presentation.dateTime) {
|
||||
return (
|
||||
<time
|
||||
dateTime={presentation.dateTime}
|
||||
aria-label={`${kindLabel} 시각 ${presentation.text}`}
|
||||
className="shrink-0 text-sm font-bold tabular-nums text-base-content"
|
||||
>
|
||||
{row.timestampSource === "decision" && (
|
||||
<span className="mr-1 text-xs text-content-muted">결정</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>
|
||||
);
|
||||
}
|
||||
|
||||
function StatusLabel({
|
||||
series,
|
||||
label,
|
||||
inProgress,
|
||||
}: {
|
||||
series: CompetitionSeriesHistorySeries;
|
||||
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 (
|
||||
<span
|
||||
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"
|
||||
}`}
|
||||
>
|
||||
<span className={`shrink-0 px-1.5 py-0.5 text-xs font-bold ${tone}`}>
|
||||
{label}
|
||||
</span>
|
||||
);
|
||||
@@ -317,7 +319,6 @@ function SeriesMatchup({
|
||||
const teamBWon = isSeriesEntryWinner(row.series, entryB.teamId);
|
||||
const showScore = shouldDisplaySeriesHistoryScore(row.series);
|
||||
const resultLabel = getSeriesHistoryResultLabel(row.series);
|
||||
const statusLabel = getSeriesHistoryStatusLabel(row.series);
|
||||
const officialWinnerTeamId =
|
||||
row.series.status === "completed" && row.series.outcome.type !== "draw"
|
||||
? row.series.outcome.winnerTeamId
|
||||
@@ -327,11 +328,10 @@ function SeriesMatchup({
|
||||
: `${teamAName} 대 ${teamBName}`;
|
||||
const accessibleResult = [
|
||||
matchupAnnouncement,
|
||||
resultLabel,
|
||||
resultLabel === "VS" ? null : resultLabel,
|
||||
officialWinnerTeamId
|
||||
? `${teamName(officialWinnerTeamId, teamById)} 승`
|
||||
: null,
|
||||
statusLabel,
|
||||
]
|
||||
.filter((part): part is string => Boolean(part))
|
||||
.join(", ");
|
||||
@@ -339,7 +339,7 @@ function SeriesMatchup({
|
||||
return (
|
||||
<>
|
||||
<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"
|
||||
>
|
||||
<TeamName name={teamAName} winner={teamAWon} align="right" />
|
||||
@@ -367,8 +367,10 @@ function SeriesMatchup({
|
||||
<span
|
||||
className={
|
||||
showScore
|
||||
? "mt-0.5 text-[11px] font-bold leading-4 text-content-muted"
|
||||
: "text-sm font-bold leading-5 text-base-content"
|
||||
? "mt-0.5 text-xs font-bold leading-4 text-content-muted"
|
||||
: row.series.status === "completed"
|
||||
? "text-sm font-bold leading-5 text-base-content"
|
||||
: "text-sm font-bold leading-5 text-content-muted"
|
||||
}
|
||||
>
|
||||
{resultLabel}
|
||||
@@ -393,26 +395,35 @@ function TeamName({
|
||||
}) {
|
||||
return (
|
||||
<span
|
||||
className={`min-w-0 break-words text-sm leading-5 ${
|
||||
align === "right" ? "text-right" : "text-left"
|
||||
className={`flex min-h-10 min-w-0 items-center gap-1 text-sm leading-5 ${
|
||||
align === "right" ? "justify-end text-right" : "justify-start text-left"
|
||||
} ${winner ? "font-bold text-base-content" : "text-content-subtle"}`}
|
||||
aria-hidden="true"
|
||||
>
|
||||
{name}
|
||||
<span className="min-w-0 break-words">{name}</span>
|
||||
{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>
|
||||
);
|
||||
}
|
||||
|
||||
function teamName(
|
||||
teamId: TeamId,
|
||||
teamId: TeamId | null,
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>,
|
||||
): string {
|
||||
if (teamId === null) return "미정";
|
||||
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 {
|
||||
return `competition-series-history-day-${dateKey}`;
|
||||
}
|
||||
|
||||
@@ -3,19 +3,24 @@ import type {
|
||||
CompetitionProjection,
|
||||
IsoDateTime,
|
||||
SeriesProjection,
|
||||
SeriesSchedule,
|
||||
} from "@lolympus/contracts";
|
||||
import { internalMatchGamePath } from "../../lib/internal-match-routes.ts";
|
||||
|
||||
export type CompetitionSeriesHistorySeries = Extract<
|
||||
SeriesProjection,
|
||||
{ status: "in-progress" | "completed" }
|
||||
>;
|
||||
export type CompetitionSeriesHistorySeries = SeriesProjection;
|
||||
|
||||
export type CompetitionSeriesHistoryTimestampSource =
|
||||
| "game-start"
|
||||
| "decision"
|
||||
| "scheduled"
|
||||
| "unavailable";
|
||||
|
||||
export interface CompetitionSeriesHistoryRow {
|
||||
series: CompetitionSeriesHistorySeries;
|
||||
games: CompetitionGameView[];
|
||||
occurredAt: IsoDateTime;
|
||||
timestampSource: "game-start" | "decision";
|
||||
occurredAt: IsoDateTime | null;
|
||||
timestampSource: CompetitionSeriesHistoryTimestampSource;
|
||||
dateKey: string;
|
||||
}
|
||||
|
||||
export interface CompetitionSeriesHistoryDay {
|
||||
@@ -23,6 +28,12 @@ export interface CompetitionSeriesHistoryDay {
|
||||
rows: CompetitionSeriesHistoryRow[];
|
||||
}
|
||||
|
||||
export interface SeriesHistoryTimePresentation {
|
||||
text: string;
|
||||
dateTime: string | null;
|
||||
screenReaderText: string | null;
|
||||
}
|
||||
|
||||
type HistoryProjection = Pick<CompetitionProjection, "series" | "games">;
|
||||
|
||||
const KOREAN_WEEKDAYS = [
|
||||
@@ -35,6 +46,9 @@ const KOREAN_WEEKDAYS = [
|
||||
"토",
|
||||
] as const;
|
||||
|
||||
const UNKNOWN_DATE_KEY = "unknown";
|
||||
const UNKNOWN_RECORD_DATE_KEY = "record-unknown";
|
||||
|
||||
export function competitionHistoryGameDetailPath(
|
||||
communityId: string,
|
||||
matchId: string,
|
||||
@@ -62,38 +76,72 @@ export function createCompetitionSeriesHistory(
|
||||
const games = [...(gamesBySeriesId.get(series.seriesId) ?? [])].sort(
|
||||
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);
|
||||
rows.push({
|
||||
series,
|
||||
games,
|
||||
occurredAt: gameStartedAt ?? series.outcome.completedAt,
|
||||
timestampSource: gameStartedAt ? "game-start" : "decision",
|
||||
});
|
||||
switch (series.status) {
|
||||
case "completed": {
|
||||
if (hasInvalidStartedAt(games)) {
|
||||
rows.push(missingRecordedGameTimeRow(series, games));
|
||||
break;
|
||||
}
|
||||
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);
|
||||
|
||||
const days: CompetitionSeriesHistoryDay[] = [];
|
||||
for (const row of rows) {
|
||||
const dateKey = dateKeyInTimeZone(row.occurredAt, timeZone);
|
||||
const currentDay = days.at(-1);
|
||||
if (currentDay?.dateKey === dateKey) {
|
||||
if (currentDay?.dateKey === row.dateKey) {
|
||||
currentDay.rows.push(row);
|
||||
} else {
|
||||
days.push({ dateKey, rows: [row] });
|
||||
days.push({ dateKey: row.dateKey, rows: [row] });
|
||||
}
|
||||
}
|
||||
return days;
|
||||
@@ -102,13 +150,29 @@ export function createCompetitionSeriesHistory(
|
||||
export function getSeriesHistoryStatusLabel(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
): string {
|
||||
if (series.status === "in-progress") return "진행 중";
|
||||
return "최종";
|
||||
switch (series.status) {
|
||||
case "inactive":
|
||||
return "필요 시";
|
||||
case "waiting":
|
||||
case "ready":
|
||||
return "예정";
|
||||
case "in-progress":
|
||||
return "진행 중";
|
||||
case "completed":
|
||||
return "최종";
|
||||
}
|
||||
}
|
||||
|
||||
export function getSeriesHistoryResultLabel(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
): string | null {
|
||||
if (
|
||||
series.status === "inactive" ||
|
||||
series.status === "waiting" ||
|
||||
series.status === "ready"
|
||||
) {
|
||||
return "VS";
|
||||
}
|
||||
if (series.status === "in-progress") return null;
|
||||
switch (series.outcome.type) {
|
||||
case "played":
|
||||
@@ -134,6 +198,13 @@ export function getSeriesHistoryRecordLabel(
|
||||
if (gameCount > 0) {
|
||||
return expanded ? "게임 상세 접기" : `게임 상세 (${gameCount})`;
|
||||
}
|
||||
if (
|
||||
series.status === "inactive" ||
|
||||
series.status === "waiting" ||
|
||||
series.status === "ready"
|
||||
) {
|
||||
return "게임 전";
|
||||
}
|
||||
if (isGameLessDecision(series)) return "경기 없이 결정";
|
||||
return "게임 기록 미등록";
|
||||
}
|
||||
@@ -142,12 +213,58 @@ export function shouldDisplaySeriesHistoryScore(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
): boolean {
|
||||
if (series.status === "in-progress") return true;
|
||||
if (series.status !== "completed") return false;
|
||||
if (series.outcome.type === "played") return true;
|
||||
return (
|
||||
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(
|
||||
durationSeconds: number,
|
||||
): string | null {
|
||||
@@ -163,8 +280,9 @@ export function formatSeriesGameDuration(
|
||||
}
|
||||
|
||||
export function formatCompetitionHistoryDate(dateKey: string): string {
|
||||
if (dateKey === UNKNOWN_RECORD_DATE_KEY) return "기록 일시 미상";
|
||||
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(dateKey);
|
||||
if (!match) return "일시 정보 없음";
|
||||
if (!match) return "일정 미정";
|
||||
const year = Number(match[1]);
|
||||
const month = Number(match[2]);
|
||||
const day = Number(match[3]);
|
||||
@@ -174,16 +292,13 @@ export function formatCompetitionHistoryDate(dateKey: string): string {
|
||||
date.getUTCMonth() !== month - 1 ||
|
||||
date.getUTCDate() !== day
|
||||
) {
|
||||
return "일시 정보 없음";
|
||||
return "일정 미정";
|
||||
}
|
||||
return `${month}월 ${day}일 (${KOREAN_WEEKDAYS[date.getUTCDay()]})`;
|
||||
return `${month}월 ${padNumber(day)}일 (${KOREAN_WEEKDAYS[date.getUTCDay()]})`;
|
||||
}
|
||||
|
||||
export function formatCompetitionHistoryDayHeading(
|
||||
dateKey: string,
|
||||
gameCount: number,
|
||||
): string {
|
||||
return `${formatCompetitionHistoryDate(dateKey)} · ${gameCount}경기`;
|
||||
export function isCompetitionHistoryCalendarDate(dateKey: string): boolean {
|
||||
return isValidLocalDate(dateKey);
|
||||
}
|
||||
|
||||
export function formatCompetitionHistoryTime(
|
||||
@@ -205,6 +320,47 @@ export function formatCompetitionHistoryTime(
|
||||
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(
|
||||
left: CompetitionGameView,
|
||||
right: CompetitionGameView,
|
||||
@@ -221,12 +377,32 @@ function compareRows(
|
||||
right: CompetitionSeriesHistoryRow,
|
||||
): number {
|
||||
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.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 {
|
||||
let earliest: { value: number; startedAt: IsoDateTime } | null = null;
|
||||
for (const game of games) {
|
||||
@@ -239,9 +415,18 @@ function earliestStartedAt(games: CompetitionGameView[]): IsoDateTime | 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);
|
||||
if (Number.isNaN(date.getTime())) return "unknown";
|
||||
if (Number.isNaN(date.getTime())) return null;
|
||||
const parts = new Intl.DateTimeFormat("en-US", {
|
||||
timeZone,
|
||||
year: "numeric",
|
||||
@@ -253,7 +438,7 @@ function dateKeyInTimeZone(value: IsoDateTime, timeZone: string): string {
|
||||
const year = part("year");
|
||||
const month = part("month");
|
||||
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 {
|
||||
@@ -264,13 +449,31 @@ function timestampValue(value: IsoDateTime): number {
|
||||
function isGameLessDecision(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
): boolean {
|
||||
if (series.status === "in-progress") return false;
|
||||
if (series.status !== "completed") return false;
|
||||
if (series.outcome.type === "draw") {
|
||||
return series.outcome.basis.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 {
|
||||
return value.toString().padStart(2, "0");
|
||||
}
|
||||
@@ -26,9 +26,9 @@ export const MATCH_DETAIL_TAB_QUERY_KEY = "tab";
|
||||
|
||||
const PUBLIC_MATCH_DETAIL_TABS: MatchDetailTab[] = [
|
||||
{ id: "bracket", label: "대진표·순위" },
|
||||
{ id: "games", label: "경기 기록" },
|
||||
{ id: "games", label: "경기 일정·결과" },
|
||||
{ id: "teams", label: "팀" },
|
||||
{ id: "info", label: "일정·안내" },
|
||||
{ id: "info", label: "안내" },
|
||||
];
|
||||
|
||||
const OPERATIONS_TAB: MatchDetailTab = { id: "ops", label: "운영" };
|
||||
|
||||
@@ -97,15 +97,15 @@ function resolveBackTarget(
|
||||
return {
|
||||
to: state.backTo,
|
||||
label:
|
||||
typeof state.backLabel === "string"
|
||||
? state.backLabel
|
||||
typeof state.backLabel === "string" && state.backLabel.trim().length > 0
|
||||
? state.backLabel.trim()
|
||||
: "돌아가기",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
to: fallbackTo,
|
||||
label: "경기 결과로 돌아가기",
|
||||
label: "경기 기록으로 돌아가기",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user