feat: enhance auction interactions and player statistics UI

This commit is contained in:
dahyeon committed 2026-11-11 20:06:22 +09:00
1 parent 6c582ba3cf
commit be4de61bb7
115 files changed
+13292 -2871

No files matched your search

+286 -222
View File
@@ -1,6 +1,18 @@
import { useEffect, useRef, useState } from "react";
import { ChevronLeft, ChevronRight } from "lucide-react";
import { Link, useLocation, useNavigate, useParams } from "react-router";
import {
Link,
useLocation,
useNavigate,
useParams,
useSearchParams,
} from "react-router";
import { StatsBack, StatsLink } from "../components/internal-stats/StatsShared";
import {
statsTarget,
useStatsBack,
useStatsRestoration,
} from "../components/internal-stats/stats-navigation";
import {
Area,
AreaChart,
@@ -16,10 +28,7 @@ import {
import { useDdragonManifest, useInternalMatchDetail } from "../api/hooks";
import type { ApiInternalMatchDetailResponse, TeamSide } from "../api/types";
import { DEFAULT_COMMUNITY_ID } from "../config";
import {
championDisplayName,
championIconUrl,
} from "../lib/ddragon";
import { championDisplayName, championIconUrl } from "../lib/ddragon";
import {
sideShortLabel,
teamIndexColorClasses,
@@ -32,9 +41,15 @@ import {
import { selectInternalMatchGame } from "../lib/internal-match-game-selection";
import { ApiError } from "../lib/api";
import { BasicGameScoreboard } from "../components/BasicGameScoreboard";
import { groupRecordedSets, type RecordedSeries } from "../lib/internal-match-series";
import {
groupRecordedSets,
type RecordedSeries,
} from "../lib/internal-match-series";
import { riotMatchIdForDisplay } from "../lib/internal-game-evidence";
import { getSeriesHistoryResultLabel, shouldDisplaySeriesHistoryScore } from "../components/competition/competition-series-history";
import {
getSeriesHistoryResultLabel,
shouldDisplaySeriesHistoryScore,
} from "../components/competition/competition-series-history";
import { LANE_LABELS } from "../lib/riot-history";
import {
filterTimelineEvents,
@@ -58,16 +73,7 @@ import {
SummonerSpellIcon,
} from "../components/ItemTooltip";
import {
Btn,
EmptyNote,
ErrorNote,
LoadingNote,
MetaDot,
PageBody,
PageHero,
PlainPage,
} from "../ui";
import { Btn, EmptyNote, ErrorNote, LoadingNote, PlainPage } from "../ui";
type MatchGameDetail = ApiInternalMatchDetailResponse["games"][number];
type MatchGameTeam = MatchGameDetail["teams"][number];
type MatchGameParticipant = MatchGameTeam["participants"][number];
@@ -138,6 +144,7 @@ function createNavigationState(
function formatDateTime(value: string | number) {
return new Intl.DateTimeFormat("ko-KR", {
timeZone: "Asia/Seoul",
month: "long",
day: "numeric",
hour: "2-digit",
@@ -367,6 +374,8 @@ function PlayerIdentityCell({
nameMaxWidth?: string;
}) {
const location = useLocation();
const { cid } = useParams();
const [params] = useSearchParams();
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
const lane =
LANE_LABELS[participant.teamPosition] ?? participant.teamPosition ?? "-";
@@ -392,13 +401,17 @@ function PlayerIdentityCell({
<SpellRuneStrip participant={participant} manifest={manifest} />
<div className="min-w-0">
{participant.userId ? (
<Link
to={`/users/${participant.userId}/history?queueGroup=internal`}
state={{ backTo: historyBackTo }}
<StatsLink
to={statsTarget(
`/communities/${cid ?? DEFAULT_COMMUNITY_ID}/internal-stats/players/${participant.userId}`,
params,
historyBackTo,
)}
data-return-id={`scoreboard-${participant.userId}`}
className={`block ${nameMaxWidth} truncate text-sm font-bold text-base-content hover:text-primary`}
>
{nameNode}
</Link>
</StatsLink>
) : (
<span
className={`block ${nameMaxWidth} truncate text-sm font-bold text-base-content`}
@@ -447,7 +460,8 @@ function PlayerRow({
{participant.assists}
</div>
<div className="text-xs font-bold tabular-nums text-base-content/40">
KDA {formatKda(
KDA{" "}
{formatKda(
participant.kills,
participant.deaths,
participant.assists,
@@ -528,7 +542,8 @@ function PlayerCard({
{participant.assists}
</div>
<div className="text-[11px] font-bold tabular-nums text-base-content/40">
KDA {formatKda(
KDA{" "}
{formatKda(
participant.kills,
participant.deaths,
participant.assists,
@@ -1520,6 +1535,7 @@ function GameTabs({
navigationState: MatchGameNavigationState | undefined;
}) {
const navigate = useNavigate();
const [params] = useSearchParams();
const currentRef = useRef<HTMLAnchorElement | null>(null);
const games = group.sets.map(({ game }) => game);
const currentIndex = games.findIndex(
@@ -1528,7 +1544,11 @@ function GameTabs({
const previousGame = games[currentIndex - 1];
const nextGame = games[currentIndex + 1];
const pathFor = (gameNumber: number) =>
internalMatchGamePath(communityId, detail.match.matchId, gameNumber);
statsTarget(
internalMatchGamePath(communityId, detail.match.matchId, gameNumber),
params,
params.get("returnTo") ?? undefined,
);
useEffect(() => {
currentRef.current?.scrollIntoView({ block: "nearest", inline: "center" });
@@ -1548,70 +1568,81 @@ function GameTabs({
className="lts-select min-w-0"
value={group.id}
onChange={(event) => {
const next = groups.find((candidate) => candidate.id === event.target.value);
if (next) void navigate(pathFor(next.sets[0].game.gameNumber), { state: navigationState });
const next = groups.find(
(candidate) => candidate.id === event.target.value,
);
if (next)
void navigate(pathFor(next.sets[0].game.gameNumber), {
state: navigationState,
});
}}
>
{groups.map((candidate) => (
<option key={candidate.id} value={candidate.id}>{candidate.label}</option>
<option key={candidate.id} value={candidate.id}>
{candidate.label}
</option>
))}
</select>
</label>
<div className="flex min-w-0 items-center gap-1 sm:flex-1">
<Link
to={previousGame ? pathFor(previousGame.gameNumber) : "#"}
state={navigationState}
aria-disabled={!previousGame}
tabIndex={previousGame ? undefined : -1}
aria-label="이전 세트"
className={stepClass}
>
<ChevronLeft className="size-4" aria-hidden="true" />
</Link>
<div className="no-scrollbar flex min-w-0 flex-1 gap-1 overflow-x-auto">
{group.sets.map(({ game, official }) => {
const winnerTeam = game.teams.find((team) => team.win);
const active = game.gameNumber === currentGameNumber;
return (
<Link
key={game.gameNumber}
ref={active ? currentRef : undefined}
to={pathFor(game.gameNumber)}
state={navigationState}
aria-current={active ? "page" : undefined}
className={`group flex h-10 shrink-0 items-center gap-2 rounded-[10px] px-3.5 text-sm transition-colors ${
active
? "bg-secondary text-secondary-content"
: "text-content-muted hover:bg-sunken hover:text-content"
}`}
>
<span className="font-bold">
{official ? `${official.ordinal}세트` : `전체 ${game.gameNumber}세트`}
</span>
{official && official.ordinal !== game.gameNumber && (
<span className="text-xs opacity-80">전체 {game.gameNumber}</span>
)}
<span
className={`max-w-28 truncate text-xs ${active ? "opacity-80" : "text-content-subtle group-hover:text-content-muted"}`}
<Link
to={previousGame ? pathFor(previousGame.gameNumber) : "#"}
state={navigationState}
aria-disabled={!previousGame}
tabIndex={previousGame ? undefined : -1}
aria-label="이전 세트"
className={stepClass}
>
<ChevronLeft className="size-4" aria-hidden="true" />
</Link>
<div className="no-scrollbar flex min-w-0 flex-1 gap-1 overflow-x-auto">
{group.sets.map(({ game, official }) => {
const winnerTeam = game.teams.find((team) => team.win);
const active = game.gameNumber === currentGameNumber;
return (
<Link
key={game.gameNumber}
ref={active ? currentRef : undefined}
to={pathFor(game.gameNumber)}
state={navigationState}
aria-current={active ? "page" : undefined}
className={`group flex h-10 shrink-0 items-center gap-2 rounded-[10px] px-3.5 text-sm transition-colors ${
active
? "bg-secondary text-secondary-content"
: "text-content-muted hover:bg-sunken hover:text-content"
}`}
>
{winnerTeam
? `${getTeamName(detail, winnerTeam.teamIndex)} 승`
: "결과 대기"}
</span>
</Link>
);
})}
</div>
<Link
to={nextGame ? pathFor(nextGame.gameNumber) : "#"}
state={navigationState}
aria-disabled={!nextGame}
tabIndex={nextGame ? undefined : -1}
aria-label="다음 세트"
className={stepClass}
>
<ChevronRight className="size-4" aria-hidden="true" />
</Link>
<span className="font-bold">
{official
? `${official.ordinal}세트`
: `전체 ${game.gameNumber}세트`}
</span>
{official && official.ordinal !== game.gameNumber && (
<span className="text-xs opacity-80">
전체 {game.gameNumber}
</span>
)}
<span
className={`max-w-28 truncate text-xs ${active ? "opacity-80" : "text-content-subtle group-hover:text-content-muted"}`}
>
{winnerTeam
? `${getTeamName(detail, winnerTeam.teamIndex)} 승`
: "결과 대기"}
</span>
</Link>
);
})}
</div>
<Link
to={nextGame ? pathFor(nextGame.gameNumber) : "#"}
state={navigationState}
aria-disabled={!nextGame}
tabIndex={nextGame ? undefined : -1}
aria-label="다음 세트"
className={stepClass}
>
<ChevronRight className="size-4" aria-hidden="true" />
</Link>
</div>
</nav>
);
@@ -1629,139 +1660,148 @@ function MatchScoreHero({
backTarget: MatchGameBackTarget;
}) {
const selectedSeries = group.series;
const officialGame = group.sets.find(({ game }) => game === selectedGame)?.official;
const officialGame = group.sets.find(
({ game }) => game === selectedGame,
)?.official;
const riotMatchId = riotMatchIdForDisplay(selectedGame, officialGame);
const setLabel = officialGame ? `${officialGame.ordinal}세트` : `전체 ${selectedGame.gameNumber}세트`;
const setLabel = officialGame
? `${officialGame.ordinal}세트`
: `전체 ${selectedGame.gameNumber}세트`;
const [leftTeam, rightTeam] = selectedGame.teams;
const teamName = (teamId: string | null) =>
detail.competition?.teams.find((team) => team.teamId === teamId)?.name ?? "팀 미확인";
const seriesSummary = selectedSeries && shouldDisplaySeriesHistoryScore(selectedSeries)
? `${selectedSeries.status === "in-progress" ? "시리즈 현재" : "시리즈 최종"} · ${selectedSeries.entries.map(
({ teamId, gameWins }) => `${teamName(teamId)} ${gameWins}`,
).join(" : ")}`
: selectedSeries?.status === "completed" ? getSeriesHistoryResultLabel(selectedSeries) : null;
const sideTone = (side: TeamSide) =>
side === "blue" ? "text-win" : "text-loss";
detail.competition?.teams.find((team) => team.teamId === teamId)?.name ??
"팀 미확인";
const seriesSummary =
selectedSeries && shouldDisplaySeriesHistoryScore(selectedSeries)
? `${selectedSeries.status === "in-progress" ? "시리즈 현재" : "시리즈 최종"} · ${selectedSeries.entries
.map(({ teamId, gameWins }) => `${teamName(teamId)} ${gameWins}`)
.join(" : ")}`
: selectedSeries?.status === "completed"
? getSeriesHistoryResultLabel(selectedSeries)
: null;
return (
<PageHero
width="xl"
crumbs={[
{ label: backTarget.label, to: backTarget.to },
{ label: setLabel },
]}
title={
<>
{detail.match.title}
<span className="ml-2 text-on-ink-muted">
{setLabel}
</span>
</>
}
meta={
<>
<span>{formatDateTime(selectedGame.gameCreation)}</span>
{officialGame && officialGame.ordinal !== selectedGame.gameNumber && (
<>
<MetaDot />
<span>전체 {selectedGame.gameNumber}세트</span>
</>
)}
<MetaDot />
<span className="tabular">
{formatDuration(selectedGame.gameDuration)}
</span>
{riotMatchId && (
<>
<MetaDot />
<span className="font-mono text-xs">{riotMatchId}</span>
</>
)}
{seriesSummary && (
<>
<MetaDot />
<span>{seriesSummary}</span>
</>
)}
</>
}
actions={
leftTeam && rightTeam ? (
<div className="grid w-full grid-cols-[1fr_auto_1fr] items-center gap-4 sm:w-auto sm:min-w-[400px]">
<div className="min-w-0 text-right">
<div
className={`truncate text-[15px] font-bold ${leftTeam.win ? "text-on-ink" : "text-on-ink-muted"}`}
>
{getTeamName(detail, leftTeam.teamIndex)}
</div>
<div
className={`mt-0.5 text-xs font-semibold ${sideTone(leftTeam.side)}`}
>
{sideLabel(leftTeam.side)}
{leftTeam.win && " · 세트 승"}
</div>
</div>
<div className="text-center">
<div className="text-sm font-semibold text-on-ink-muted">세트 결과</div>
</div>
<div className="min-w-0">
<div
className={`truncate text-[15px] font-bold ${rightTeam.win ? "text-on-ink" : "text-on-ink-muted"}`}
>
{getTeamName(detail, rightTeam.teamIndex)}
</div>
<div
className={`mt-0.5 text-xs font-semibold ${sideTone(rightTeam.side)}`}
>
{sideLabel(rightTeam.side)}
{rightTeam.win && " · 세트 승"}
</div>
</div>
<>
<StatsBack to={backTarget.to}>{backTarget.label}</StatsBack>
<header className="is-page-heading is-detail-heading">
<div>
<p className="is-eyebrow">세트 상세 분석</p>
<h1>
{detail.match.title} · {setLabel}
</h1>
<p className="is-muted">
{group.label}
{seriesSummary && <> · {seriesSummary}</>}
</p>
</div>
</header>
<div className="is-game-context">
<span>{formatDateTime(selectedGame.gameCreation)}</span>
<span>플레이 시간 {formatDuration(selectedGame.gameDuration)}</span>
{officialGame && <span>전체 #{selectedGame.gameNumber}</span>}
{riotMatchId && <span>{riotMatchId}</span>}
</div>
{leftTeam && rightTeam && (
<section className="is-game-result" aria-label="세트 결과">
<div>
<span className={leftTeam.side === "blue" ? "is-blue" : "is-red"}>
{sideLabel(leftTeam.side)}
</span>
<h2>{getTeamName(detail, leftTeam.teamIndex)}</h2>
<b className={leftTeam.win ? "is-blue" : "is-muted"}>
{leftTeam.win ? "승리" : rightTeam.win ? "패배" : "결과 미확정"}
</b>
</div>
) : undefined
}
/>
<strong>
VS<small>세트 결과</small>
</strong>
<div>
<span className={rightTeam.side === "blue" ? "is-blue" : "is-red"}>
{sideLabel(rightTeam.side)}
</span>
<h2>{getTeamName(detail, rightTeam.teamIndex)}</h2>
<b className={rightTeam.win ? "is-blue" : "is-muted"}>
{rightTeam.win ? "승리" : leftTeam.win ? "패배" : "결과 미확정"}
</b>
</div>
</section>
)}
</>
);
}
export default function MatchGameDetailPage() {
const { cid, matchId, id, gameNumber } = useParams();
const location = useLocation();
const [activeTab, setActiveTab] =
useState<InternalGameDetailTab>("scoreboard");
const [params, setParams] = useSearchParams();
const activeTab: InternalGameDetailTab =
params.get("analysis") === "build"
? "build"
: params.get("analysis") === "matchup"
? "matchup"
: "scoreboard";
const setActiveTab = (tab: InternalGameDetailTab) => {
const next = new URLSearchParams(params);
next.set("analysis", tab);
setParams(next, { replace: true, preventScrollReset: true });
};
const communityId = cid ?? DEFAULT_COMMUNITY_ID;
const resolvedMatchId = matchId ?? id;
const requestedGameNumber = Number(gameNumber);
const detailQuery = useInternalMatchDetail(resolvedMatchId, communityId);
const { data: ddragon } = useDdragonManifest();
const detail = detailQuery.data;
useStatsRestoration(!detailQuery.isPending);
const fallbackBackTo = id
? `/match/${id}?tab=games`
: resolvedMatchId
? internalMatchDetailPath(communityId, resolvedMatchId)
: `/communities/${communityId}/internal-stats`;
const backTarget = resolveBackTarget(location.state, fallbackBackTo);
? internalMatchDetailPath(communityId, resolvedMatchId)
: `/communities/${communityId}/internal-stats`;
const previousTarget = resolveBackTarget(location.state, fallbackBackTo);
const backTo = useStatsBack(previousTarget.to);
const backTarget = {
to: backTo,
label:
backTo === previousTarget.to
? previousTarget.label
: "이전 전적으로 돌아가기",
};
const navigationState = createNavigationState(backTarget, fallbackBackTo);
if (detailQuery.isLoading) {
return (
<PlainPage>
<div className="internal-stats is-feedback-shell">
<StatsBack to={backTarget.to}>{backTarget.label}</StatsBack>
</div>
<LoadingNote label="세트 기록을 불러오는 중" />
</PlainPage>
);
}
if (detailQuery.isError && !(detailQuery.error instanceof ApiError && detailQuery.error.status === 404)) {
if (
detailQuery.isError &&
!(detailQuery.error instanceof ApiError && detailQuery.error.status === 404)
) {
return (
<PlainPage>
<ErrorNote title="세트 기록을 불러오지 못했습니다"
action={<Btn onClick={() => void detailQuery.refetch()}>다시 시도</Btn>} />
<div className="internal-stats is-feedback-shell">
<StatsBack to={backTarget.to}>{backTarget.label}</StatsBack>
</div>
<ErrorNote
title="세트 기록을 불러오지 못했습니다"
action={
<Btn onClick={() => void detailQuery.refetch()}>다시 시도</Btn>
}
/>
</PlainPage>
);
}
if (!detail) {
return (
<PlainPage>
<div className="internal-stats is-feedback-shell">
<StatsBack to={backTarget.to}>{backTarget.label}</StatsBack>
</div>
<EmptyNote
title="세트 기록을 찾을 수 없습니다"
action={<Btn to={backTarget.to}>{backTarget.label}</Btn>}
@@ -1776,17 +1816,28 @@ export default function MatchGameDetailPage() {
);
const groups = groupRecordedSets(detail);
const group = groups.find(({ sets }) => sets.some(({ game }) => game === selectedGame));
const group = groups.find(({ sets }) =>
sets.some(({ game }) => game === selectedGame),
);
if (!selectedGame || !group) {
const officialGame = detail.competition?.projection.games.find(
(game) => game.displayNumber === requestedGameNumber,
);
if (officialGame) {
const winner = detail.competition?.teams.find((team) => team.teamId === officialGame.winnerTeamId);
const winner = detail.competition?.teams.find(
(team) => team.teamId === officialGame.winnerTeamId,
);
return (
<PlainPage>
<div className="internal-stats is-feedback-shell">
<StatsBack to={backTarget.to}>{backTarget.label}</StatsBack>
</div>
<EmptyNote
title={officialGame.evidence.type === "legacy" ? "Riot 원본이 없는 과거 기록" : "상세 분석 준비 중"}
title={
officialGame.evidence.type === "legacy"
? "Riot 원본이 없는 과거 기록"
: "상세 분석 준비 중"
}
description={`${officialGame.ordinal}세트 · ${winner?.name ?? "팀 미확인"} 승리`}
action={<Btn to={backTarget.to}>{backTarget.label}</Btn>}
/>
@@ -1800,6 +1851,9 @@ export default function MatchGameDetailPage() {
: "요청한 경기";
return (
<PlainPage>
<div className="internal-stats is-feedback-shell">
<StatsBack to={backTarget.to}>{backTarget.label}</StatsBack>
</div>
<EmptyNote
title={
hasRecordedGames
@@ -1818,57 +1872,67 @@ export default function MatchGameDetailPage() {
}
return (
<>
<MatchScoreHero
detail={detail}
selectedGame={selectedGame}
group={group}
backTarget={backTarget}
/>
<PageBody width="xl">
<GameTabs
<div className="internal-stats">
<main className="is-page is-game-page">
<MatchScoreHero
detail={detail}
groups={groups}
selectedGame={selectedGame}
group={group}
communityId={communityId}
currentGameNumber={selectedGame.gameNumber}
navigationState={navigationState}
backTarget={backTarget}
/>
<div>
<GameTabs
detail={detail}
groups={groups}
group={group}
communityId={communityId}
currentGameNumber={selectedGame.gameNumber}
navigationState={navigationState}
/>
{!selectedGame.analysisAvailability || selectedGame.analysisAvailability === "available" ? (
<>
<PostgameBreakdown
selectedGame={selectedGame}
detail={detail}
manifest={ddragon}
/>
<TimelineGraph
key={selectedGame.riotMatchId}
selectedGame={selectedGame}
detail={detail}
manifest={ddragon}
/>
<div className="mt-5 space-y-4">
<InternalGameDetailTabBar activeTab={activeTab} onChange={setActiveTab} />
<InternalGameAnalysisPanel
activeTab={activeTab}
{!selectedGame.analysisAvailability ||
selectedGame.analysisAvailability === "available" ? (
<>
<PostgameBreakdown
selectedGame={selectedGame}
detail={detail}
manifest={ddragon}
scoreboard={
<ScoreboardTables
selectedGame={selectedGame}
detail={detail}
manifest={ddragon}
/>
}
/>
</div>
</>
) : (
<BasicGameScoreboard game={selectedGame} teams={detail.match.teams} manifest={ddragon} />
)}
</PageBody>
</>
<TimelineGraph
key={selectedGame.riotMatchId}
selectedGame={selectedGame}
detail={detail}
manifest={ddragon}
/>
<div className="mt-5 space-y-4">
<InternalGameDetailTabBar
activeTab={activeTab}
onChange={setActiveTab}
/>
<InternalGameAnalysisPanel
activeTab={activeTab}
selectedGame={selectedGame}
detail={detail}
manifest={ddragon}
scoreboard={
<ScoreboardTables
selectedGame={selectedGame}
detail={detail}
manifest={ddragon}
/>
}
/>
</div>
</>
) : (
<BasicGameScoreboard
game={selectedGame}
teams={detail.match.teams}
manifest={ddragon}
/>
)}
</div>
</main>
</div>
);
}