feat: improve tournament workflows and prune outdated docs
This commit is contained in:
1 parent
da7b502936
commit
38a89b5374
53 files changed
+3308
-3276
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { ChevronLeft, ChevronRight } from "lucide-react";
|
||||
import { Link, useLocation, useParams } from "react-router";
|
||||
import { Link, useLocation, useNavigate, useParams } from "react-router";
|
||||
import {
|
||||
Area,
|
||||
AreaChart,
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
XAxis,
|
||||
YAxis,
|
||||
} from "recharts";
|
||||
import { useDdragonManifest, useInternalMatchDetail } from "../api/hooks";
|
||||
import { useCompetition, useDdragonManifest, useInternalMatchDetail } from "../api/hooks";
|
||||
import type { ApiInternalMatchDetailResponse, TeamSide } from "../api/types";
|
||||
import { DEFAULT_COMMUNITY_ID } from "../config";
|
||||
import {
|
||||
@@ -30,6 +30,8 @@ import {
|
||||
internalMatchGamePath,
|
||||
} from "../lib/internal-match-routes";
|
||||
import { selectInternalMatchGame } from "../lib/internal-match-game-selection";
|
||||
import { groupRecordedSets, type RecordedSeries } from "../lib/internal-match-series";
|
||||
import { getSeriesHistoryResultLabel, shouldDisplaySeriesHistoryScore } from "../components/competition/competition-series-history";
|
||||
import { LANE_LABELS } from "../lib/riot-history";
|
||||
import {
|
||||
filterTimelineEvents,
|
||||
@@ -241,18 +243,6 @@ function getTeamName(
|
||||
);
|
||||
}
|
||||
|
||||
function resolveSelectedSeries(
|
||||
detail: ApiInternalMatchDetailResponse,
|
||||
selectedGame: MatchGameDetail,
|
||||
) {
|
||||
const teamIndexes = selectedGame.teams.map((team) => team.teamIndex);
|
||||
return detail.match.seriesResults.find(
|
||||
(series) =>
|
||||
teamIndexes.includes(series.teamAIndex) &&
|
||||
teamIndexes.includes(series.teamBIndex),
|
||||
);
|
||||
}
|
||||
|
||||
function WinBadge({ win }: { win: boolean }) {
|
||||
return win ? (
|
||||
<span className="inline-flex items-center border border-accent/60 bg-accent px-2 py-0.5 text-xs font-black text-accent-content">
|
||||
@@ -1514,21 +1504,27 @@ function ScoreboardTables({
|
||||
|
||||
function GameTabs({
|
||||
detail,
|
||||
groups,
|
||||
group,
|
||||
communityId,
|
||||
currentGameNumber,
|
||||
navigationState,
|
||||
}: {
|
||||
detail: ApiInternalMatchDetailResponse;
|
||||
groups: RecordedSeries[];
|
||||
group: RecordedSeries;
|
||||
communityId: string;
|
||||
currentGameNumber: number;
|
||||
navigationState: MatchGameNavigationState | undefined;
|
||||
}) {
|
||||
const navigate = useNavigate();
|
||||
const currentRef = useRef<HTMLAnchorElement | null>(null);
|
||||
const currentIndex = detail.games.findIndex(
|
||||
const games = group.sets.map(({ game }) => game);
|
||||
const currentIndex = games.findIndex(
|
||||
(game) => game.gameNumber === currentGameNumber,
|
||||
);
|
||||
const previousGame = detail.games[currentIndex - 1];
|
||||
const nextGame = detail.games[currentIndex + 1];
|
||||
const previousGame = games[currentIndex - 1];
|
||||
const nextGame = games[currentIndex + 1];
|
||||
const pathFor = (gameNumber: number) =>
|
||||
internalMatchGamePath(communityId, detail.match.matchId, gameNumber);
|
||||
|
||||
@@ -1541,9 +1537,25 @@ function GameTabs({
|
||||
|
||||
return (
|
||||
<nav
|
||||
className="lts-panel sticky top-[60px] z-30 flex items-center gap-1 p-1"
|
||||
className="lts-panel sticky top-(--app-header-height) z-30 p-1"
|
||||
aria-label="세트 선택"
|
||||
>
|
||||
<label className="flex min-w-0 items-center gap-2 border-b border-line px-2 py-1.5 text-xs font-semibold text-content-muted">
|
||||
<span className="shrink-0">대진</span>
|
||||
<select
|
||||
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 });
|
||||
}}
|
||||
>
|
||||
{groups.map((candidate) => (
|
||||
<option key={candidate.id} value={candidate.id}>{candidate.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<div className="flex items-center gap-1">
|
||||
<Link
|
||||
to={previousGame ? pathFor(previousGame.gameNumber) : "#"}
|
||||
state={navigationState}
|
||||
@@ -1555,7 +1567,7 @@ function GameTabs({
|
||||
<ChevronLeft className="size-4" aria-hidden="true" />
|
||||
</Link>
|
||||
<div className="no-scrollbar flex min-w-0 flex-1 gap-1 overflow-x-auto">
|
||||
{detail.games.map((game) => {
|
||||
{group.sets.map(({ game, official }) => {
|
||||
const winnerTeam = game.teams.find((team) => team.win);
|
||||
const active = game.gameNumber === currentGameNumber;
|
||||
return (
|
||||
@@ -1571,7 +1583,12 @@ function GameTabs({
|
||||
: "text-content-muted hover:bg-sunken hover:text-content"
|
||||
}`}
|
||||
>
|
||||
<span className="font-bold">{game.gameNumber}세트</span>
|
||||
<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"}`}
|
||||
>
|
||||
@@ -1593,6 +1610,7 @@ function GameTabs({
|
||||
>
|
||||
<ChevronRight className="size-4" aria-hidden="true" />
|
||||
</Link>
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -1600,22 +1618,25 @@ function GameTabs({
|
||||
function MatchScoreHero({
|
||||
detail,
|
||||
selectedGame,
|
||||
group,
|
||||
backTarget,
|
||||
}: {
|
||||
detail: ApiInternalMatchDetailResponse;
|
||||
selectedGame: MatchGameDetail;
|
||||
group: RecordedSeries;
|
||||
backTarget: MatchGameBackTarget;
|
||||
}) {
|
||||
const selectedSeries = resolveSelectedSeries(detail, selectedGame);
|
||||
const selectedSeries = group.series;
|
||||
const officialGame = group.sets.find(({ game }) => game === selectedGame)?.official;
|
||||
const setLabel = officialGame ? `${officialGame.ordinal}세트` : `전체 ${selectedGame.gameNumber}세트`;
|
||||
const [leftTeam, rightTeam] = selectedGame.teams;
|
||||
const leftScore =
|
||||
selectedSeries?.teamAIndex === leftTeam?.teamIndex
|
||||
? selectedSeries?.teamAWins
|
||||
: selectedSeries?.teamBWins;
|
||||
const rightScore =
|
||||
selectedSeries?.teamBIndex === rightTeam?.teamIndex
|
||||
? selectedSeries?.teamBWins
|
||||
: selectedSeries?.teamAWins;
|
||||
const getScore = (side: TeamSide) => selectedSeries?.entries.find(
|
||||
(entry) => entry.teamId === officialGame?.teams[side].teamId,
|
||||
)?.gameWins;
|
||||
const leftScore = leftTeam && getScore(leftTeam.side);
|
||||
const rightScore = rightTeam && getScore(rightTeam.side);
|
||||
const showSeriesScore = selectedSeries && shouldDisplaySeriesHistoryScore(selectedSeries) && leftScore !== undefined && rightScore !== undefined;
|
||||
const decision = selectedSeries?.status === "completed" ? getSeriesHistoryResultLabel(selectedSeries) : null;
|
||||
const sideTone = (side: TeamSide) =>
|
||||
side === "blue" ? "text-[#8fb6ff]" : "text-[#ff99a5]";
|
||||
|
||||
@@ -1624,19 +1645,25 @@ function MatchScoreHero({
|
||||
width="xl"
|
||||
crumbs={[
|
||||
{ label: backTarget.label, to: backTarget.to },
|
||||
{ label: `${selectedGame.gameNumber}세트` },
|
||||
{ label: setLabel },
|
||||
]}
|
||||
title={
|
||||
<>
|
||||
{detail.match.title}
|
||||
<span className="ml-2 text-on-ink-muted">
|
||||
{selectedGame.gameNumber}세트
|
||||
{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)}
|
||||
@@ -1662,14 +1689,16 @@ function MatchScoreHero({
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-center">
|
||||
<div className="tabular flex items-baseline gap-2.5 text-4xl font-extrabold">
|
||||
<span>{leftScore ?? (leftTeam.win ? 1 : 0)}</span>
|
||||
<span className="text-xl text-on-ink-muted">:</span>
|
||||
<span>{rightScore ?? (rightTeam.win ? 1 : 0)}</span>
|
||||
</div>
|
||||
<div className="mt-0.5 text-[11px] font-semibold text-on-ink-muted">
|
||||
시리즈 스코어
|
||||
</div>
|
||||
{showSeriesScore ? (
|
||||
<>
|
||||
<div className="tabular text-4xl font-extrabold">{leftScore} : {rightScore}</div>
|
||||
<div className="mt-0.5 text-xs font-semibold text-on-ink-muted">
|
||||
{selectedSeries.status === "in-progress" ? "시리즈 진행 스코어" : "시리즈 스코어"}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="text-sm font-semibold text-on-ink-muted">{decision ?? "세트 결과"}</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
<div
|
||||
@@ -1700,6 +1729,7 @@ export default function MatchGameDetailPage() {
|
||||
const resolvedMatchId = matchId ?? id;
|
||||
const requestedGameNumber = Number(gameNumber);
|
||||
const detailQuery = useInternalMatchDetail(resolvedMatchId, communityId);
|
||||
const competition = useCompetition(resolvedMatchId, communityId);
|
||||
const { data: ddragon } = useDdragonManifest();
|
||||
const detail = detailQuery.data;
|
||||
const fallbackBackTo = resolvedMatchId
|
||||
@@ -1732,7 +1762,9 @@ export default function MatchGameDetailPage() {
|
||||
requestedGameNumber,
|
||||
);
|
||||
|
||||
if (!selectedGame) {
|
||||
const groups = groupRecordedSets(detail, competition.data);
|
||||
const group = groups.find(({ sets }) => sets.some(({ game }) => game === selectedGame));
|
||||
if (!selectedGame || !group) {
|
||||
const hasRecordedGames = detail.games.length > 0;
|
||||
const requestedGameLabel =
|
||||
Number.isSafeInteger(requestedGameNumber) && requestedGameNumber > 0
|
||||
@@ -1762,11 +1794,14 @@ export default function MatchGameDetailPage() {
|
||||
<MatchScoreHero
|
||||
detail={detail}
|
||||
selectedGame={selectedGame}
|
||||
group={group}
|
||||
backTarget={backTarget}
|
||||
/>
|
||||
<PageBody width="xl">
|
||||
<GameTabs
|
||||
detail={detail}
|
||||
groups={groups}
|
||||
group={group}
|
||||
communityId={communityId}
|
||||
currentGameNumber={selectedGame.gameNumber}
|
||||
navigationState={navigationState}
|
||||
|
||||
Reference in new issue
Block a user