feat: link competition games to detail analysis
Route each result-history Game by its global display number and preserve the Competition return target. Refuse stale detail fallbacks so a missing requested Game cannot silently show another Game.
This commit is contained in:
1 parent
3c60081ece
commit
3bd3120eb1
11 files changed
+382
-54
No files matched your search
@@ -0,0 +1,133 @@
|
||||
import type {
|
||||
CommunityId,
|
||||
CompetitionTeamView,
|
||||
MatchId,
|
||||
TeamId,
|
||||
} from "@lolympus/contracts";
|
||||
import { ChevronRight } from "lucide-react";
|
||||
import { Link } from "react-router";
|
||||
import {
|
||||
competitionHistoryGameDetailPath,
|
||||
formatCompetitionHistoryTime,
|
||||
formatSeriesGameDuration,
|
||||
type CompetitionSeriesHistoryRow,
|
||||
} from "./competition-series-history";
|
||||
|
||||
export function CompetitionGameHistory({
|
||||
games,
|
||||
teamById,
|
||||
communityId,
|
||||
matchId,
|
||||
historyBackTo,
|
||||
}: {
|
||||
games: CompetitionSeriesHistoryRow["games"];
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||
communityId: CommunityId;
|
||||
matchId: MatchId;
|
||||
historyBackTo: string;
|
||||
}) {
|
||||
return (
|
||||
<ol className="border-t border-base-content/10 bg-base-content/[0.02] px-4 py-1">
|
||||
{games.map((game) => {
|
||||
const duration = formatSeriesGameDuration(game.durationSeconds);
|
||||
const winnerName = teamById.get(game.winnerTeamId)?.name ?? "알 수 없는 팀";
|
||||
const detailPath = competitionHistoryGameDetailPath(
|
||||
communityId,
|
||||
matchId,
|
||||
game,
|
||||
);
|
||||
const content = (
|
||||
<GameHistoryRowContent
|
||||
game={game}
|
||||
winnerName={winnerName}
|
||||
duration={duration}
|
||||
linked={detailPath !== null}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<li
|
||||
key={game.id}
|
||||
className="border-b border-base-content/8 last:border-b-0"
|
||||
>
|
||||
{detailPath ? (
|
||||
<Link
|
||||
to={detailPath}
|
||||
state={{
|
||||
backTo: historyBackTo,
|
||||
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"
|
||||
>
|
||||
{content}
|
||||
</Link>
|
||||
) : (
|
||||
<div className="min-h-11 border-l-2 border-l-transparent px-2 py-2 text-xs text-base-content">
|
||||
{content}
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
);
|
||||
}
|
||||
|
||||
function GameHistoryRowContent({
|
||||
game,
|
||||
winnerName,
|
||||
duration,
|
||||
linked,
|
||||
}: {
|
||||
game: CompetitionSeriesHistoryRow["games"][number];
|
||||
winnerName: string;
|
||||
duration: string | null;
|
||||
linked: boolean;
|
||||
}) {
|
||||
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 {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} 승
|
||||
</span>
|
||||
<span
|
||||
className="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="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>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -83,6 +83,8 @@ export function CompetitionResults({
|
||||
)}
|
||||
|
||||
<CompetitionSeriesHistory
|
||||
communityId={competition.communityId}
|
||||
matchId={competition.matchId}
|
||||
projection={projection}
|
||||
teamById={teamById}
|
||||
/>
|
||||
|
||||
@@ -1,34 +1,43 @@
|
||||
import type {
|
||||
CommunityId,
|
||||
CompetitionProjection,
|
||||
CompetitionTeamView,
|
||||
MatchId,
|
||||
TeamId,
|
||||
} from "@lolympus/contracts";
|
||||
import { ChevronDown } from "lucide-react";
|
||||
import { useLocation } from "react-router";
|
||||
import {
|
||||
createCompetitionSeriesHistory,
|
||||
formatCompetitionHistoryDate,
|
||||
formatCompetitionHistoryTime,
|
||||
formatSeriesGameDuration,
|
||||
getSeriesHistoryStatusLabel,
|
||||
shouldDisplaySeriesHistoryScore,
|
||||
type CompetitionSeriesHistoryRow,
|
||||
} from "./competition-series-history";
|
||||
import { CompetitionGameHistory } from "./CompetitionGameHistory";
|
||||
import { bracketRoundLabel } from "./double-elimination-bracket-layout";
|
||||
import { isSeriesEntryWinner } from "./series-score-card-model";
|
||||
|
||||
export function CompetitionSeriesHistory({
|
||||
communityId,
|
||||
matchId,
|
||||
projection,
|
||||
teamById,
|
||||
}: {
|
||||
communityId: CommunityId;
|
||||
matchId: MatchId;
|
||||
projection: CompetitionProjection;
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||
}) {
|
||||
const location = useLocation();
|
||||
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
|
||||
const history = createCompetitionSeriesHistory(projection);
|
||||
if (history.length === 0) return null;
|
||||
|
||||
return (
|
||||
<section
|
||||
className="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"
|
||||
>
|
||||
<header className="border-b border-base-content/10 px-4 py-3">
|
||||
@@ -63,7 +72,13 @@ export function CompetitionSeriesHistory({
|
||||
<ol className="divide-y divide-base-content/10">
|
||||
{day.rows.map((row) => (
|
||||
<li key={row.series.seriesId}>
|
||||
<SeriesHistoryRow row={row} teamById={teamById} />
|
||||
<SeriesHistoryRow
|
||||
row={row}
|
||||
teamById={teamById}
|
||||
communityId={communityId}
|
||||
matchId={matchId}
|
||||
historyBackTo={historyBackTo}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
@@ -78,9 +93,15 @@ export function CompetitionSeriesHistory({
|
||||
function SeriesHistoryRow({
|
||||
row,
|
||||
teamById,
|
||||
communityId,
|
||||
matchId,
|
||||
historyBackTo,
|
||||
}: {
|
||||
row: CompetitionSeriesHistoryRow;
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||
communityId: CommunityId;
|
||||
matchId: MatchId;
|
||||
historyBackTo: string;
|
||||
}) {
|
||||
if (row.games.length === 0) {
|
||||
return (
|
||||
@@ -90,10 +111,16 @@ function SeriesHistoryRow({
|
||||
|
||||
return (
|
||||
<details className="group">
|
||||
<summary className="list-none cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-base-content/70 [&::-webkit-details-marker]:hidden">
|
||||
<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">
|
||||
<SeriesSummary row={row} teamById={teamById} hasGameDetails />
|
||||
</summary>
|
||||
<GameHistory games={row.games} teamById={teamById} />
|
||||
<CompetitionGameHistory
|
||||
games={row.games}
|
||||
teamById={teamById}
|
||||
communityId={communityId}
|
||||
matchId={matchId}
|
||||
historyBackTo={historyBackTo}
|
||||
/>
|
||||
</details>
|
||||
);
|
||||
}
|
||||
@@ -144,7 +171,7 @@ function SeriesSummary({
|
||||
<span className="group-open:hidden">{row.games.length}게임 보기</span>
|
||||
<span className="hidden group-open:inline">게임 접기</span>
|
||||
<ChevronDown
|
||||
className="ml-1 h-4 w-4 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"
|
||||
/>
|
||||
</>
|
||||
@@ -283,47 +310,6 @@ function TeamName({
|
||||
);
|
||||
}
|
||||
|
||||
function GameHistory({
|
||||
games,
|
||||
teamById,
|
||||
}: {
|
||||
games: CompetitionSeriesHistoryRow["games"];
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||
}) {
|
||||
return (
|
||||
<ol className="border-t border-base-content/10 bg-base-content/[0.02] px-4 py-1">
|
||||
{games.map((game) => {
|
||||
const duration = formatSeriesGameDuration(game.durationSeconds);
|
||||
return (
|
||||
<li
|
||||
key={game.id}
|
||||
className="grid grid-cols-[3.75rem_3.25rem_minmax(0,1fr)_3.5rem] items-center gap-2 border-b border-base-content/8 py-2 text-xs last:border-b-0 md:grid-cols-[4.5rem_4rem_minmax(0,1fr)_4.5rem] md:gap-4"
|
||||
>
|
||||
<span className="font-bold text-content-muted">
|
||||
Game {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">
|
||||
{teamName(game.winnerTeamId, teamById)} 승
|
||||
</span>
|
||||
<span
|
||||
className="text-right font-mono tabular-nums text-content-muted"
|
||||
aria-label={duration ? `경기 시간 ${duration}` : "경기 시간 기록 없음"}
|
||||
>
|
||||
{duration ?? "—"}
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
);
|
||||
}
|
||||
|
||||
function teamName(
|
||||
teamId: TeamId,
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>,
|
||||
|
||||
@@ -4,6 +4,7 @@ import type {
|
||||
IsoDateTime,
|
||||
SeriesProjection,
|
||||
} from "@lolympus/contracts";
|
||||
import { internalMatchGamePath } from "../../lib/internal-match-routes.ts";
|
||||
|
||||
export type CompetitionSeriesHistorySeries = Extract<
|
||||
SeriesProjection,
|
||||
@@ -34,6 +35,17 @@ const KOREAN_WEEKDAYS = [
|
||||
"토",
|
||||
] as const;
|
||||
|
||||
export function competitionHistoryGameDetailPath(
|
||||
communityId: string,
|
||||
matchId: string,
|
||||
game: Pick<CompetitionGameView, "displayNumber">,
|
||||
): string | null {
|
||||
if (!Number.isSafeInteger(game.displayNumber) || game.displayNumber <= 0) {
|
||||
return null;
|
||||
}
|
||||
return internalMatchGamePath(communityId, matchId, game.displayNumber);
|
||||
}
|
||||
|
||||
export function createCompetitionSeriesHistory(
|
||||
projection: HistoryProjection,
|
||||
timeZone = "Asia/Seoul",
|
||||
|
||||
@@ -122,6 +122,12 @@ body {
|
||||
--color-base-300: oklch(95% 0 0); /* 구분선/보더 */
|
||||
}
|
||||
|
||||
/* 경기 결과 기록의 링크 강조는 양쪽 테마에서 같은 브랜드 코랄을 쓴다.
|
||||
전역 dark primary는 유지해 다른 화면의 기존 색상 의미를 바꾸지 않는다. */
|
||||
.competition-series-history {
|
||||
--color-primary: oklch(0.708008 0.234375 24);
|
||||
}
|
||||
|
||||
/* ── 실시간 입찰 피드백 모션 ──
|
||||
입찰가 갱신 시 pop(스케일 펄스), 내가 밀렸을 때 shake(주의 환기). */
|
||||
@keyframes lts-bid-pop {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
export function selectInternalMatchGame<T extends { gameNumber: number }>(
|
||||
games: readonly T[],
|
||||
requestedGameNumber: number,
|
||||
): T | null {
|
||||
if (
|
||||
!Number.isSafeInteger(requestedGameNumber) ||
|
||||
requestedGameNumber <= 0
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
games.find((game) => game.gameNumber === requestedGameNumber) ?? null
|
||||
);
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
internalMatchDetailPath,
|
||||
internalMatchGamePath,
|
||||
} from "../lib/internal-match-routes";
|
||||
import { selectInternalMatchGame } from "../lib/internal-match-game-selection";
|
||||
import { LANE_LABELS } from "../lib/riot-history";
|
||||
import {
|
||||
filterTimelineEvents,
|
||||
@@ -1681,14 +1682,29 @@ export default function MatchGameDetailPage() {
|
||||
);
|
||||
}
|
||||
|
||||
const selectedGame =
|
||||
detail.games.find((game) => game.gameNumber === requestedGameNumber) ??
|
||||
detail.games[0];
|
||||
const selectedGame = selectInternalMatchGame(
|
||||
detail.games,
|
||||
requestedGameNumber,
|
||||
);
|
||||
|
||||
if (!selectedGame) {
|
||||
const hasRecordedGames = detail.games.length > 0;
|
||||
const requestedGameLabel =
|
||||
Number.isSafeInteger(requestedGameNumber) && requestedGameNumber > 0
|
||||
? `${requestedGameNumber}경기`
|
||||
: "요청한 경기";
|
||||
return (
|
||||
<main className="mx-auto max-w-6xl px-4 py-20 text-center">
|
||||
<h1 className="text-lg font-bold">수집된 세트 기록이 없습니다</h1>
|
||||
<h1 className="text-lg font-bold">
|
||||
{hasRecordedGames
|
||||
? "해당 경기 기록을 찾을 수 없습니다"
|
||||
: "수집된 세트 기록이 없습니다"}
|
||||
</h1>
|
||||
{hasRecordedGames && (
|
||||
<p className="mt-2 text-sm text-content-muted">
|
||||
{requestedGameLabel}가 현재 상세 기록에 없습니다.
|
||||
</p>
|
||||
)}
|
||||
<Link
|
||||
to={backTarget.to}
|
||||
className="btn btn-ghost btn-sm mt-4"
|
||||
|
||||
Reference in new issue
Block a user