feat: connect tournament views to APIs and recover archived stats

Remove development previews and complete hall of fame, match history, official results, and multi-kill API integration.

Fix active match pagination and team-ready controls, preserve basic scoreboards, and recover statistics when Riot archives arrive.

Use bounded in-process cache invalidation retries and add the Riot match lookup index migration with regression coverage.
This commit is contained in:
dahyeon committed 2026-11-11 02:00:35 +09:00
1 parent 20e1e6ec04
commit 0d7617e2d2
70 files changed
+3739 -1793

No files matched your search

+8 -49
View File
@@ -35,11 +35,7 @@ import {
useAuctionSocket,
type BidLatencyDiagnostics,
} from "../api/useAuctionSocket";
import {
DEFAULT_COMMUNITY_ID,
setDevCaptainTeamIndex,
useDevCaptainTeamIndex,
} from "../config";
import { DEFAULT_COMMUNITY_ID } from "../config";
import { ApiError } from "../lib/api";
import { mergeAuctionState } from "../api/auction-state";
import {
@@ -1929,7 +1925,6 @@ export default function AuctionPage() {
const undoMutation = useUndoAuction(DEFAULT_COMMUNITY_ID);
const resetAuctionMutation = useResetAuction(DEFAULT_COMMUNITY_ID);
const socket = useAuctionSocket(id);
const captainTeamIndex = useDevCaptainTeamIndex();
const [assignedPositionDraft, setAssignedPositionDraft] = useState<{
playerId: string | null;
position: Position;
@@ -1995,29 +1990,12 @@ export default function AuctionPage() {
const setAssignedPosition = (position: Position) => {
setAssignedPositionDraft({ playerId: currentPlayerId, position });
};
const availableTeamIndexes = useMemo(() => {
const indexes = new Set(
(auctionState?.teams ?? []).map((team) => team.teamIndex),
);
return [...indexes].sort((left, right) => left - right);
}, [auctionState?.teams]);
const captainRole: CaptainRole | null =
captainTeamIndex === null
? null
: {
teamIndex: captainTeamIndex,
};
const captainTeam = currentUser && auctionState?.teams.find(
(team) => team.captainUserId === currentUser._id,
);
const captainRole: CaptainRole | null = captainTeam ? { teamIndex: captainTeam.teamIndex } : null;
const chatSenderLabel = resolveChatSenderLabel(currentUser, captainRole);
useEffect(() => {
if (availableTeamIndexes.length === 0) return;
if (
captainTeamIndex !== null &&
!availableTeamIndexes.includes(captainTeamIndex)
) {
setDevCaptainTeamIndex(availableTeamIndexes[0]);
}
}, [availableTeamIndexes, captainTeamIndex]);
useEffect(() => {
if (!socket.resetAt || !id) return;
@@ -2299,28 +2277,9 @@ export default function AuctionPage() {
</>
}
actions={
<div className="w-40">
{/* 임시 운영용: 로그인/권한 확인 없이 조작자 역할을 선택할 수 있게 열어둔다. */}
<select
aria-label="경매 참여 역할"
value={captainTeamIndex ?? "spectator"}
onChange={(event) =>
setDevCaptainTeamIndex(
event.target.value === "spectator"
? null
: Number(event.target.value),
)
}
className="lts-select"
>
<option value="spectator">관전자</option>
{availableTeamIndexes.map((teamIndex) => (
<option key={teamIndex} value={teamIndex}>
{teamIndexLabel(teamIndex)} 팀장
</option>
))}
</select>
</div>
<span className="text-sm font-semibold" aria-label="경매 참여 역할">
{captainTeam ? teamIndexLabel(captainTeam.teamIndex, captainTeam.name) + " 팀장" : "관전자"}
</span>
}
/>
<main
+82 -222
View File
@@ -1,12 +1,11 @@
import { useState } from 'react';
import type { CompetitionDetailResponse } from '@lolympus/contracts';
import { useDeferredValue, useState } from 'react';
import { ChevronDown, Search, X } from 'lucide-react';
import { Link, useLocation, useParams, useSearchParams } from 'react-router';
import {
useCommunity,
useCompetition,
useCommunityInternalStatsMatches,
useCommunityLeaderboard,
useCommunityStatsSeasons,
useDdragonManifest,
useTeamInsights,
} from '../api/hooks';
@@ -22,7 +21,7 @@ import {
profileIconUrl,
} from '../lib/ddragon';
import {
getInternalMatchOutcome,
formatOfficialMatchResult,
getMainLane,
LEADERBOARD_MIN_GAMES,
LEADERBOARD_SORTS,
@@ -38,10 +37,6 @@ import {
getHistoryMatchTitle,
getHomeMatchSchedule,
} from './home-match-presentation';
import {
getSeriesHistoryResultLabel,
shouldDisplaySeriesHistoryScore,
} from '../components/competition/competition-series-history';
import {
Btn,
Chip,
@@ -50,7 +45,6 @@ import {
LoadingNote,
Panel,
PanelHeader,
Pill,
PlainPage,
Skeleton,
} from '../ui';
@@ -95,122 +89,14 @@ function ChampionChip({
);
}
function OfficialMatchResult({
competition,
}: {
competition: CompetitionDetailResponse;
}) {
const { projection, teams } = competition;
const teamName = (id: string) =>
teams.find(({ teamId }) => teamId === id)?.name ?? '팀 미확인';
const outcome = projection.outcome;
if (projection.phase === 'cancelled') return '취소';
if (projection.phase !== 'completed' || !outcome) return '결과 확정 전';
switch (outcome.type) {
case 'double-elimination':
return `우승 · ${teamName(outcome.championTeamId)}`;
case 'round-robin':
return outcome.leaderTeamIds.length > 0
? `${outcome.leaderTeamIds.length > 1 ? '공동 1위' : '우승'} · ${outcome.leaderTeamIds.map(teamName).join(', ')}`
: '대회 종료';
case 'paired-series': {
if (projection.series.length !== 1) return '시리즈 종료';
const series = projection.series[0];
if (!shouldDisplaySeriesHistoryScore(series))
return getSeriesHistoryResultLabel(series) ?? '시리즈 종료';
const [left, right] = series.entries;
return `${teamName(left.teamId ?? '')} ${left.gameWins} : ${right.gameWins} ${teamName(right.teamId ?? '')}`;
}
}
}
/** 팀원 프로필을 겹쳐 보여주는 작은 묶음. */
function MemberStack({
members,
manifest,
}: {
members: ApiInternalMatchCard['teams'][number]['members'];
manifest: Manifest;
}) {
if (members.length === 0) return null;
return (
<span className="flex shrink-0 -space-x-1.5" aria-hidden="true">
{members.slice(0, 5).map((member) => (
<img
key={member.userId}
src={profileIconUrl(manifest, member.profileIconId)}
alt=""
title={member.summonerName}
className="size-6 rounded-full bg-sunken-strong object-cover ring-2 ring-card"
loading="lazy"
/>
))}
</span>
);
}
/** 펼치지 않아도 보이는 결과 요약. 목록 응답에 담긴 값만 쓴다. */
function MatchOutcomeSummary({
match,
recordedGameCount,
manifest,
}: {
match: ApiInternalMatchCard;
recordedGameCount: number;
manifest: Manifest;
}) {
const outcome = getInternalMatchOutcome(match);
if (!outcome) {
return (
<span className="flex items-center gap-2">
{match.status === 'in-progress' && (
<Pill tone="live" dot>
진행 중
</Pill>
)}
<span className="tabular">{recordedGameCount}세트 수집</span>
</span>
);
}
if (outcome.type === 'score') {
const { left, right, leftWins, rightWins, winner } = outcome;
const nameClass = (team: typeof left) =>
`min-w-0 truncate ${winner?.teamIndex === team.teamIndex ? 'font-bold text-content' : ''}`;
return (
<span className="flex min-w-0 items-center gap-2">
<span className={nameClass(left)}>{left.name}</span>
<strong className="tabular shrink-0 rounded-full bg-sunken-strong px-2.5 py-0.5 text-content-strong">
{leftWins} : {rightWins}
</strong>
<span className={nameClass(right)}>{right.name}</span>
</span>
);
}
return (
<span className="flex min-w-0 items-center gap-2">
<Pill tone="gold">우승</Pill>
<strong className="min-w-0 truncate font-bold text-content">
{outcome.winner.name}
</strong>
<MemberStack members={outcome.winner.members} manifest={manifest} />
</span>
);
}
function MatchCard({
match,
communityId,
manifest,
}: {
match: ApiInternalMatchCard;
communityId: string;
manifest: Manifest;
}) {
const [open, setOpen] = useState(false);
const competition = useCompetition(match.matchId, communityId, open);
const result = match.resultPresentation;
const location = useLocation();
const backTo = `${location.pathname}${location.search}`;
const recordedGames = match.games.filter(
@@ -224,10 +110,7 @@ function MatchCard({
return (
<li>
<details
className="group"
onToggle={(event) => setOpen(event.currentTarget.open)}
>
<details className="group">
<summary className="grid cursor-pointer list-none grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-2 px-4 py-3.5 hover:bg-sunken focus-visible:-outline-offset-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,18rem)_auto] sm:px-5 [&::-webkit-details-marker]:hidden">
<span className="min-w-0">
<span className="tabular block text-xs text-content-muted">
@@ -243,76 +126,62 @@ function MatchCard({
</strong>
</span>
<span className="col-start-1 row-start-2 flex min-w-0 text-sm text-content-muted sm:col-start-2 sm:row-start-1 sm:justify-end">
{competition.data ? (
<strong className="font-semibold text-content">
<OfficialMatchResult competition={competition.data} />
</strong>
) : (
<MatchOutcomeSummary
match={match}
recordedGameCount={recordedGames.length}
manifest={manifest}
/>
)}
<strong className="font-semibold text-content">
{formatOfficialMatchResult(result)}
</strong>
</span>
<ChevronDown
className="col-start-2 row-span-2 row-start-1 size-4 text-content-muted transition-transform group-open:rotate-180 sm:col-start-3 sm:row-span-1"
aria-hidden="true"
/>
</summary>
{open && (
<div className="border-t border-line bg-sunken px-4 py-3 sm:px-5">
<div className="flex flex-wrap items-center justify-between gap-2 text-sm">
<p className="text-content-muted">
{competition.isLoading
? '공식 결과를 확인하는 중'
: competition.data
? '수집된 세트 기록'
: '공식 시리즈 정보를 확인할 수 없습니다'}
</p>
<Link
className="font-semibold hover:underline"
to={internalMatchDetailPath(communityId, match.matchId)}
state={{ backTo }}
>
내전 기록 전체 보기 →
</Link>
</div>
{recordedGames.length > 0 && (
<ul className="mt-2 divide-y divide-line text-sm">
{recordedGames.map((game) => {
const winner = match.teams.find(
({ teamIndex }) => teamIndex === game.winnerTeamIndex,
);
return (
<li
key={game.gameNumber}
className="flex flex-wrap items-center justify-between gap-x-3 py-2"
>
<span className="tabular">
전체 {game.gameNumber}세트 ·{' '}
{winner ? `${winner.name} 승` : '팀 미확인'}
</span>
{game.riotMatchId && (
<Link
className="font-semibold hover:underline"
to={internalMatchGamePath(
communityId,
match.matchId,
game.gameNumber,
)}
state={{ backTo, backLabel: '내전 전적으로' }}
>
상세 분석
</Link>
)}
</li>
);
})}
</ul>
)}
<div className="border-t border-line bg-sunken px-4 py-3 sm:px-5">
<div className="flex flex-wrap items-center justify-between gap-2 text-sm">
<p className="text-content-muted">
{recordedGames.length > 0 ? '수집된 세트 기록' : '수집된 세트 기록 없음'}
</p>
<Link
className="font-semibold hover:underline"
to={internalMatchDetailPath(communityId, match.matchId)}
state={{ backTo }}
>
내전 기록 전체 보기 →
</Link>
</div>
)}
{recordedGames.length > 0 && (
<ul className="mt-2 divide-y divide-line text-sm">
{recordedGames.map((game) => {
const winner = match.teams.find(
({ teamIndex }) => teamIndex === game.winnerTeamIndex,
);
return (
<li
key={game.gameNumber}
className="flex flex-wrap items-center justify-between gap-x-3 py-2"
>
<span className="tabular">
전체 {game.gameNumber}세트 ·{' '}
{winner ? `${winner.name} 승` : '팀 미확인'}
</span>
{game.riotMatchId && (
<Link
className="font-semibold hover:underline"
to={internalMatchGamePath(
communityId,
match.matchId,
game.gameNumber,
)}
state={{ backTo, backLabel: '내전 전적으로' }}
>
상세 분석
</Link>
)}
</li>
);
})}
</ul>
)}
</div>
</details>
</li>
);
@@ -567,7 +436,7 @@ export default function CommunityInternalStatsPage() {
const isRanking = searchParams.get('view') === 'ranking';
const seasonId = searchParams.get('seasonId') || 'current';
const query = searchParams.get('q') ?? '';
const keyword = query.trim().toLocaleLowerCase('ko-KR');
const keyword = useDeferredValue(query.trim().slice(0, 100));
const format = searchParams.get('format');
const playerId = searchParams.get('player');
const sort = parseLeaderboardSort(searchParams.get('sort'));
@@ -579,12 +448,18 @@ export default function CommunityInternalStatsPage() {
limit: 12,
};
const communityQuery = useCommunity(communityId);
const seasonsQuery = useCommunityStatsSeasons(communityId);
const matchesQuery = useCommunityInternalStatsMatches(
filters,
{
...filters,
query: isRanking ? undefined : keyword,
format: format === 'pair' || format === 'tournament' ? format : undefined,
playerId: playerId ?? undefined,
},
communityId,
!isRanking,
);
const leaderboardQuery = useCommunityLeaderboard(filters, communityId);
const leaderboardQuery = useCommunityLeaderboard({ ...filters, query: isRanking ? keyword : undefined }, communityId);
const insightsQuery = useTeamInsights(filters, communityId);
const { data: ddragon } = useDdragonManifest();
const matches =
@@ -599,24 +474,12 @@ export default function CommunityInternalStatsPage() {
sort,
);
const player = leaderboardRows.find((row) => row.userId === playerId);
const visibleMatches = matches.filter((match) => {
const matchType = match.teams.length === 2 ? 'pair' : 'tournament';
return (
((format !== 'pair' && format !== 'tournament') ||
matchType === format) &&
(!playerId ||
match.teams.some((team) =>
team.members.some((member) => member.userId === playerId),
)) &&
match.title.toLocaleLowerCase('ko-KR').includes(keyword)
);
});
const visiblePlayers = leaderboardRows.filter((row) =>
row.summonerName.toLocaleLowerCase('ko-KR').includes(keyword),
);
const hasMatchFilters = Boolean(
keyword || format === 'pair' || format === 'tournament' || playerId,
);
const matchedUsers = leaderboardQuery.data?.matchedUserIds;
const visiblePlayers = isRanking && keyword
? leaderboardRows.filter((row) => matchedUsers?.includes(row.userId))
: leaderboardRows;
const hasMatchFilters = Boolean(keyword || format || playerId);
const confirmedSideWinRate = insights?.sideWinRate.confirmed;
const title = isRanking ? '선수 순위' : '최근 내전';
if (!communityId) {
@@ -673,7 +536,11 @@ export default function CommunityInternalStatsPage() {
>
<option value="current">현재 시즌</option>
<option value="all">전체 시즌</option>
{seasonId !== 'current' && seasonId !== 'all' && (
{seasonsQuery.data?.seasons
.filter(({ id }) => id !== 'current' && id !== 'all')
.map(({ id, label }) => <option key={id} value={id}>{label}</option>)}
{seasonId !== 'current' && seasonId !== 'all' &&
!seasonsQuery.data?.seasons.some(({ id }) => id === seasonId) && (
<option value={seasonId}>{season?.label ?? seasonId}</option>
)}
</select>
@@ -703,6 +570,7 @@ export default function CommunityInternalStatsPage() {
<input
type="search"
aria-label={isRanking ? '선수 검색' : '내전명 검색'}
maxLength={100}
placeholder={isRanking ? '선수 이름 검색' : '내전명 검색'}
value={query}
onChange={(event) => updateParam('q', event.target.value)}
@@ -716,7 +584,7 @@ export default function CommunityInternalStatsPage() {
<h2 id="internal-stats-heading" className="text-base font-bold">
{title}{' '}
<span className="tabular ml-1 text-sm font-medium text-content-muted">
{isRanking ? visiblePlayers.length : visibleMatches.length}
{isRanking ? visiblePlayers.length : matches.length}
</span>
</h2>
{isRanking ? (
@@ -841,34 +709,28 @@ export default function CommunityInternalStatsPage() {
}
/>
</div>
) : visibleMatches.length === 0 ? (
) : matches.length === 0 ? (
<EmptyNote
size="sm"
title={
hasMatchFilters
? '불러온 기록에 일치하는 내전이 없습니다'
? '조건에 일치하는 내전이 없습니다'
: '아직 수집된 내전 결과가 없습니다'
}
/>
) : (
<ul className="divide-y divide-line">
{visibleMatches.map((match) => (
{matches.map((match) => (
<MatchCard
key={match.matchId}
match={match}
communityId={communityId}
manifest={ddragon}
/>
))}
</ul>
)}
{matchesQuery.hasNextPage && (
<div className="space-y-2 border-t border-line p-3">
{hasMatchFilters && (
<p className="text-center text-xs text-content-muted">
필터는 불러온 {matches.length}건에 적용됩니다.
</p>
)}
{matchesQuery.isFetchNextPageError && (
<p
role="status"
@@ -901,12 +763,10 @@ export default function CommunityInternalStatsPage() {
<div className="p-4">
{insightsQuery.isLoading ? (
<Skeleton width="100%" height={52} />
) : confirmedSideWinRate ? (
<SideWinRate {...confirmedSideWinRate} />
) : insights ? (
<SideWinRate
blue={insights.sideWinRate.blue}
red={insights.sideWinRate.red}
sampleSize={insights.sideWinRate.bluePicks}
/>
<p className="text-sm text-content-muted">확정 세트 표본을 확인할 수 없습니다.</p>
) : (
<ErrorNote
title="시즌 요약을 불러오지 못했습니다"
+78 -30
View File
@@ -1,4 +1,4 @@
import { useEffect, useState, type CSSProperties } from 'react';
import { useEffect, useState, type CSSProperties, type ReactNode } from 'react';
import type {
MatchDetailResponse,
MatchEventType,
@@ -24,6 +24,7 @@ import {
Button,
EmptyNote,
ErrorNote,
LoadingNote,
Panel,
PanelHeader,
Pill,
@@ -36,11 +37,11 @@ import {
getHomeMatchEnrollment,
getHomeMatchSchedule,
getNextMatchBanner,
HOME_MATCH_STATUS,
getMatchStageLabel,
} from './home-match-presentation';
const UPCOMING_MATCH_LIST_LIMIT = 4;
const HISTORY_MATCH_PAGE_SIZE = 10;
const MATCH_ARCHIVE_PAGE_SIZE = 10;
const HOME_HISTORY_LIMIT = 4;
const HOME_RANKING_LIMIT = 5;
const DEFAULT_MAP_ID = 11;
@@ -127,9 +128,11 @@ function NextMatch({ match }: { match: MatchDetailResponse }) {
function UpcomingMatches({
matches,
title = '이어지는 내전',
footer,
}: {
matches: MatchDetailResponse[];
title?: string;
footer?: ReactNode;
}) {
return (
<Panel>
@@ -156,7 +159,7 @@ function UpcomingMatches({
<p className="tabular col-start-1 mt-1 text-[13px] text-content-muted sm:col-start-3 sm:row-start-1 sm:mt-0">
{match.status === 'recruiting'
? label
: HOME_MATCH_STATUS[match.status]}{' '}
: getMatchStageLabel(match)}{' '}
· {capacity}
</p>
<ChevronRight
@@ -168,6 +171,10 @@ function UpcomingMatches({
);
})}
</ul>
{matches.length === 0 && (
<EmptyNote size="sm" title="이 페이지에 표시할 일정이 없습니다." />
)}
{footer}
</Panel>
);
}
@@ -238,13 +245,13 @@ function HistoryResult({ match }: { match: MatchSummaryResponse }) {
tone={match.status === 'in-progress' ? 'live' : 'neutral'}
dot={match.status === 'in-progress'}
>
{HOME_MATCH_STATUS[match.status]}
{getMatchStageLabel(match)}
</Pill>
);
}
return (
<span className="text-content-muted">
{HOME_MATCH_STATUS[match.status]}
{getMatchStageLabel(match)}
</span>
);
}
@@ -764,7 +771,7 @@ function RankingPreview({ statsPath }: { statsPath: string }) {
);
}
interface HistoryPaginationProps {
interface MatchPaginationProps {
page: number;
pageCount: number;
total: number;
@@ -773,14 +780,14 @@ interface HistoryPaginationProps {
onNext: () => void;
}
function HistoryPagination({
function MatchPagination({
page,
pageCount,
total,
isFetching,
onPrevious,
onNext,
}: HistoryPaginationProps) {
}: MatchPaginationProps) {
return (
<div className="flex flex-wrap items-center justify-between gap-x-3 gap-y-1 border-t border-line px-4 py-2.5 sm:px-5">
<span className="tabular text-xs text-content-muted">
@@ -814,32 +821,43 @@ export default function HomePage({ eventType }: { eventType?: MatchEventType })
const eventLabel = MATCH_EVENT_LABEL[selectedEventType];
const [timelineNow] = useState(() => new Date().toISOString());
const [searchParams, setSearchParams] = useSearchParams();
const requestedPage = Number(searchParams.get('page'));
const historyPage =
showArchive && Number.isSafeInteger(requestedPage) && requestedPage > 0
? requestedPage
: 1;
const historyLimit = showArchive
? HISTORY_MATCH_PAGE_SIZE
: HOME_HISTORY_LIMIT;
function setHistoryPage(page: number) {
const params = new URLSearchParams(searchParams);
if (page > 1) params.set('page', String(page));
else params.delete('page');
setSearchParams(params, { preventScrollReset: true });
function getPage(key: 'page' | 'activePage') {
const page = Number(searchParams.get(key));
return showArchive && Number.isSafeInteger(page) && page > 0 ? page : 1;
}
const historyPage = getPage('page');
const activePage = getPage('activePage');
const historyLimit = showArchive ? MATCH_ARCHIVE_PAGE_SIZE : HOME_HISTORY_LIMIT;
const activeLimit = showArchive ? MATCH_ARCHIVE_PAGE_SIZE : UPCOMING_MATCH_LIST_LIMIT;
function setPage(key: 'page' | 'activePage', page: number) {
setSearchParams((previous) => {
const params = new URLSearchParams(previous);
if (page > 1) params.set(key, String(page));
else params.delete(key);
return params;
}, { preventScrollReset: true });
}
const upcomingMatchesQuery = useMatches({
eventType: selectedEventType,
view: 'upcoming',
asOf: timelineNow,
limit: UPCOMING_MATCH_LIST_LIMIT,
scheduledFrom: timelineNow,
sort: 'asc',
});
const activeMatchesQuery = useMatchesPage({
eventType: selectedEventType,
view: 'active',
asOf: timelineNow,
limit: activeLimit,
page: activePage,
sort: 'desc',
});
const historyMatchesQuery = useMatchesPage({
eventType: selectedEventType,
view: 'history',
asOf: timelineNow,
limit: historyLimit,
page: historyPage,
status: showArchive ? undefined : 'finished',
scheduledTo: showArchive ? timelineNow : undefined,
sort: 'desc',
includeResults: true,
});
@@ -860,6 +878,11 @@ export default function HomePage({ eventType }: { eventType?: MatchEventType })
const bannerMatch = showArchive ? undefined : nextMatch;
const visibleUpcomingMatches = showArchive ? allUpcomingMatches : upcomingMatches;
const historyTotal = historyMatchesQuery.data?.total ?? 0;
const activeTotal = activeMatchesQuery.data?.total ?? 0;
const activePageCount = Math.max(
1,
Math.ceil(activeTotal / (activeMatchesQuery.data?.limit ?? activeLimit)),
);
const historyPageCount = Math.max(
1,
Math.ceil(historyTotal / (historyMatchesQuery.data?.limit ?? historyLimit)),
@@ -882,6 +905,31 @@ export default function HomePage({ eventType }: { eventType?: MatchEventType })
<h1 className="text-2xl font-bold">{eventLabel} 일정</h1>
</header>
)}
{activeMatchesQuery.isError && !activeMatchesQuery.data ? (
<ErrorNote title="진행 중인 일정을 불러오지 못했습니다"
action={<Button size="sm" label="다시 시도" onClick={() => void activeMatchesQuery.refetch()} />} />
) : activeMatchesQuery.isPlaceholderData ? (
<Panel aria-busy="true">
<PanelHeader title="진행 중인 일정" />
<LoadingNote label="일정을 불러오는 중" />
</Panel>
) : activeMatchesQuery.data &&
(activeMatchesQuery.data.matches.length > 0 || activePage > 1) ? (
<UpcomingMatches
matches={activeMatchesQuery.data.matches}
title="진행 중인 일정"
footer={showArchive && (activePageCount > 1 || activePage > 1) && (
<MatchPagination
page={activePage}
pageCount={activePageCount}
total={activeTotal}
isFetching={activeMatchesQuery.isFetching}
onPrevious={() => setPage('activePage', Math.min(activePage - 1, activePageCount))}
onNext={() => setPage('activePage', activePage + 1)}
/>
)}
/>
) : null}
{upcomingMatchesQuery.isLoading ? (
<UpcomingStatusHeading className="text-sm text-content-muted" aria-busy="true">
{eventLabel} 일정을 불러오는 중
@@ -921,7 +969,7 @@ export default function HomePage({ eventType }: { eventType?: MatchEventType })
>
<HistorySection aria-busy={isHistoryPageLoading} aria-live="polite">
<PanelHeader
title={showArchive ? '지난 일정과 결과' : '최근 내전 결과'}
title={showArchive ? '종료된 일정과 결과' : '최근 내전 결과'}
variant={showArchive ? 'panel' : 'section'}
actions={
<Link
@@ -961,14 +1009,14 @@ export default function HomePage({ eventType }: { eventType?: MatchEventType })
) : (
<RecentMatchResults matches={historyMatchesQuery.data?.matches ?? []} />
)}
{showArchive && !hasHistoryError && historyTotal > 0 && (
<HistoryPagination
{showArchive && !hasHistoryError && (historyTotal > 0 || historyPage > 1) && (
<MatchPagination
page={historyPage}
pageCount={historyPageCount}
total={historyTotal}
isFetching={historyMatchesQuery.isFetching}
onPrevious={() => setHistoryPage(Math.max(1, historyPage - 1))}
onNext={() => setHistoryPage(historyPage + 1)}
onPrevious={() => setPage('page', Math.min(historyPage - 1, historyPageCount))}
onNext={() => setPage('page', historyPage + 1)}
/>
)}
</HistorySection>
+54 -12
View File
@@ -1,7 +1,8 @@
import { Link, useLocation, useParams } from "react-router";
import { useCompetition, useDdragonManifest, useInternalMatchDetail } from "../api/hooks";
import { useDdragonManifest, useInternalMatchDetail } from "../api/hooks";
import type { ApiInternalMatchDetailResponse, TeamSide } from "../api/types";
import { DEFAULT_COMMUNITY_ID } from "../config";
import { ApiError } from "../lib/api";
import {
championDisplayName,
championIconUrl,
@@ -12,12 +13,16 @@ import {
} from "../lib/league";
import { internalMatchGamePath } from "../lib/internal-match-routes";
import { groupRecordedSets } from "../lib/internal-match-series";
import { riotMatchIdForDisplay } from "../lib/internal-game-evidence";
import { formatOfficialMatchResult } from "../lib/internal-stats-presentation";
import { LANE_LABELS } from "../lib/riot-history";
import { ItemIcon } from "../components/ItemTooltip";
import { BasicGameScoreboard } from "../components/BasicGameScoreboard";
import {
Btn,
EmptyNote,
ErrorNote,
LoadingNote,
MetaDot,
PageBody,
@@ -101,17 +106,22 @@ function GamePanel({
communityId,
matchId,
game,
teams,
ordinal,
riotMatchId,
manifest,
}: {
communityId: string;
matchId: string;
game: ApiInternalMatchDetailResponse["games"][number];
teams: ApiInternalMatchDetailResponse["match"]["teams"];
ordinal?: number;
riotMatchId: string | null;
manifest: ReturnType<typeof useDdragonManifest>["data"];
}) {
const location = useLocation();
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
const hasAnalysis = !game.analysisAvailability || game.analysisAvailability === "available";
return (
<section className="lts-panel overflow-hidden">
@@ -125,8 +135,10 @@ function GamePanel({
</h3>
<p className="mt-1 text-xs text-base-content/35">
{formatDateTime(game.gameCreation)} ·{" "}
{formatDuration(game.gameDuration)} ·{" "}
<span className="font-mono">{game.riotMatchId}</span>
{formatDuration(game.gameDuration)}
{riotMatchId && (
<> · <span className="font-mono">{riotMatchId}</span></>
)}
</p>
</div>
<div className="flex gap-2">
@@ -135,7 +147,7 @@ function GamePanel({
state={{ backTo: historyBackTo }}
className="inline-flex h-7 items-center rounded-full bg-primary-tint px-3 text-xs font-bold text-primary transition-colors hover:brightness-95"
>
상세 분석
{hasAnalysis ? "상세 분석" : "경기 기록"}
</Link>
{game.teams.map((team) => (
<span
@@ -155,7 +167,7 @@ function GamePanel({
</div>
</div>
{game.teams.map((team) => (
{hasAnalysis ? game.teams.map((team) => (
<div
key={team.side}
className="border-b border-base-content/8 last:border-b-0"
@@ -246,7 +258,7 @@ function GamePanel({
</table>
</div>
</div>
))}
)) : <BasicGameScoreboard game={game} teams={teams} manifest={manifest} />}
</section>
);
}
@@ -260,7 +272,6 @@ export default function InternalMatchDetailPage() {
? requestedBack
: `/communities/${communityId}/internal-stats`;
const detailQuery = useInternalMatchDetail(matchId, communityId);
const competition = useCompetition(matchId, communityId);
const { data: ddragon } = useDdragonManifest();
const detail = detailQuery.data;
@@ -272,7 +283,15 @@ export default function InternalMatchDetailPage() {
);
}
if (detailQuery.error || !detail) {
if (detailQuery.isError && !(detailQuery.error instanceof ApiError && detailQuery.error.status === 404)) {
return (
<PlainPage>
<ErrorNote title="내전 기록을 불러오지 못했습니다"
action={<Btn onClick={() => void detailQuery.refetch()}>다시 시도</Btn>} />
</PlainPage>
);
}
if (!detail) {
return (
<PlainPage>
<EmptyNote
@@ -287,7 +306,11 @@ export default function InternalMatchDetailPage() {
);
}
const groups = groupRecordedSets(detail, competition.data);
const groups = groupRecordedSets(detail);
const competition = detail.competition;
const unanalysedGames = competition?.projection.games.filter(
(game) => !detail.games.some((record) => record.gameId === game.id),
) ?? [];
return (
<>
@@ -305,6 +328,12 @@ export default function InternalMatchDetailPage() {
<span>{detail.match.teams.length}팀</span>
<MetaDot />
<span>{detail.games.length}세트 수집</span>
{competition && (
<>
<MetaDot />
<span>{formatOfficialMatchResult(detail.match.resultPresentation)}</span>
</>
)}
</>
}
actions={
@@ -314,7 +343,7 @@ export default function InternalMatchDetailPage() {
}
/>
<PageBody width="xl" className="space-y-4">
{detail.games.length === 0 && (
{detail.games.length === 0 && unanalysedGames.length === 0 && (
<Panel>
<EmptyNote title="수집된 경기 기록이 없습니다" />
</Panel>
@@ -324,14 +353,27 @@ export default function InternalMatchDetailPage() {
<h2 className="flex flex-wrap items-baseline gap-x-2 px-1 text-base font-bold">
{group.label}
<span className="text-xs font-medium text-content-muted">
{group.series ? "시리즈" : "대진"} · {group.sets.length}세트 수집
{group.series ? "시리즈" : "공식 시리즈 정보 없음"} · {group.sets.length}세트 수집
</span>
</h2>
{group.sets.map(({ game, official }) => (
<GamePanel key={game.riotMatchId} communityId={communityId} matchId={detail.match.matchId} game={game} ordinal={official?.ordinal} manifest={ddragon} />
<GamePanel key={game.riotMatchId} communityId={communityId} matchId={detail.match.matchId} game={game} teams={detail.match.teams} ordinal={official?.ordinal} riotMatchId={riotMatchIdForDisplay(game, official)} manifest={ddragon} />
))}
</section>
))}
{unanalysedGames.length > 0 && (
<Panel className="space-y-2 p-4">
<h2 className="font-semibold">공식 세트 결과</h2>
<ul className="space-y-1 text-sm">
{unanalysedGames.map((game) => (
<li key={game.id}>
전체 {game.displayNumber}세트 · {competition?.teams.find((team) => team.teamId === game.winnerTeamId)?.name ?? "팀 미확인"} 승리
{" · "}{game.evidence.type === "legacy" ? "Riot 원본 없음" : "상세 분석 준비 중"}
</li>
))}
</ul>
</Panel>
)}
</PageBody>
</>
);
+44 -11
View File
@@ -61,6 +61,7 @@ import {
} from "../components/competition/match-detail-tabs";
import { DEFAULT_COMMUNITY_ID, useAuthUserId } from "../config";
import { apiFetch, ApiError } from "../lib/api";
import { getMatchStageLabel } from "./home-match-presentation";
import { profileIconUrl } from "../lib/ddragon";
import {
POSITION_ORDER,
@@ -1000,6 +1001,9 @@ function MatchRegistration({
joining,
error,
onJoin,
cancelling,
cancelError,
onCancel,
}: {
match: MatchDetailView;
canJoin: boolean;
@@ -1008,6 +1012,9 @@ function MatchRegistration({
joining: boolean;
error: Error | null;
onJoin: (position: Position) => void;
cancelling: boolean;
cancelError: Error | null;
onCancel: () => void;
}) {
const [selectedPosition, setSelectedPosition] = useState<Position>();
const position = selectedPosition ?? initialPosition;
@@ -1059,6 +1066,13 @@ function MatchRegistration({
)
)}
{error && <ErrorNote className="mt-4" title="참가 신청을 완료하지 못했습니다" description={error.message} />}
{match.joined && canJoin && (
<Btn className="mt-4" variant="secondary" loading={cancelling}
disabled={cancelling} onClick={onCancel}>
참가 신청 취소
</Btn>
)}
{cancelError && <ErrorNote className="mt-4" title="참가 신청을 취소하지 못했습니다" description={cancelError.message} />}
</Panel>
);
}
@@ -1452,6 +1466,12 @@ export default function MatchDetailPage() {
const navigate = useNavigate();
const [searchParams, setSearchParams] = useSearchParams();
const queryClient = useQueryClient();
function invalidateMatchLists() {
return Promise.all([
queryClient.invalidateQueries({ queryKey: ["matches", DEFAULT_COMMUNITY_ID] }),
queryClient.invalidateQueries({ queryKey: ["matches-page", DEFAULT_COMMUNITY_ID] }),
]);
}
const authUserId = useAuthUserId();
const matchQuery = useMatch(id, DEFAULT_COMMUNITY_ID);
const competitionEnabled = Boolean(
@@ -1527,9 +1547,7 @@ export default function MatchDetailPage() {
queryClient.invalidateQueries({
queryKey: ["match", DEFAULT_COMMUNITY_ID, id ?? null],
}),
queryClient.invalidateQueries({
queryKey: ["matches", DEFAULT_COMMUNITY_ID],
}),
invalidateMatchLists(),
]);
},
onError: () => {
@@ -1537,6 +1555,19 @@ export default function MatchDetailPage() {
},
});
const cancelJoinMutation = useMutation({
mutationFn: () => apiFetch<MatchDetailResponse>(
`/communities/${DEFAULT_COMMUNITY_ID}/matches/${id}/participants`,
{ method: "DELETE" },
),
onSettled: async () => {
await Promise.all([
queryClient.invalidateQueries({ queryKey: ["match", DEFAULT_COMMUNITY_ID, id ?? null] }),
invalidateMatchLists(),
]);
},
});
const addParticipantMutation = useMutation({
mutationFn: ({
userId,
@@ -1557,9 +1588,7 @@ export default function MatchDetailPage() {
onSuccess: async () => {
await Promise.all([
queryClient.invalidateQueries({ queryKey: matchQueryKey }),
queryClient.invalidateQueries({
queryKey: ["matches", DEFAULT_COMMUNITY_ID],
}),
invalidateMatchLists(),
]);
},
});
@@ -1591,9 +1620,7 @@ export default function MatchDetailPage() {
},
onSettled: () => {
void queryClient.invalidateQueries({ queryKey: matchQueryKey });
void queryClient.invalidateQueries({
queryKey: ["matches", DEFAULT_COMMUNITY_ID],
});
void invalidateMatchLists();
},
});
@@ -1686,6 +1713,7 @@ export default function MatchDetailPage() {
queryClient.invalidateQueries({
queryKey: ["auction", DEFAULT_COMMUNITY_ID, id ?? null],
}),
invalidateMatchLists(),
]);
navigate(`/match/${id}/auction`);
},
@@ -1845,13 +1873,15 @@ export default function MatchDetailPage() {
}
const match = mapApiMatchToMatchDetail(matchQuery.data);
const si = statusBadge(match.status);
const si = { ...statusBadge(match.status), label: getMatchStageLabel(matchQuery.data) };
const auctionNotStarted =
auctionQuery.error instanceof ApiError && auctionQuery.error.status === 404;
const activeAuction = auctionNotStarted ? null : auctionQuery.data;
const showAuctionLink = Boolean(activeAuction);
const hasTeamProgress = Boolean(competitionQuery.data?.teams.length) &&
(match.status === "in-progress" || match.status === "finished");
(matchQuery.data.eventProgress?.stage === "team-ready" ||
match.status === "in-progress" ||
match.status === "finished");
const auctionParticipantPool = buildAuctionParticipantPool(
matchQuery.data.participants,
);
@@ -2010,6 +2040,9 @@ export default function MatchDetailPage() {
joining={joinMatchMutation.isPending}
error={joinMatchMutation.error}
onJoin={joinMatchMutation.mutate}
cancelling={cancelJoinMutation.isPending}
cancelError={cancelJoinMutation.error}
onCancel={() => cancelJoinMutation.mutate()}
/>
)}
+83 -52
View File
@@ -13,7 +13,7 @@ import {
XAxis,
YAxis,
} from "recharts";
import { useCompetition, useDdragonManifest, useInternalMatchDetail } from "../api/hooks";
import { useDdragonManifest, useInternalMatchDetail } from "../api/hooks";
import type { ApiInternalMatchDetailResponse, TeamSide } from "../api/types";
import { DEFAULT_COMMUNITY_ID } from "../config";
import {
@@ -30,7 +30,10 @@ import {
internalMatchGamePath,
} from "../lib/internal-match-routes";
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 { riotMatchIdForDisplay } from "../lib/internal-game-evidence";
import { getSeriesHistoryResultLabel, shouldDisplaySeriesHistoryScore } from "../components/competition/competition-series-history";
import { LANE_LABELS } from "../lib/riot-history";
import {
@@ -58,6 +61,7 @@ import {
import {
Btn,
EmptyNote,
ErrorNote,
LoadingNote,
MetaDot,
PageBody,
@@ -1626,15 +1630,16 @@ function MatchScoreHero({
}) {
const selectedSeries = group.series;
const officialGame = group.sets.find(({ game }) => game === selectedGame)?.official;
const riotMatchId = riotMatchIdForDisplay(selectedGame, officialGame);
const setLabel = officialGame ? `${officialGame.ordinal}세트` : `전체 ${selectedGame.gameNumber}세트`;
const [leftTeam, rightTeam] = selectedGame.teams;
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 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";
@@ -1666,8 +1671,18 @@ function MatchScoreHero({
<span className="tabular">
{formatDuration(selectedGame.gameDuration)}
</span>
<MetaDot />
<span className="font-mono text-xs">{selectedGame.riotMatchId}</span>
{riotMatchId && (
<>
<MetaDot />
<span className="font-mono text-xs">{riotMatchId}</span>
</>
)}
{seriesSummary && (
<>
<MetaDot />
<span>{seriesSummary}</span>
</>
)}
</>
}
actions={
@@ -1687,16 +1702,7 @@ function MatchScoreHero({
</div>
</div>
<div className="text-center">
{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 className="text-sm font-semibold text-on-ink-muted">세트 결과</div>
</div>
<div className="min-w-0">
<div
@@ -1727,10 +1733,11 @@ 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
const fallbackBackTo = id
? `/match/${id}?tab=games`
: resolvedMatchId
? internalMatchDetailPath(communityId, resolvedMatchId)
: `/communities/${communityId}/internal-stats`;
const backTarget = resolveBackTarget(location.state, fallbackBackTo);
@@ -1744,7 +1751,15 @@ export default function MatchGameDetailPage() {
);
}
if (detailQuery.error || !detail) {
if (detailQuery.isError && !(detailQuery.error instanceof ApiError && detailQuery.error.status === 404)) {
return (
<PlainPage>
<ErrorNote title="세트 기록을 불러오지 못했습니다"
action={<Btn onClick={() => void detailQuery.refetch()}>다시 시도</Btn>} />
</PlainPage>
);
}
if (!detail) {
return (
<PlainPage>
<EmptyNote
@@ -1760,9 +1775,24 @@ export default function MatchGameDetailPage() {
requestedGameNumber,
);
const groups = groupRecordedSets(detail, competition.data);
const groups = groupRecordedSets(detail);
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);
return (
<PlainPage>
<EmptyNote
title={officialGame.evidence.type === "legacy" ? "Riot 원본이 없는 과거 기록" : "상세 분석 준비 중"}
description={`${officialGame.ordinal}세트 · ${winner?.name ?? "팀 미확인"} 승리`}
action={<Btn to={backTarget.to}>{backTarget.label}</Btn>}
/>
</PlainPage>
);
}
const hasRecordedGames = detail.games.length > 0;
const requestedGameLabel =
Number.isSafeInteger(requestedGameNumber) && requestedGameNumber > 0
@@ -1805,38 +1835,39 @@ export default function MatchGameDetailPage() {
navigationState={navigationState}
/>
<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={selectedGame}
detail={detail}
manifest={ddragon}
scoreboard={
<ScoreboardTables
{!selectedGame.analysisAvailability || selectedGame.analysisAvailability === "available" ? (
<>
<PostgameBreakdown
selectedGame={selectedGame}
detail={detail}
manifest={ddragon}
/>
}
/>
</div>
<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} />
)}
</PageBody>
</>
);
+11 -16
View File
@@ -52,11 +52,11 @@ import {
RANK_FILTER_TABS,
} from "../lib/riot-history";
import {
mockLargestMultiKill,
multiKillLabel,
rankPositionRates,
} from "../lib/multi-kill";
import { ResponsiveTierLabel } from "../components/RankBadge";
import { formatRankDetail } from "../components/rankBadgeUtils";
import {
InternalGameAnalysisPanel,
InternalGameDetailTabBar,
@@ -647,8 +647,12 @@ function ParticipantRow({
>
{participantName}
</div>
{/* 티어 (임시: 백엔드 연동 전까지 비움 — 라인은 행 순서로 식별) */}
<div className="truncate text-xs text-base-content/30">—</div>
{participant.tier && (
<div className="truncate text-xs text-content-muted"
title={`저장된 티어 · ${formatLastFetched(participant.tier.fetchedAt)}`}>
{formatRankDetail(participant.tier)}
</div>
)}
</div>
</div>
@@ -782,10 +786,9 @@ function resolveInternalDetailGame(
match: ApiRecentMatchView,
) {
if (!detail) return undefined;
return (
detail.games.find((game) => game.gameNumber === match.gameNumber) ??
detail.games.find((game) => game.riotMatchId === match.matchId) ??
detail.games[0]
return detail.games.find(
(game) => game.riotMatchId === match.matchId &&
(match.gameNumber === undefined || game.gameNumber === match.gameNumber),
);
}
@@ -914,14 +917,7 @@ function RecentMatchCard({
ownerParticipantId: string;
}) {
const [expanded, setExpanded] = useState(false);
// 응답에 값이 없을 때 개발 화면에서만 목업으로 배지 모양을 확인한다.
const isMockMultiKill =
match.largestMultiKill === undefined && import.meta.env.DEV;
const multiKill = multiKillLabel(
isMockMultiKill
? mockLargestMultiKill(match.kills)
: match.largestMultiKill,
);
const multiKill = multiKillLabel(match.largestMultiKill);
const championName =
championDisplayName(manifest, match.championId) ?? String(match.championId);
const outcome = match.remake ? "remake" : match.win ? "win" : "loss";
@@ -964,7 +960,6 @@ function RecentMatchCard({
{multiKill && (
<span
className="mt-1 inline-flex h-5 items-center rounded-full border border-leaf px-2 text-[11px] font-semibold text-leaf"
title={isMockMultiKill ? "목업 데이터 (API 미지원)" : undefined}
>
{multiKill}
</span>
+15 -7
View File
@@ -1,4 +1,4 @@
import type { MatchDetailResponse } from '@lolympus/contracts';
import type { MatchDetailResponse, MatchEventStage } from '@lolympus/contracts';
const scheduleFormatter = new Intl.DateTimeFormat('ko-KR', {
timeZone: 'Asia/Seoul',
@@ -10,16 +10,25 @@ const scheduleFormatter = new Intl.DateTimeFormat('ko-KR', {
hourCycle: 'h23',
});
export const HOME_MATCH_STATUS = {
const MATCH_STAGE_LABEL: Record<MatchEventStage, string> = {
recruiting: '모집 중',
'team-built': '팀빌딩',
auction: '경매 중',
'team-ready': '팀 편성 완료',
'team-check': '팀빌딩 상태 확인 필요',
'in-progress': '진행 중',
finished: '종료',
} as const;
};
export function getMatchStageLabel(
match: Pick<MatchDetailResponse, 'status' | 'eventProgress'>,
) {
return MATCH_STAGE_LABEL[match.eventProgress?.stage ??
(match.status === 'team-built' ? 'team-check' : match.status)];
}
type HomeMatchEnrollment = Pick<
MatchDetailResponse,
'status' | 'joined' | 'participants' | 'maxParticipants'
'status' | 'eventProgress' | 'joined' | 'participants' | 'maxParticipants'
>;
export function getHomeMatchSchedule(scheduledAt: string) {
@@ -92,8 +101,7 @@ export function getNextMatchBanner(
const regularTitle = /^(?:[월화수목금토일]요일\s*(?:정기\s*)?|정기\s*)내전$/u;
const title = regularTitle.test(match.title.trim()) ? '정기 내전' : match.title;
let status: string = HOME_MATCH_STATUS[match.status];
if (match.status === 'team-built') status = '팀 편성';
let status = getMatchStageLabel(match);
if (match.status === 'recruiting') {
if (match.joined) status = '신청 완료';
else if (!canApply) status = match.maxParticipants > 0 ? '정원 마감' : '모집 마감';