refactor: cut web results over to competition projections
This commit is contained in:
1 parent
7db97c540b
commit
6bddb666fc
13 files changed
+2153
-3885
No files matched your search
+12
-11
@@ -51,7 +51,8 @@ function MsalHeaderActions() {
|
||||
function ThemeToggle() {
|
||||
const theme = useTheme();
|
||||
const nextTheme = theme === "light" ? "dark" : "light";
|
||||
const label = nextTheme === "dark" ? "다크 테마로 전환" : "라이트 테마로 전환";
|
||||
const label =
|
||||
nextTheme === "dark" ? "다크 테마로 전환" : "라이트 테마로 전환";
|
||||
const Icon = nextTheme === "dark" ? Moon : Sun;
|
||||
|
||||
return (
|
||||
@@ -81,11 +82,11 @@ function AppFooter() {
|
||||
</Link>
|
||||
</nav>
|
||||
<p className="leading-relaxed max-w-4xl">
|
||||
© 2026 LOLYMPUS. LOLYMPUS is not endorsed by Riot Games and
|
||||
does not reflect the views or opinions of Riot Games or anyone
|
||||
officially involved in producing or managing League of Legends.
|
||||
League of Legends and Riot Games are trademarks or registered
|
||||
trademarks of Riot Games, Inc. League of Legends © Riot Games, Inc.
|
||||
© 2026 LOLYMPUS. LOLYMPUS is not endorsed by Riot Games and does not
|
||||
reflect the views or opinions of Riot Games or anyone officially
|
||||
involved in producing or managing League of Legends. League of Legends
|
||||
and Riot Games are trademarks or registered trademarks of Riot Games,
|
||||
Inc. League of Legends © Riot Games, Inc.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
@@ -156,12 +157,12 @@ function App() {
|
||||
path="/match/:id/game/:gameNumber"
|
||||
element={<MatchGameDetailPage />}
|
||||
/>
|
||||
<Route
|
||||
path="/match/:id/team/:teamIndex"
|
||||
element={<MatchTeamProgressPage />}
|
||||
/>
|
||||
<Route path="/match/:id/team" element={<MatchTeamProgressPage />} />
|
||||
<Route path="/match/:id/auction" element={<AuctionPage />} />
|
||||
<Route path="/users/:userId/history" element={<UserHistoryPage />} />
|
||||
<Route
|
||||
path="/users/:userId/history"
|
||||
element={<UserHistoryPage />}
|
||||
/>
|
||||
<Route
|
||||
path="/communities/:cid/internal-stats"
|
||||
element={<CommunityInternalStatsPage />}
|
||||
|
||||
+205
-131
@@ -1,6 +1,16 @@
|
||||
import { InteractionStatus } from '@azure/msal-browser';
|
||||
import { useMsal } from '@azure/msal-react';
|
||||
import { useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query';
|
||||
import type {
|
||||
CompetitionCommandResponse,
|
||||
CompetitionDetailResponse,
|
||||
CreateSeriesAdjudicationRequest,
|
||||
ReverseSeriesResultRequest,
|
||||
SeriesId,
|
||||
SeriesReversalPreviewRequest,
|
||||
SeriesReversalPreviewResponse,
|
||||
TeamCompetitionViewResponse,
|
||||
} from '@lolympus/contracts';
|
||||
import { DEFAULT_COMMUNITY_ID, useAuthUserId } from '../config';
|
||||
import { apiFetch } from '../lib/api';
|
||||
import {
|
||||
@@ -41,7 +51,6 @@ import type {
|
||||
RebuildLegacyMatchesResponse,
|
||||
TournamentCodeBulkUploadResponse,
|
||||
TournamentCodeListResponse,
|
||||
TournamentCodeSlotView,
|
||||
TournamentCodeState,
|
||||
TournamentCodeStatsResponse,
|
||||
TournamentCodeUploadItem,
|
||||
@@ -83,7 +92,8 @@ function createMatchesPath(
|
||||
if (options.limit) searchParams.set('limit', String(options.limit));
|
||||
if (options.page) searchParams.set('page', String(options.page));
|
||||
if (options.offset) searchParams.set('offset', String(options.offset));
|
||||
if (options.scheduledFrom) searchParams.set('scheduledFrom', options.scheduledFrom);
|
||||
if (options.scheduledFrom)
|
||||
searchParams.set('scheduledFrom', options.scheduledFrom);
|
||||
if (options.scheduledTo) searchParams.set('scheduledTo', options.scheduledTo);
|
||||
if (options.sort) searchParams.set('sort', options.sort);
|
||||
|
||||
@@ -152,7 +162,10 @@ export function useMatchesPage(
|
||||
});
|
||||
}
|
||||
|
||||
export function useMatch(matchId: string | undefined, communityId = DEFAULT_COMMUNITY_ID) {
|
||||
export function useMatch(
|
||||
matchId: string | undefined,
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: ['match', communityId, matchId ?? null],
|
||||
queryFn: () =>
|
||||
@@ -164,6 +177,126 @@ export function useMatch(matchId: string | undefined, communityId = DEFAULT_COMM
|
||||
});
|
||||
}
|
||||
|
||||
export function useCompetition(
|
||||
matchId: string | undefined,
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
enabled = true,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: ['competition', communityId, matchId ?? null],
|
||||
queryFn: () =>
|
||||
apiFetch<CompetitionDetailResponse>(
|
||||
`/communities/${communityId}/matches/${matchId}/competition`,
|
||||
{
|
||||
auth: 'none',
|
||||
},
|
||||
),
|
||||
enabled: enabled && Boolean(communityId && matchId),
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
export function useTeamCompetition(
|
||||
matchId: string | undefined,
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: ['competition-team', communityId, matchId ?? null],
|
||||
queryFn: () =>
|
||||
apiFetch<TeamCompetitionViewResponse>(
|
||||
`/communities/${communityId}/matches/${matchId}/competition/team`,
|
||||
),
|
||||
enabled: Boolean(communityId && matchId),
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
type CompetitionMutationScope = {
|
||||
matchId: string;
|
||||
seriesId: SeriesId;
|
||||
revision: number;
|
||||
};
|
||||
|
||||
type IdempotentCompetitionMutationScope = CompetitionMutationScope & {
|
||||
idempotencyKey: string;
|
||||
};
|
||||
|
||||
function competitionCommandHeaders(revision: number, idempotencyKey?: string) {
|
||||
return {
|
||||
'If-Match': `"${revision}"`,
|
||||
...(idempotencyKey ? { 'Idempotency-Key': idempotencyKey } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
export function useAdjudicateCompetitionSeries(
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
) {
|
||||
return useMutation({
|
||||
mutationFn: (
|
||||
params: IdempotentCompetitionMutationScope & {
|
||||
request: CreateSeriesAdjudicationRequest;
|
||||
},
|
||||
) =>
|
||||
apiFetch<CompetitionCommandResponse>(
|
||||
`/communities/${communityId}/matches/${params.matchId}/competition/series/${params.seriesId}/adjudications`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: competitionCommandHeaders(
|
||||
params.revision,
|
||||
params.idempotencyKey,
|
||||
),
|
||||
body: JSON.stringify(params.request),
|
||||
},
|
||||
),
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
export function usePreviewCompetitionSeriesReversal(
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
) {
|
||||
return useMutation({
|
||||
mutationFn: (
|
||||
params: CompetitionMutationScope & {
|
||||
request: SeriesReversalPreviewRequest;
|
||||
},
|
||||
) =>
|
||||
apiFetch<SeriesReversalPreviewResponse>(
|
||||
`/communities/${communityId}/matches/${params.matchId}/competition/series/${params.seriesId}/reversal-preview`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: competitionCommandHeaders(params.revision),
|
||||
body: JSON.stringify(params.request),
|
||||
},
|
||||
),
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
export function useReverseCompetitionSeries(
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
) {
|
||||
return useMutation({
|
||||
mutationFn: (
|
||||
params: IdempotentCompetitionMutationScope & {
|
||||
request: ReverseSeriesResultRequest;
|
||||
},
|
||||
) =>
|
||||
apiFetch<CompetitionCommandResponse>(
|
||||
`/communities/${communityId}/matches/${params.matchId}/competition/series/${params.seriesId}/reverse`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: competitionCommandHeaders(
|
||||
params.revision,
|
||||
params.idempotencyKey,
|
||||
),
|
||||
body: JSON.stringify(params.request),
|
||||
},
|
||||
),
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCommunityUserSearch(
|
||||
query: string,
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
@@ -302,7 +435,13 @@ export function useCreateMatch(communityId = DEFAULT_COMMUNITY_ID) {
|
||||
|
||||
export function useUpdateMatch(communityId = DEFAULT_COMMUNITY_ID) {
|
||||
return useMutation({
|
||||
mutationFn: ({ matchId, body }: { matchId: string; body: Partial<MatchMutationRequest> }) =>
|
||||
mutationFn: ({
|
||||
matchId,
|
||||
body,
|
||||
}: {
|
||||
matchId: string;
|
||||
body: Partial<MatchMutationRequest>;
|
||||
}) =>
|
||||
apiFetch<ApiMatch>(`/communities/${communityId}/matches/${matchId}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(body),
|
||||
@@ -310,101 +449,6 @@ export function useUpdateMatch(communityId = DEFAULT_COMMUNITY_ID) {
|
||||
});
|
||||
}
|
||||
|
||||
export function useReshuffleDoubleEliminationSeeds(
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
) {
|
||||
return useMutation({
|
||||
mutationFn: (matchId: string) =>
|
||||
apiFetch<ApiMatch>(
|
||||
`/communities/${communityId}/matches/${matchId}/double-elimination/seeds/reshuffle`,
|
||||
{ method: 'POST' },
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
export function useSwapDoubleEliminationSeeds(
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
) {
|
||||
return useMutation({
|
||||
mutationFn: (params: {
|
||||
matchId: string;
|
||||
leftSeedNumber: number;
|
||||
rightSeedNumber: number;
|
||||
}) =>
|
||||
apiFetch<ApiMatch>(
|
||||
`/communities/${communityId}/matches/${params.matchId}/double-elimination/seeds/swap`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
leftSeedNumber: params.leftSeedNumber,
|
||||
rightSeedNumber: params.rightSeedNumber,
|
||||
}),
|
||||
},
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
export function useApplyDoubleEliminationWalkover(
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
) {
|
||||
return useMutation({
|
||||
mutationFn: (params: {
|
||||
matchId: string;
|
||||
bracketMatchId: string;
|
||||
winnerTeamIndex: number;
|
||||
reason?: string;
|
||||
}) =>
|
||||
apiFetch<ApiMatch>(
|
||||
`/communities/${communityId}/matches/${params.matchId}/double-elimination/bracket-matches/${params.bracketMatchId}/walkover`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
winnerTeamIndex: params.winnerTeamIndex,
|
||||
reason: params.reason,
|
||||
}),
|
||||
},
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
export function useCancelDoubleEliminationWalkover(
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
) {
|
||||
return useMutation({
|
||||
mutationFn: (params: {
|
||||
matchId: string;
|
||||
bracketMatchId: string;
|
||||
reason?: string;
|
||||
}) =>
|
||||
apiFetch<ApiMatch>(
|
||||
`/communities/${communityId}/matches/${params.matchId}/double-elimination/bracket-matches/${params.bracketMatchId}/walkover/cancel`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ reason: params.reason }),
|
||||
},
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
export function useCancelDoubleEliminationRiotResult(
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
) {
|
||||
return useMutation({
|
||||
mutationFn: (params: {
|
||||
matchId: string;
|
||||
bracketMatchId: string;
|
||||
reason?: string;
|
||||
}) =>
|
||||
apiFetch<ApiMatch>(
|
||||
`/communities/${communityId}/matches/${params.matchId}/double-elimination/bracket-matches/${params.bracketMatchId}/result/cancel`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ reason: params.reason }),
|
||||
},
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
function createUserHistoryPath(
|
||||
communityId: string,
|
||||
userId: string,
|
||||
@@ -416,7 +460,8 @@ function createUserHistoryPath(
|
||||
if (filters.queueGroup) searchParams.set('queueGroup', filters.queueGroup);
|
||||
if (filters.rank) searchParams.set('rank', filters.rank);
|
||||
if (filters.seasonId) searchParams.set('seasonId', filters.seasonId);
|
||||
if (filters.championId) searchParams.set('championId', String(filters.championId));
|
||||
if (filters.championId)
|
||||
searchParams.set('championId', String(filters.championId));
|
||||
for (const [key, value] of Object.entries(extra)) {
|
||||
if (value !== null && value !== undefined && value !== '') {
|
||||
searchParams.set(key, String(value));
|
||||
@@ -461,8 +506,15 @@ export function useChampionStats(
|
||||
],
|
||||
queryFn: () =>
|
||||
apiFetch<ApiChampionStatsResponse>(
|
||||
createUserHistoryPath(communityId, userId ?? '', 'champion-stats', filters),
|
||||
{ auth: 'none' },
|
||||
createUserHistoryPath(
|
||||
communityId,
|
||||
userId ?? '',
|
||||
'champion-stats',
|
||||
filters,
|
||||
),
|
||||
{
|
||||
auth: 'none',
|
||||
},
|
||||
),
|
||||
enabled: Boolean(communityId && userId && enabled),
|
||||
});
|
||||
@@ -486,8 +538,15 @@ export function useRecentSummary(
|
||||
],
|
||||
queryFn: () =>
|
||||
apiFetch<ApiRecentSummaryResponse>(
|
||||
createUserHistoryPath(communityId, userId ?? '', 'recent-summary', filters),
|
||||
{ auth: 'none' },
|
||||
createUserHistoryPath(
|
||||
communityId,
|
||||
userId ?? '',
|
||||
'recent-summary',
|
||||
filters,
|
||||
),
|
||||
{
|
||||
auth: 'none',
|
||||
},
|
||||
),
|
||||
enabled: Boolean(communityId && userId && enabled),
|
||||
});
|
||||
@@ -511,10 +570,16 @@ export function useRecentMatches(
|
||||
],
|
||||
queryFn: ({ pageParam }) =>
|
||||
apiFetch<ApiRecentMatchesResponse>(
|
||||
createUserHistoryPath(communityId, userId ?? '', 'recent-matches', filters, {
|
||||
cursor: pageParam,
|
||||
limit: 10,
|
||||
}),
|
||||
createUserHistoryPath(
|
||||
communityId,
|
||||
userId ?? '',
|
||||
'recent-matches',
|
||||
filters,
|
||||
{
|
||||
cursor: pageParam,
|
||||
limit: 10,
|
||||
},
|
||||
),
|
||||
{ auth: 'none' },
|
||||
),
|
||||
initialPageParam: null as number | null,
|
||||
@@ -533,7 +598,8 @@ function createCommunityInternalStatsPath(
|
||||
if (filters.seasonId) searchParams.set('seasonId', filters.seasonId);
|
||||
if (filters.from) searchParams.set('from', filters.from);
|
||||
if (filters.to) searchParams.set('to', filters.to);
|
||||
if (filters.championId) searchParams.set('championId', String(filters.championId));
|
||||
if (filters.championId)
|
||||
searchParams.set('championId', String(filters.championId));
|
||||
if (filters.limit) searchParams.set('limit', String(filters.limit));
|
||||
for (const [key, value] of Object.entries(extra)) {
|
||||
if (value !== null && value !== undefined && value !== '') {
|
||||
@@ -590,7 +656,9 @@ export function useCommunityLeaderboard(
|
||||
queryFn: () =>
|
||||
apiFetch<ApiLeaderboardResponse>(
|
||||
createCommunityInternalStatsPath(communityId, 'leaderboard', filters),
|
||||
{ auth: 'none' },
|
||||
{
|
||||
auth: 'none',
|
||||
},
|
||||
),
|
||||
enabled: Boolean(communityId && enabled),
|
||||
});
|
||||
@@ -613,7 +681,9 @@ export function useTeamInsights(
|
||||
queryFn: () =>
|
||||
apiFetch<ApiTeamInsightsResponse>(
|
||||
createCommunityInternalStatsPath(communityId, 'team-insights', filters),
|
||||
{ auth: 'none' },
|
||||
{
|
||||
auth: 'none',
|
||||
},
|
||||
),
|
||||
enabled: Boolean(communityId && enabled),
|
||||
});
|
||||
@@ -628,7 +698,9 @@ export function useInternalMatchDetail(
|
||||
queryFn: () =>
|
||||
apiFetch<ApiInternalMatchDetailResponse>(
|
||||
`/communities/${communityId}/internal-stats/match/${matchId}`,
|
||||
{ auth: 'none' },
|
||||
{
|
||||
auth: 'none',
|
||||
},
|
||||
),
|
||||
enabled: Boolean(communityId && matchId),
|
||||
retry: false,
|
||||
@@ -651,10 +723,16 @@ export function useUserInternalHistory(
|
||||
],
|
||||
queryFn: ({ pageParam }) =>
|
||||
apiFetch<ApiUserInternalHistoryResponse>(
|
||||
createUserHistoryPath(communityId, userId ?? '', 'internal-history', filters, {
|
||||
cursor: pageParam,
|
||||
limit: 10,
|
||||
}),
|
||||
createUserHistoryPath(
|
||||
communityId,
|
||||
userId ?? '',
|
||||
'internal-history',
|
||||
filters,
|
||||
{
|
||||
cursor: pageParam,
|
||||
limit: 10,
|
||||
},
|
||||
),
|
||||
{ auth: 'none' },
|
||||
),
|
||||
initialPageParam: null as number | null,
|
||||
@@ -740,7 +818,9 @@ export function useTournamentCodes(
|
||||
});
|
||||
}
|
||||
|
||||
export function useBulkUploadTournamentCodes(communityId = DEFAULT_COMMUNITY_ID) {
|
||||
export function useBulkUploadTournamentCodes(
|
||||
communityId = DEFAULT_COMMUNITY_ID,
|
||||
) {
|
||||
return useMutation({
|
||||
mutationFn: (codes: TournamentCodeUploadItem[]) =>
|
||||
apiFetch<TournamentCodeBulkUploadResponse>(
|
||||
@@ -772,16 +852,6 @@ export function useDeleteTournamentCode(communityId = DEFAULT_COMMUNITY_ID) {
|
||||
});
|
||||
}
|
||||
|
||||
export function useReplaceTournamentCode(communityId = DEFAULT_COMMUNITY_ID) {
|
||||
return useMutation({
|
||||
mutationFn: (params: { matchId: string; gameNumber: number }) =>
|
||||
apiFetch<TournamentCodeSlotView>(
|
||||
`/communities/${communityId}/tournament-codes/matches/${params.matchId}/games/${params.gameNumber}/replace`,
|
||||
{ method: 'POST' },
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
export function usePollTournamentResult(communityId = DEFAULT_COMMUNITY_ID) {
|
||||
return useMutation({
|
||||
mutationFn: (matchId: string) =>
|
||||
@@ -791,9 +861,12 @@ export function usePollTournamentResult(communityId = DEFAULT_COMMUNITY_ID) {
|
||||
priority: 'high' | 'low';
|
||||
attempt: number;
|
||||
expandedToAllPuuids: boolean;
|
||||
}>(`/communities/${communityId}/matches/${matchId}/poll-tournament-result`, {
|
||||
method: 'POST',
|
||||
}),
|
||||
}>(
|
||||
`/communities/${communityId}/matches/${matchId}/poll-tournament-result`,
|
||||
{
|
||||
method: 'POST',
|
||||
},
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -848,7 +921,8 @@ export function useLegacyImportMembers(
|
||||
],
|
||||
queryFn: () => {
|
||||
const searchParams = new URLSearchParams();
|
||||
if (options.windowStart) searchParams.set('windowStart', options.windowStart);
|
||||
if (options.windowStart)
|
||||
searchParams.set('windowStart', options.windowStart);
|
||||
if (options.windowEnd) searchParams.set('windowEnd', options.windowEnd);
|
||||
const queryString = searchParams.toString();
|
||||
return apiFetch<LegacyImportMembersResponse>(
|
||||
|
||||
+18
-63
@@ -9,11 +9,9 @@ import type {
|
||||
ApiRiotRecentStatsSummary,
|
||||
ApiTierHistoryEntry,
|
||||
ApiTierInfo,
|
||||
ApiDoubleEliminationBracket,
|
||||
MatchStatus,
|
||||
Position,
|
||||
RiotLane,
|
||||
TournamentCodeSlotView,
|
||||
} from "./types";
|
||||
import { POSITION_ORDER, teamIndexLabel } from "../lib/league";
|
||||
|
||||
@@ -52,40 +50,9 @@ export interface MatchDetailView {
|
||||
description: string;
|
||||
map: string;
|
||||
maxParticipants: number;
|
||||
gameCount: number;
|
||||
gameMode: ApiMatch["gameMode"];
|
||||
doubleElimination?: ApiDoubleEliminationBracket;
|
||||
tournamentCodes: TournamentCodeSlotView[];
|
||||
joined: boolean;
|
||||
participants: ParticipantView[];
|
||||
teams: TeamView[];
|
||||
result?: {
|
||||
winner?: string;
|
||||
winnerTeamIndex?: number;
|
||||
riotMatchIds: string[];
|
||||
games: Array<{
|
||||
gameNumber: number;
|
||||
bracketMatchId?: string;
|
||||
riotMatchId: string;
|
||||
blueTeamIndex: number;
|
||||
redTeamIndex: number;
|
||||
winnerTeamIndex: number;
|
||||
winnerSide: "blue" | "red";
|
||||
gameCreation: number;
|
||||
gameDuration: number;
|
||||
participants: Array<{
|
||||
userId: string;
|
||||
teamIndex: number;
|
||||
side: "blue" | "red";
|
||||
championId: number;
|
||||
kills: number;
|
||||
deaths: number;
|
||||
assists: number;
|
||||
win: boolean;
|
||||
}>;
|
||||
}>;
|
||||
seriesResults: NonNullable<ApiMatch["result"]>["seriesResults"];
|
||||
};
|
||||
prizes: string[];
|
||||
notices: string[];
|
||||
schedule: { time: string; label: string }[];
|
||||
@@ -434,7 +401,9 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
|
||||
captainUserId: team.captainUserId,
|
||||
captainName:
|
||||
captain?.summonerName ??
|
||||
(team.captainUserId ? `User ${team.captainUserId.slice(-4)}` : undefined),
|
||||
(team.captainUserId
|
||||
? `User ${team.captainUserId.slice(-4)}`
|
||||
: undefined),
|
||||
captainTag: captain?.tag,
|
||||
participants: team.members.map((member) => {
|
||||
const participant =
|
||||
@@ -450,10 +419,6 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
|
||||
};
|
||||
});
|
||||
|
||||
const winnerTeam = match.result?.winnerTeamIndex
|
||||
? teams.find((team) => team.teamIndex === match.result?.winnerTeamIndex)
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
id: match._id,
|
||||
title: match.title,
|
||||
@@ -463,24 +428,9 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
|
||||
description: match.description,
|
||||
map: mapIdToLabel(match.mapId),
|
||||
maxParticipants: match.maxParticipants,
|
||||
gameCount: match.gameCount ?? 3,
|
||||
gameMode: match.gameMode ?? "pair",
|
||||
doubleElimination: match.doubleElimination,
|
||||
tournamentCodes: match.tournamentCodes ?? [],
|
||||
joined: Boolean(match.joined),
|
||||
participants,
|
||||
teams,
|
||||
result: match.result
|
||||
? {
|
||||
winner: match.result.winnerTeamIndex ? winnerTeam?.name : undefined,
|
||||
winnerTeamIndex: match.result.winnerTeamIndex,
|
||||
riotMatchIds: match.result.riotMatchIds,
|
||||
games: [...(match.result.games ?? [])].sort(
|
||||
(left, right) => left.gameNumber - right.gameNumber,
|
||||
),
|
||||
seriesResults: match.result.seriesResults ?? [],
|
||||
}
|
||||
: undefined,
|
||||
prizes: match.prizes,
|
||||
notices: match.notices,
|
||||
schedule: match.schedule,
|
||||
@@ -523,9 +473,9 @@ export function mapApiAuctionToAuctionState(
|
||||
const auctionPlayerLookup = new Map(
|
||||
auctionOrder.map((player) => [player.userId, player]),
|
||||
);
|
||||
const teams = rawAuctionTeams.map(normalizeApiAuctionTeam).sort(
|
||||
(left, right) => left.teamIndex - right.teamIndex,
|
||||
);
|
||||
const teams = rawAuctionTeams
|
||||
.map(normalizeApiAuctionTeam)
|
||||
.sort((left, right) => left.teamIndex - right.teamIndex);
|
||||
|
||||
const totalPlayers = auctionOrder.length;
|
||||
const currentPlayer =
|
||||
@@ -535,7 +485,9 @@ export function mapApiAuctionToAuctionState(
|
||||
rawAuctionOrder[currentAuctionPlayerOrderIndex]?.userId ?? "",
|
||||
) ?? null);
|
||||
const currentPlayerIndex =
|
||||
auction.phase === "complete" ? totalPlayers : currentAuctionPlayerOrderIndex;
|
||||
auction.phase === "complete"
|
||||
? totalPlayers
|
||||
: currentAuctionPlayerOrderIndex;
|
||||
const remainingMs = currentBidRoundDeadlineTimestampMS
|
||||
? Math.max(0, currentBidRoundDeadlineTimestampMS - now.getTime())
|
||||
: 0;
|
||||
@@ -557,11 +509,12 @@ export function mapApiAuctionToAuctionState(
|
||||
auctionRound: auction.currentAuctionRound ?? auction.auctionRound ?? 1,
|
||||
bids: normalizeApiAuctionBids(auction),
|
||||
currentBid,
|
||||
currentBidder: currentBidderTeamIndex !== undefined
|
||||
? {
|
||||
teamIndex: currentBidderTeamIndex,
|
||||
}
|
||||
: null,
|
||||
currentBidder:
|
||||
currentBidderTeamIndex !== undefined
|
||||
? {
|
||||
teamIndex: currentBidderTeamIndex,
|
||||
}
|
||||
: null,
|
||||
remainingMs,
|
||||
timer,
|
||||
maxTimer: maximumBidRoundDurationSeconds,
|
||||
@@ -574,7 +527,9 @@ export function mapApiAuctionToAuctionState(
|
||||
|
||||
type NormalizedApiAuctionTeam = ApiAuctionTeam & { points: number };
|
||||
|
||||
function normalizeApiAuctionTeam(team: ApiAuctionTeam): NormalizedApiAuctionTeam {
|
||||
function normalizeApiAuctionTeam(
|
||||
team: ApiAuctionTeam,
|
||||
): NormalizedApiAuctionTeam {
|
||||
return {
|
||||
...team,
|
||||
points: team.points ?? team.remainingBidPointAmount ?? 0,
|
||||
|
||||
+1
-122
@@ -3,7 +3,6 @@ export type RiotLane = 'TOP' | 'JUNGLE' | 'MIDDLE' | 'BOTTOM' | 'UTILITY';
|
||||
export type TeamSide = 'blue' | 'red';
|
||||
export type MatchGameMode =
|
||||
| 'pair'
|
||||
| 'bracket'
|
||||
| 'round-robin'
|
||||
| 'double-elimination';
|
||||
export type MatchStatus =
|
||||
@@ -143,25 +142,6 @@ export type TournamentCodeState =
|
||||
| 'released'
|
||||
| 'voided';
|
||||
|
||||
export type TournamentCodeSlotState = TournamentCodeState | 'pending';
|
||||
|
||||
export interface TournamentCodeSlotView {
|
||||
gameNumber: number;
|
||||
seriesGameNumber?: number;
|
||||
seriesGameCount?: number;
|
||||
seriesRequiredWins?: number;
|
||||
bracketMatchId?: string;
|
||||
bracketSide?: string;
|
||||
roundNumber?: number;
|
||||
matchNumber?: number;
|
||||
teamAIndex?: number;
|
||||
teamBIndex?: number;
|
||||
code: string | null;
|
||||
expiresAt: string | null;
|
||||
state: TournamentCodeSlotState;
|
||||
riotMatchId: string | null;
|
||||
}
|
||||
|
||||
export interface ApiMatchParticipant {
|
||||
userId: string;
|
||||
puuid?: string;
|
||||
@@ -187,109 +167,11 @@ export interface ApiMatchTeam {
|
||||
members: ApiMatchTeamMember[];
|
||||
}
|
||||
|
||||
export interface ApiMatchGameResultParticipant {
|
||||
userId: string;
|
||||
teamIndex: number;
|
||||
side: TeamSide;
|
||||
championId: number;
|
||||
kills: number;
|
||||
deaths: number;
|
||||
assists: number;
|
||||
win: boolean;
|
||||
}
|
||||
|
||||
export interface ApiMatchGameResult {
|
||||
gameNumber: number;
|
||||
bracketMatchId?: string;
|
||||
riotMatchId: string;
|
||||
blueTeamIndex: number;
|
||||
redTeamIndex: number;
|
||||
winnerTeamIndex: number;
|
||||
winnerSide: TeamSide;
|
||||
gameCreation: number;
|
||||
gameDuration: number;
|
||||
participants: ApiMatchGameResultParticipant[];
|
||||
}
|
||||
|
||||
export interface ApiMatchResult {
|
||||
winnerTeamIndex?: number;
|
||||
mvpUserId?: string;
|
||||
riotMatchIds: string[];
|
||||
games: ApiMatchGameResult[];
|
||||
seriesResults?: Array<{
|
||||
bracketMatchId?: string;
|
||||
teamAIndex: number;
|
||||
teamBIndex: number;
|
||||
teamAWins: number;
|
||||
teamBWins: number;
|
||||
winnerTeamIndex?: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface ApiMatchScheduleItem {
|
||||
time: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface ApiMatchGameAssignment {
|
||||
gameNumber: number;
|
||||
roundNumber?: number;
|
||||
teamAIndex: number;
|
||||
teamBIndex: number;
|
||||
}
|
||||
|
||||
export interface ApiDoubleEliminationSeed {
|
||||
seedNumber: number;
|
||||
teamIndex: number;
|
||||
}
|
||||
|
||||
export interface ApiDoubleEliminationBracketDestination {
|
||||
bracketMatchId: string;
|
||||
position: 'A' | 'B';
|
||||
}
|
||||
|
||||
export interface ApiDoubleEliminationWalkover {
|
||||
winnerTeamIndex: number;
|
||||
reason?: string;
|
||||
awardedAt: string;
|
||||
cancelledAt?: string;
|
||||
cancelReason?: string;
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
export interface ApiDoubleEliminationBracketMatch {
|
||||
bracketMatchId: string;
|
||||
gameNumber: number;
|
||||
gameCount: number;
|
||||
requiredWins: number;
|
||||
bracketSide: 'winner' | 'loser' | 'grand-final' | 'reset-final';
|
||||
roundNumber: number;
|
||||
matchNumber: number;
|
||||
state: 'pending' | 'ready' | 'completed';
|
||||
teamAIndex?: number;
|
||||
teamBIndex?: number;
|
||||
winnerAdvancesTo?: ApiDoubleEliminationBracketDestination;
|
||||
loserAdvancesTo?: ApiDoubleEliminationBracketDestination;
|
||||
winnerTeamIndex?: number;
|
||||
loserTeamIndex?: number;
|
||||
completedBy?: 'riot-result' | 'walkover';
|
||||
completedAt?: string;
|
||||
walkover?: ApiDoubleEliminationWalkover;
|
||||
}
|
||||
|
||||
export interface ApiDoubleEliminationBracket {
|
||||
teamCount: 4 | 8;
|
||||
resetFinalEnabled: boolean;
|
||||
resetFinalCreated: boolean;
|
||||
seeds: ApiDoubleEliminationSeed[];
|
||||
bracketMatches: ApiDoubleEliminationBracketMatch[];
|
||||
placements: {
|
||||
firstTeamIndex?: number;
|
||||
secondTeamIndex?: number;
|
||||
thirdTeamIndex?: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ManualTournamentResultCollectResponse {
|
||||
scanned: number;
|
||||
matched: number;
|
||||
@@ -311,13 +193,10 @@ export interface ApiMatch {
|
||||
gameCount: number;
|
||||
gameMode: MatchGameMode;
|
||||
roundRobinMaxRounds?: number;
|
||||
gameSchedule?: ApiMatchGameAssignment[];
|
||||
doubleElimination?: ApiDoubleEliminationBracket;
|
||||
tournamentCodes?: TournamentCodeSlotView[];
|
||||
doubleEliminationResetFinalEnabled?: boolean;
|
||||
hostUserId?: string;
|
||||
participants: ApiMatchParticipant[];
|
||||
teams: ApiMatchTeam[];
|
||||
result?: ApiMatchResult;
|
||||
prizes: string[];
|
||||
notices: string[];
|
||||
schedule: ApiMatchScheduleItem[];
|
||||
|
||||
@@ -0,0 +1,763 @@
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import type {
|
||||
CompetitionCommandResponse,
|
||||
CompetitionDetailResponse,
|
||||
SeriesAdjudicationDecision,
|
||||
SeriesProjection,
|
||||
SeriesReversalMode,
|
||||
SeriesReversalPreviewResponse,
|
||||
TeamId,
|
||||
} from "@lolympus/contracts";
|
||||
import {
|
||||
useAdjudicateCompetitionSeries,
|
||||
usePreviewCompetitionSeriesReversal,
|
||||
useReverseCompetitionSeries,
|
||||
} from "../../api/hooks";
|
||||
import { ApiError } from "../../lib/api";
|
||||
|
||||
type AdjudicationType = SeriesAdjudicationDecision["type"];
|
||||
|
||||
const ADJUDICATION_LABELS: Record<AdjudicationType, string> = {
|
||||
walkover: "부전승",
|
||||
forfeit: "몰수패",
|
||||
administrative: "운영자 판정",
|
||||
"administrative-draw": "운영자 무승부",
|
||||
};
|
||||
|
||||
export function CompetitionAdminControls({
|
||||
competition,
|
||||
communityId,
|
||||
canManage,
|
||||
}: {
|
||||
competition: CompetitionDetailResponse;
|
||||
communityId: string;
|
||||
canManage: boolean;
|
||||
}) {
|
||||
const queryClient = useQueryClient();
|
||||
const series = competition.projection.series;
|
||||
const defaultSeries =
|
||||
series.find(
|
||||
(item) => item.status === "ready" || item.status === "in-progress",
|
||||
) ??
|
||||
series.find((item) => item.status === "completed") ??
|
||||
series[0];
|
||||
const [selectedSeriesId, setSelectedSeriesId] = useState<string>(
|
||||
defaultSeries?.seriesId ?? "",
|
||||
);
|
||||
const [adjudicationType, setAdjudicationType] =
|
||||
useState<AdjudicationType>("walkover");
|
||||
const [winnerTeamId, setWinnerTeamId] = useState<string>("");
|
||||
const [adjudicationReason, setAdjudicationReason] = useState("");
|
||||
const [reversalMode, setReversalMode] =
|
||||
useState<SeriesReversalMode>("strict");
|
||||
const [reversalReason, setReversalReason] = useState("");
|
||||
const [reversalPreview, setReversalPreview] =
|
||||
useState<SeriesReversalPreviewResponse | null>(null);
|
||||
const [impactConfirmed, setImpactConfirmed] = useState(false);
|
||||
const [notice, setNotice] = useState<string | null>(null);
|
||||
const adjudicationIdempotencyKeyRef = useRef<string | null>(null);
|
||||
const reversalIdempotencyKeyRef = useRef<string | null>(null);
|
||||
const adjudicationMutation = useAdjudicateCompetitionSeries(communityId);
|
||||
const previewMutation = usePreviewCompetitionSeriesReversal(communityId);
|
||||
const reversalMutation = useReverseCompetitionSeries(communityId);
|
||||
|
||||
const selectedSeries =
|
||||
series.find((item) => item.seriesId === selectedSeriesId) ?? defaultSeries;
|
||||
const teamById = useMemo(
|
||||
() => new Map(competition.teams.map((team) => [team.teamId, team])),
|
||||
[competition.teams],
|
||||
);
|
||||
const eligibleTeams = selectedSeries
|
||||
? selectedSeries.entries.flatMap((entry) =>
|
||||
entry.teamId ? [teamById.get(entry.teamId)] : [],
|
||||
)
|
||||
: [];
|
||||
const selectedSeriesGames = selectedSeries
|
||||
? competition.projection.games.filter(
|
||||
(game) => game.seriesId === selectedSeries.seriesId,
|
||||
)
|
||||
: [];
|
||||
const drawAllowed = Boolean(
|
||||
selectedSeries?.rule.type === "fixed-games" &&
|
||||
selectedSeries.rule.drawPolicy === "allow",
|
||||
);
|
||||
const canAdjudicate = Boolean(
|
||||
selectedSeries &&
|
||||
(selectedSeries.status === "ready" ||
|
||||
selectedSeries.status === "in-progress"),
|
||||
);
|
||||
const canReverse = selectedSeries?.status === "completed";
|
||||
const previewIsCurrent = Boolean(
|
||||
reversalPreview && reversalPreview.sourceRevision === competition.revision,
|
||||
);
|
||||
const effectiveSelectedSeriesId = selectedSeries?.seriesId ?? "";
|
||||
const effectiveWinnerTeamId = eligibleTeams.some(
|
||||
(team) => team?.teamId === winnerTeamId,
|
||||
)
|
||||
? winnerTeamId
|
||||
: (eligibleTeams.find(Boolean)?.teamId ?? "");
|
||||
const effectiveAdjudicationType =
|
||||
adjudicationType === "administrative-draw" && !drawAllowed
|
||||
? "administrative"
|
||||
: adjudicationType === "walkover" && selectedSeriesGames.length > 0
|
||||
? "forfeit"
|
||||
: adjudicationType;
|
||||
|
||||
if (!canManage || series.length === 0) return null;
|
||||
|
||||
async function invalidateCompetitionCaches(
|
||||
response?: CompetitionCommandResponse,
|
||||
) {
|
||||
const matchId = String(competition.matchId);
|
||||
if (response) {
|
||||
queryClient.setQueryData(
|
||||
["competition", communityId, matchId],
|
||||
response.competition,
|
||||
);
|
||||
}
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["competition", communityId, matchId],
|
||||
}),
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["competition-team", communityId, matchId],
|
||||
}),
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["match", communityId, matchId],
|
||||
}),
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["matches", communityId],
|
||||
}),
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["matches-page", communityId],
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
function resetCommandFeedback() {
|
||||
setNotice(null);
|
||||
adjudicationMutation.reset();
|
||||
previewMutation.reset();
|
||||
reversalMutation.reset();
|
||||
}
|
||||
|
||||
function handleSelectedSeriesChange(nextSeriesId: string) {
|
||||
const nextSeries = series.find((item) => item.seriesId === nextSeriesId);
|
||||
const nextHasGames = competition.projection.games.some(
|
||||
(game) => game.seriesId === nextSeries?.seriesId,
|
||||
);
|
||||
setSelectedSeriesId(nextSeriesId);
|
||||
setWinnerTeamId("");
|
||||
setAdjudicationType(nextHasGames ? "forfeit" : "walkover");
|
||||
setAdjudicationReason("");
|
||||
setReversalMode("strict");
|
||||
setReversalReason("");
|
||||
setReversalPreview(null);
|
||||
setImpactConfirmed(false);
|
||||
adjudicationIdempotencyKeyRef.current = null;
|
||||
reversalIdempotencyKeyRef.current = null;
|
||||
resetCommandFeedback();
|
||||
}
|
||||
|
||||
function handleAdjudicationSubmit(event: React.FormEvent) {
|
||||
event.preventDefault();
|
||||
if (!selectedSeries || !canAdjudicate || !adjudicationReason.trim()) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
effectiveAdjudicationType !== "administrative-draw" &&
|
||||
!effectiveWinnerTeamId
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const decision: SeriesAdjudicationDecision =
|
||||
effectiveAdjudicationType === "administrative-draw"
|
||||
? { type: "administrative-draw" }
|
||||
: {
|
||||
type: effectiveAdjudicationType,
|
||||
winnerTeamId: effectiveWinnerTeamId as TeamId,
|
||||
};
|
||||
const idempotencyKey =
|
||||
adjudicationIdempotencyKeyRef.current ??
|
||||
`adjudicate:${selectedSeries.seriesId}:${crypto.randomUUID()}`;
|
||||
adjudicationIdempotencyKeyRef.current = idempotencyKey;
|
||||
resetCommandFeedback();
|
||||
adjudicationMutation.mutate(
|
||||
{
|
||||
matchId: String(competition.matchId),
|
||||
seriesId: selectedSeries.seriesId,
|
||||
revision: competition.revision,
|
||||
idempotencyKey,
|
||||
request: {
|
||||
decision,
|
||||
reason: adjudicationReason.trim(),
|
||||
},
|
||||
},
|
||||
{
|
||||
onSuccess: async (response) => {
|
||||
adjudicationIdempotencyKeyRef.current = null;
|
||||
setNotice("Series 판정을 기록했습니다.");
|
||||
setAdjudicationReason("");
|
||||
await invalidateCompetitionCaches(response);
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function handlePreviewSubmit(event: React.FormEvent) {
|
||||
event.preventDefault();
|
||||
if (!selectedSeries || !canReverse || !reversalReason.trim()) return;
|
||||
|
||||
resetCommandFeedback();
|
||||
setReversalPreview(null);
|
||||
setImpactConfirmed(false);
|
||||
previewMutation.mutate(
|
||||
{
|
||||
matchId: String(competition.matchId),
|
||||
seriesId: selectedSeries.seriesId,
|
||||
revision: competition.revision,
|
||||
request: {
|
||||
mode: reversalMode,
|
||||
reason: reversalReason.trim(),
|
||||
},
|
||||
},
|
||||
{
|
||||
onSuccess: (preview) => {
|
||||
reversalIdempotencyKeyRef.current = null;
|
||||
setReversalPreview(preview);
|
||||
setImpactConfirmed(false);
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function handleReverse() {
|
||||
if (
|
||||
!selectedSeries ||
|
||||
!reversalPreview ||
|
||||
!previewIsCurrent ||
|
||||
!impactConfirmed ||
|
||||
!reversalReason.trim()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const idempotencyKey =
|
||||
reversalIdempotencyKeyRef.current ??
|
||||
`reverse:${selectedSeries.seriesId}:${crypto.randomUUID()}`;
|
||||
reversalIdempotencyKeyRef.current = idempotencyKey;
|
||||
resetCommandFeedback();
|
||||
reversalMutation.mutate(
|
||||
{
|
||||
matchId: String(competition.matchId),
|
||||
seriesId: selectedSeries.seriesId,
|
||||
revision: reversalPreview.sourceRevision,
|
||||
idempotencyKey,
|
||||
request: {
|
||||
mode: reversalMode,
|
||||
reason: reversalReason.trim(),
|
||||
impactHash: reversalPreview.impactHash,
|
||||
},
|
||||
},
|
||||
{
|
||||
onSuccess: async (response) => {
|
||||
reversalIdempotencyKeyRef.current = null;
|
||||
setNotice("Series 결과를 되돌렸습니다.");
|
||||
setReversalPreview(null);
|
||||
setImpactConfirmed(false);
|
||||
setReversalReason("");
|
||||
await invalidateCompetitionCaches(response);
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
const commandError =
|
||||
adjudicationMutation.error ??
|
||||
previewMutation.error ??
|
||||
reversalMutation.error;
|
||||
const commandErrorCode = competitionCommandErrorCode(commandError);
|
||||
const staleCommand =
|
||||
(commandError instanceof ApiError && commandError.status === 412) ||
|
||||
commandErrorCode === "REVERSAL_PREVIEW_STALE";
|
||||
const commandPending =
|
||||
adjudicationMutation.isPending ||
|
||||
previewMutation.isPending ||
|
||||
reversalMutation.isPending;
|
||||
|
||||
return (
|
||||
<section
|
||||
className="mb-6 border border-warning/25 bg-warning/[0.04] p-4"
|
||||
aria-labelledby="competition-admin-heading"
|
||||
>
|
||||
<div className="flex flex-wrap items-start justify-between gap-3 border-b border-warning/20 pb-3">
|
||||
<div>
|
||||
<p className="text-[11px] font-bold uppercase tracking-wider text-warning">
|
||||
Owner / Admin
|
||||
</p>
|
||||
<h2
|
||||
id="competition-admin-heading"
|
||||
className="mt-1 text-base font-bold"
|
||||
>
|
||||
공식 결과 관리
|
||||
</h2>
|
||||
</div>
|
||||
<span className="border border-base-content/10 px-2 py-1 font-mono text-xs text-base-content/45">
|
||||
revision {competition.revision}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<label className="mt-4 block text-xs font-bold text-base-content/55">
|
||||
Series
|
||||
<select
|
||||
className="mt-1.5 h-10 w-full border border-base-content/15 bg-base-100 px-3 text-sm focus:border-warning/50 focus:outline-none"
|
||||
value={effectiveSelectedSeriesId}
|
||||
disabled={commandPending}
|
||||
onChange={(event) => handleSelectedSeriesChange(event.target.value)}
|
||||
>
|
||||
{series.map((item) => (
|
||||
<option key={item.seriesId} value={item.seriesId}>
|
||||
{seriesLabel(item)} · {seriesStatusLabel(item.status)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
{notice && (
|
||||
<p
|
||||
className="mt-3 border border-success/20 bg-success/10 px-3 py-2 text-sm text-success"
|
||||
role="status"
|
||||
>
|
||||
{notice}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{commandError && (
|
||||
<div
|
||||
className="mt-3 border border-error/20 bg-error/10 px-3 py-2 text-sm text-error"
|
||||
role="alert"
|
||||
>
|
||||
<p>{competitionCommandErrorMessage(commandError)}</p>
|
||||
{staleCommand && (
|
||||
<button
|
||||
type="button"
|
||||
className="mt-2 border border-error/25 px-2 py-1 text-xs font-bold hover:bg-error/10"
|
||||
onClick={() => {
|
||||
adjudicationIdempotencyKeyRef.current = null;
|
||||
reversalIdempotencyKeyRef.current = null;
|
||||
resetCommandFeedback();
|
||||
void invalidateCompetitionCaches();
|
||||
}}
|
||||
>
|
||||
최신 revision 불러오기
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{canAdjudicate ? (
|
||||
<form className="mt-4 space-y-3" onSubmit={handleAdjudicationSubmit}>
|
||||
<h3 className="text-sm font-bold">Series 판정</h3>
|
||||
<div className="grid gap-3 sm:grid-cols-2">
|
||||
<label className="text-xs font-bold text-base-content/50">
|
||||
판정 유형
|
||||
<select
|
||||
className="mt-1.5 h-10 w-full border border-base-content/15 bg-base-100 px-3 text-sm focus:border-warning/50 focus:outline-none"
|
||||
value={effectiveAdjudicationType}
|
||||
disabled={adjudicationMutation.isPending}
|
||||
onChange={(event) => {
|
||||
resetCommandFeedback();
|
||||
adjudicationIdempotencyKeyRef.current = null;
|
||||
setAdjudicationType(event.target.value as AdjudicationType);
|
||||
}}
|
||||
>
|
||||
<option
|
||||
value="walkover"
|
||||
disabled={selectedSeriesGames.length > 0}
|
||||
>
|
||||
{ADJUDICATION_LABELS.walkover}
|
||||
</option>
|
||||
<option value="forfeit">{ADJUDICATION_LABELS.forfeit}</option>
|
||||
<option value="administrative">
|
||||
{ADJUDICATION_LABELS.administrative}
|
||||
</option>
|
||||
{drawAllowed && (
|
||||
<option value="administrative-draw">
|
||||
{ADJUDICATION_LABELS["administrative-draw"]}
|
||||
</option>
|
||||
)}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
{effectiveAdjudicationType !== "administrative-draw" && (
|
||||
<label className="text-xs font-bold text-base-content/50">
|
||||
승리 팀
|
||||
<select
|
||||
className="mt-1.5 h-10 w-full border border-base-content/15 bg-base-100 px-3 text-sm focus:border-warning/50 focus:outline-none"
|
||||
value={effectiveWinnerTeamId}
|
||||
disabled={adjudicationMutation.isPending}
|
||||
onChange={(event) => {
|
||||
resetCommandFeedback();
|
||||
adjudicationIdempotencyKeyRef.current = null;
|
||||
setWinnerTeamId(event.target.value);
|
||||
}}
|
||||
>
|
||||
{eligibleTeams.map((team) =>
|
||||
team ? (
|
||||
<option key={team.teamId} value={team.teamId}>
|
||||
{team.name}
|
||||
</option>
|
||||
) : null,
|
||||
)}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<label className="block text-xs font-bold text-base-content/50">
|
||||
판정 사유
|
||||
<textarea
|
||||
className="mt-1.5 min-h-24 w-full resize-y border border-base-content/15 bg-base-100 px-3 py-2 text-sm focus:border-warning/50 focus:outline-none"
|
||||
maxLength={2000}
|
||||
value={adjudicationReason}
|
||||
disabled={adjudicationMutation.isPending}
|
||||
onChange={(event) => {
|
||||
resetCommandFeedback();
|
||||
adjudicationIdempotencyKeyRef.current = null;
|
||||
setAdjudicationReason(event.target.value);
|
||||
}}
|
||||
placeholder="감사 로그에 남을 구체적인 사유를 입력하세요."
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
type="submit"
|
||||
className="btn btn-warning btn-sm px-4 text-xs"
|
||||
disabled={
|
||||
adjudicationMutation.isPending ||
|
||||
!adjudicationReason.trim() ||
|
||||
(effectiveAdjudicationType !== "administrative-draw" &&
|
||||
!effectiveWinnerTeamId)
|
||||
}
|
||||
>
|
||||
{adjudicationMutation.isPending ? "기록 중..." : "판정 기록"}
|
||||
</button>
|
||||
</form>
|
||||
) : canReverse && selectedSeries ? (
|
||||
<form className="mt-4 space-y-3" onSubmit={handlePreviewSubmit}>
|
||||
<h3 className="text-sm font-bold">결과 되돌리기</h3>
|
||||
<p className="text-xs leading-5 text-base-content/50">
|
||||
먼저 현재 revision에서 영향을 계산합니다. 실행 시 동일 revision과
|
||||
impact hash가 검증됩니다.
|
||||
</p>
|
||||
<fieldset className="grid gap-2 sm:grid-cols-2">
|
||||
<legend className="mb-1 text-xs font-bold text-base-content/50">
|
||||
되돌리기 범위
|
||||
</legend>
|
||||
{(["strict", "cascade"] as const).map((mode) => (
|
||||
<label
|
||||
key={mode}
|
||||
className="flex cursor-pointer items-start gap-2 border border-base-content/10 bg-base-100 px-3 py-2 text-xs"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name="reversal-mode"
|
||||
className="radio radio-warning radio-xs mt-0.5"
|
||||
value={mode}
|
||||
checked={reversalMode === mode}
|
||||
disabled={
|
||||
previewMutation.isPending || reversalMutation.isPending
|
||||
}
|
||||
onChange={() => {
|
||||
resetCommandFeedback();
|
||||
reversalIdempotencyKeyRef.current = null;
|
||||
setReversalMode(mode);
|
||||
setReversalPreview(null);
|
||||
setImpactConfirmed(false);
|
||||
}}
|
||||
/>
|
||||
<span>
|
||||
<strong className="block text-base-content/70">
|
||||
{mode === "strict" ? "Strict" : "Cascade"}
|
||||
</strong>
|
||||
<span className="mt-0.5 block text-base-content/40">
|
||||
{mode === "strict"
|
||||
? "후속 결과가 없을 때 선택 Series만 되돌립니다."
|
||||
: "영향받은 후속 Series 결과도 함께 되돌립니다."}
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
|
||||
<label className="block text-xs font-bold text-base-content/50">
|
||||
되돌리기 사유
|
||||
<textarea
|
||||
className="mt-1.5 min-h-24 w-full resize-y border border-base-content/15 bg-base-100 px-3 py-2 text-sm focus:border-warning/50 focus:outline-none"
|
||||
maxLength={2000}
|
||||
value={reversalReason}
|
||||
disabled={previewMutation.isPending || reversalMutation.isPending}
|
||||
onChange={(event) => {
|
||||
resetCommandFeedback();
|
||||
reversalIdempotencyKeyRef.current = null;
|
||||
setReversalReason(event.target.value);
|
||||
setReversalPreview(null);
|
||||
setImpactConfirmed(false);
|
||||
}}
|
||||
placeholder="감사 로그에 남을 구체적인 사유를 입력하세요."
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
className="btn btn-outline btn-sm px-4 text-xs"
|
||||
disabled={
|
||||
previewMutation.isPending ||
|
||||
reversalMutation.isPending ||
|
||||
!reversalReason.trim()
|
||||
}
|
||||
>
|
||||
{previewMutation.isPending ? "계산 중..." : "영향 미리보기"}
|
||||
</button>
|
||||
|
||||
{reversalPreview && (
|
||||
<ReversalImpactPanel
|
||||
preview={reversalPreview}
|
||||
competition={competition}
|
||||
confirmed={impactConfirmed}
|
||||
onConfirmedChange={setImpactConfirmed}
|
||||
previewIsCurrent={previewIsCurrent}
|
||||
executing={reversalMutation.isPending}
|
||||
onExecute={handleReverse}
|
||||
/>
|
||||
)}
|
||||
</form>
|
||||
) : (
|
||||
<p className="mt-4 border border-dashed border-base-content/15 px-3 py-4 text-sm text-base-content/45">
|
||||
이 Series는 현재 판정하거나 되돌릴 수 있는 상태가 아닙니다.
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function ReversalImpactPanel({
|
||||
preview,
|
||||
competition,
|
||||
confirmed,
|
||||
onConfirmedChange,
|
||||
previewIsCurrent,
|
||||
executing,
|
||||
onExecute,
|
||||
}: {
|
||||
preview: SeriesReversalPreviewResponse;
|
||||
competition: CompetitionDetailResponse;
|
||||
confirmed: boolean;
|
||||
onConfirmedChange: (confirmed: boolean) => void;
|
||||
previewIsCurrent: boolean;
|
||||
executing: boolean;
|
||||
onExecute: () => void;
|
||||
}) {
|
||||
const seriesById = new Map(
|
||||
competition.projection.series.map((series) => [series.seriesId, series]),
|
||||
);
|
||||
const teamById = new Map(
|
||||
competition.teams.map((team) => [team.teamId, team]),
|
||||
);
|
||||
const { impact } = preview;
|
||||
|
||||
return (
|
||||
<div className="border border-error/25 bg-error/[0.04] p-3">
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
<h4 className="text-sm font-bold text-error">영향 범위</h4>
|
||||
<span className="font-mono text-xs text-base-content/45">
|
||||
source revision {preview.sourceRevision}
|
||||
</span>
|
||||
</div>
|
||||
<dl className="mt-3 grid grid-cols-2 gap-2 text-xs sm:grid-cols-4">
|
||||
<ImpactCount label="Series" value={impact.seriesIds.length} />
|
||||
<ImpactCount label="Facts" value={impact.factIds.length} />
|
||||
<ImpactCount label="Game slots" value={impact.gameSlotIds.length} />
|
||||
<ImpactCount label="Teams" value={impact.teamIds.length} />
|
||||
<ImpactCount label="코드 반환" value={impact.releasesReservedCodes} />
|
||||
<ImpactCount label="사용 코드 무효화" value={impact.voidsUsedCodes} />
|
||||
<ImpactCount
|
||||
label="통계 재생성"
|
||||
value={impact.requiresStatsRebuild ? "필요" : "불필요"}
|
||||
/>
|
||||
</dl>
|
||||
|
||||
<div className="mt-3 grid gap-2 sm:grid-cols-2">
|
||||
<ImpactList
|
||||
title="영향받는 Series"
|
||||
items={impact.seriesIds.map((seriesId) => {
|
||||
const series = seriesById.get(seriesId);
|
||||
return series ? seriesLabel(series) : String(seriesId);
|
||||
})}
|
||||
/>
|
||||
<ImpactList
|
||||
title="영향받는 팀"
|
||||
items={impact.teamIds.map(
|
||||
(teamId) => teamById.get(teamId)?.name ?? String(teamId),
|
||||
)}
|
||||
/>
|
||||
<ImpactList title="되돌릴 사실 ID" items={impact.factIds.map(String)} />
|
||||
<ImpactList
|
||||
title="영향받는 Game slot ID"
|
||||
items={impact.gameSlotIds.map(String)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="mt-3">
|
||||
<span className="text-xs font-bold text-base-content/45">
|
||||
Impact hash
|
||||
</span>
|
||||
<code className="mt-1 block break-all border border-base-content/10 bg-base-100 px-2 py-1.5 font-mono text-[11px] text-base-content/55">
|
||||
{preview.impactHash}
|
||||
</code>
|
||||
</div>
|
||||
|
||||
{!previewIsCurrent && (
|
||||
<p
|
||||
className="mt-3 border border-error/20 bg-error/10 px-2 py-2 text-xs text-error"
|
||||
role="alert"
|
||||
>
|
||||
Competition revision이 변경되었습니다. 새 미리보기가 필요합니다.
|
||||
</p>
|
||||
)}
|
||||
|
||||
<label className="mt-3 flex items-start gap-2 text-xs text-base-content/60">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="checkbox checkbox-error checkbox-xs mt-0.5"
|
||||
checked={confirmed}
|
||||
disabled={!previewIsCurrent || executing}
|
||||
onChange={(event) => onConfirmedChange(event.target.checked)}
|
||||
/>
|
||||
표시된 Series, 사실, 코드 및 통계 영향을 확인했습니다.
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-error btn-sm mt-3 px-4 text-xs"
|
||||
disabled={!confirmed || !previewIsCurrent || executing}
|
||||
onClick={onExecute}
|
||||
>
|
||||
{executing ? "되돌리는 중..." : "Hash 확인 후 되돌리기"}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ImpactCount({
|
||||
label,
|
||||
value,
|
||||
}: {
|
||||
label: string;
|
||||
value: number | string;
|
||||
}) {
|
||||
return (
|
||||
<div className="border border-base-content/10 bg-base-100 px-2 py-2">
|
||||
<dt className="text-base-content/40">{label}</dt>
|
||||
<dd className="mt-0.5 font-mono font-bold text-base-content/70">
|
||||
{value}
|
||||
</dd>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ImpactList({ title, items }: { title: string; items: string[] }) {
|
||||
return (
|
||||
<div className="border border-base-content/10 bg-base-100 px-2 py-2 text-xs">
|
||||
<h5 className="font-bold text-base-content/45">{title}</h5>
|
||||
{items.length > 0 ? (
|
||||
<ul className="mt-1 space-y-0.5 text-base-content/60">
|
||||
{items.map((item, index) => (
|
||||
<li key={`${item}:${index}`} className="break-all">
|
||||
{item}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p className="mt-1 text-base-content/35">없음</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function seriesLabel(series: SeriesProjection) {
|
||||
return series.code ?? `${stageLabel(series)} Series`;
|
||||
}
|
||||
|
||||
function stageLabel(series: SeriesProjection) {
|
||||
switch (series.stage.type) {
|
||||
case "pair":
|
||||
return "대진";
|
||||
case "round-robin":
|
||||
return `${series.stage.roundNumber ?? 1}라운드`;
|
||||
case "upper":
|
||||
return `승자조 ${series.stage.roundNumber ?? 1}라운드`;
|
||||
case "lower":
|
||||
return `패자조 ${series.stage.roundNumber ?? 1}라운드`;
|
||||
case "grand-final":
|
||||
return "그랜드 파이널";
|
||||
case "reset-final":
|
||||
return "리셋 파이널";
|
||||
}
|
||||
}
|
||||
|
||||
function seriesStatusLabel(status: SeriesProjection["status"]) {
|
||||
switch (status) {
|
||||
case "inactive":
|
||||
return "비활성";
|
||||
case "waiting":
|
||||
return "대기";
|
||||
case "ready":
|
||||
return "경기 가능";
|
||||
case "in-progress":
|
||||
return "진행 중";
|
||||
case "completed":
|
||||
return "종료";
|
||||
}
|
||||
}
|
||||
|
||||
function competitionCommandErrorMessage(error: unknown) {
|
||||
const code = competitionCommandErrorCode(error);
|
||||
if (code === "REVERSAL_PREVIEW_STALE") {
|
||||
return "미리보기 이후 Competition이 변경되었습니다. 최신 revision에서 영향을 다시 계산하세요.";
|
||||
}
|
||||
if (code === "REVERSAL_DESCENDANT_ACTIVITY") {
|
||||
return "후속 Series에 결과 또는 코드 사용 이력이 있습니다. Cascade 모드로 영향을 다시 계산하세요.";
|
||||
}
|
||||
if (code === "WALKOVER_HAS_ACTIVE_GAMES") {
|
||||
return "이미 반영된 게임이 있어 부전승 처리할 수 없습니다. 몰수패 또는 운영자 판정을 사용하세요.";
|
||||
}
|
||||
if (code === "ADJUDICATION_DRAW_NOT_ALLOWED") {
|
||||
return "이 Series 규칙은 운영자 무승부를 허용하지 않습니다.";
|
||||
}
|
||||
if (error instanceof ApiError) {
|
||||
if (error.status === 412) {
|
||||
return "Competition revision이 변경되었습니다. 최신 revision을 불러온 뒤 다시 시도하세요.";
|
||||
}
|
||||
if (error.status === 409) {
|
||||
return `현재 결과 상태와 충돌했습니다. ${error.message}`;
|
||||
}
|
||||
if (error.status === 422) {
|
||||
return `요청을 적용할 수 없습니다. ${error.message}`;
|
||||
}
|
||||
if (error.status === 403) {
|
||||
return "이 Competition 결과를 관리할 권한이 없습니다.";
|
||||
}
|
||||
}
|
||||
return error instanceof Error
|
||||
? error.message
|
||||
: "Competition 명령을 처리하지 못했습니다.";
|
||||
}
|
||||
|
||||
function competitionCommandErrorCode(error: unknown) {
|
||||
if (!(error instanceof ApiError)) return null;
|
||||
const envelope = error.data as { error?: { code?: unknown } } | null;
|
||||
return typeof envelope?.error?.code === "string" ? envelope.error.code : null;
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
import type {
|
||||
BracketRoundView,
|
||||
CompetitionDetailResponse,
|
||||
CompetitionOutcome,
|
||||
TeamId,
|
||||
} from "@lolympus/contracts";
|
||||
import { Link } from "react-router";
|
||||
import { RoundRobinTable } from "./RoundRobinTable";
|
||||
import { SeriesScoreCard } from "./SeriesScoreCard";
|
||||
|
||||
export function CompetitionResults({
|
||||
competition,
|
||||
}: {
|
||||
competition: CompetitionDetailResponse;
|
||||
}) {
|
||||
const { projection } = competition;
|
||||
const teamById = new Map(
|
||||
competition.teams.map((team) => [team.teamId, team]),
|
||||
);
|
||||
const seriesById = new Map(
|
||||
projection.series.map((series) => [series.seriesId, series]),
|
||||
);
|
||||
|
||||
return (
|
||||
<section className="mb-6 space-y-4" aria-labelledby="competition-heading">
|
||||
<header className="flex flex-wrap items-end justify-between gap-3 border-b border-base-content/10 pb-3">
|
||||
<div>
|
||||
<p className="text-[11px] font-bold uppercase tracking-wider text-base-content/35">
|
||||
Competition
|
||||
</p>
|
||||
<h2 id="competition-heading" className="mt-1 text-lg font-bold">
|
||||
공식 경기 결과
|
||||
</h2>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-xs text-base-content/40">
|
||||
revision {competition.revision}
|
||||
</span>
|
||||
<Link
|
||||
to={`/match/${competition.matchId}/team`}
|
||||
className="border border-base-content/10 px-2.5 py-1.5 text-xs font-bold text-base-content/55 hover:border-primary/30 hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
|
||||
>
|
||||
내 팀 진행
|
||||
</Link>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{projection.outcome && (
|
||||
<OutcomeSummary outcome={projection.outcome} teamById={teamById} />
|
||||
)}
|
||||
|
||||
{projection.formatType === "round-robin" && (
|
||||
<RoundRobinTable standings={projection.standings} teamById={teamById} />
|
||||
)}
|
||||
|
||||
{projection.rounds.length > 0 ? (
|
||||
<div className="overflow-x-auto pb-2">
|
||||
<div className="grid min-w-max auto-cols-[17rem] grid-flow-col gap-4">
|
||||
{projection.rounds.map((round) => (
|
||||
<RoundColumn
|
||||
key={`${round.stage}:${round.roundNumber ?? 0}`}
|
||||
round={round}
|
||||
seriesById={seriesById}
|
||||
teamById={teamById}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<p
|
||||
className="border border-dashed border-base-content/15 px-4 py-5 text-sm text-base-content/45"
|
||||
role="status"
|
||||
>
|
||||
편성된 공식 대진이 없습니다.
|
||||
</p>
|
||||
)}
|
||||
|
||||
{projection.games.length > 0 && (
|
||||
<div className="border border-base-content/10 bg-base-content/[0.02] p-4">
|
||||
<h3 className="text-xs font-bold uppercase tracking-wider text-base-content/40">
|
||||
완료된 게임
|
||||
</h3>
|
||||
<ul className="mt-3 grid gap-2 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{projection.games.map((game) => (
|
||||
<li
|
||||
key={game.id}
|
||||
className="flex items-center justify-between gap-3 border border-base-content/8 bg-base-100 px-3 py-2 text-xs"
|
||||
>
|
||||
<span className="text-base-content/45">
|
||||
Game {game.displayNumber}
|
||||
</span>
|
||||
<span className="truncate font-semibold">
|
||||
{teamById.get(game.winnerTeamId)?.name ?? "알 수 없는 팀"} 승
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function RoundColumn({
|
||||
round,
|
||||
seriesById,
|
||||
teamById,
|
||||
}: {
|
||||
round: BracketRoundView;
|
||||
seriesById: Map<
|
||||
string,
|
||||
CompetitionDetailResponse["projection"]["series"][number]
|
||||
>;
|
||||
teamById: Map<TeamId, CompetitionDetailResponse["teams"][number]>;
|
||||
}) {
|
||||
return (
|
||||
<section aria-label={round.label} className="space-y-2">
|
||||
<h3 className="px-1 text-xs font-bold text-base-content/45">
|
||||
{stageLabel(round.stage, round.roundNumber)}
|
||||
</h3>
|
||||
<div className="space-y-3">
|
||||
{round.seriesIds.map((seriesId) => {
|
||||
const series = seriesById.get(seriesId);
|
||||
return series ? (
|
||||
<SeriesScoreCard
|
||||
key={series.seriesId}
|
||||
series={series}
|
||||
teamById={teamById}
|
||||
/>
|
||||
) : null;
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function OutcomeSummary({
|
||||
outcome,
|
||||
teamById,
|
||||
}: {
|
||||
outcome: CompetitionOutcome;
|
||||
teamById: Map<TeamId, CompetitionDetailResponse["teams"][number]>;
|
||||
}) {
|
||||
if (outcome.type === "paired-series") {
|
||||
return (
|
||||
<p className="border-l-2 border-success bg-success/5 px-3 py-2 text-sm text-base-content/65">
|
||||
{outcome.completedSeriesIds.length + outcome.drawnSeriesIds.length}개
|
||||
Series가 모두 종료되었습니다.
|
||||
</p>
|
||||
);
|
||||
}
|
||||
const leaders =
|
||||
outcome.type === "round-robin"
|
||||
? outcome.leaderTeamIds
|
||||
: [outcome.championTeamId];
|
||||
return (
|
||||
<p className="border-l-2 border-success bg-success/5 px-3 py-2 text-sm">
|
||||
<span className="mr-2 text-xs font-bold text-success">
|
||||
{outcome.type === "round-robin" ? "1위" : "우승"}
|
||||
</span>
|
||||
<span className="font-bold">
|
||||
{leaders
|
||||
.map((teamId) => teamById.get(teamId)?.name ?? "알 수 없는 팀")
|
||||
.join(", ")}
|
||||
</span>
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
function stageLabel(stage: BracketRoundView["stage"], round?: number) {
|
||||
switch (stage) {
|
||||
case "pair":
|
||||
return "대진";
|
||||
case "round-robin":
|
||||
return `${round ?? 1}라운드`;
|
||||
case "upper":
|
||||
return `승자조 ${round ?? 1}라운드`;
|
||||
case "lower":
|
||||
return `패자조 ${round ?? 1}라운드`;
|
||||
case "grand-final":
|
||||
return "그랜드 파이널";
|
||||
case "reset-final":
|
||||
return "리셋 파이널";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import type {
|
||||
CompetitionTeamView,
|
||||
RoundRobinStandingView,
|
||||
TeamId,
|
||||
} from "@lolympus/contracts";
|
||||
|
||||
export function RoundRobinTable({
|
||||
standings,
|
||||
teamById,
|
||||
}: {
|
||||
standings: RoundRobinStandingView[];
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||
}) {
|
||||
return (
|
||||
<div className="overflow-x-auto border border-base-content/10">
|
||||
<table className="w-full min-w-[36rem] text-left text-xs">
|
||||
<caption className="sr-only">라운드 로빈 공식 순위</caption>
|
||||
<thead className="border-b border-base-content/10 bg-base-200/40 text-base-content/40">
|
||||
<tr>
|
||||
<th scope="col" className="w-14 px-3 py-2 font-semibold">
|
||||
순위
|
||||
</th>
|
||||
<th scope="col" className="px-3 py-2 font-semibold">
|
||||
팀
|
||||
</th>
|
||||
<th scope="col" className="px-3 py-2 text-right font-semibold">
|
||||
전적
|
||||
</th>
|
||||
<th scope="col" className="px-3 py-2 text-right font-semibold">
|
||||
게임
|
||||
</th>
|
||||
<th scope="col" className="px-3 py-2 text-right font-semibold">
|
||||
득실
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-base-content/8">
|
||||
{standings.map((standing) => (
|
||||
<tr key={standing.teamId}>
|
||||
<td className="px-3 py-2.5 font-mono font-bold tabular-nums">
|
||||
{standing.rank}
|
||||
</td>
|
||||
<th scope="row" className="px-3 py-2.5 font-semibold">
|
||||
{teamById.get(standing.teamId)?.name ?? "알 수 없는 팀"}
|
||||
</th>
|
||||
<td className="px-3 py-2.5 text-right tabular-nums text-base-content/60">
|
||||
{standing.seriesWins}승 {standing.seriesLosses}패
|
||||
{standing.seriesDraws > 0 ? ` ${standing.seriesDraws}무` : ""}
|
||||
</td>
|
||||
<td className="px-3 py-2.5 text-right tabular-nums text-base-content/60">
|
||||
{standing.gameWins}-{standing.gameLosses}
|
||||
</td>
|
||||
<td className="px-3 py-2.5 text-right font-mono font-bold tabular-nums">
|
||||
{standing.gameDiff > 0 ? "+" : ""}
|
||||
{standing.gameDiff}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import type {
|
||||
CompetitionTeamView,
|
||||
SeriesProjection,
|
||||
TeamId,
|
||||
} from "@lolympus/contracts";
|
||||
|
||||
const STATUS_LABEL: Record<SeriesProjection["status"], string> = {
|
||||
inactive: "비활성",
|
||||
waiting: "대진 대기",
|
||||
ready: "경기 가능",
|
||||
"in-progress": "진행 중",
|
||||
completed: "종료",
|
||||
};
|
||||
|
||||
export function SeriesScoreCard({
|
||||
series,
|
||||
teamById,
|
||||
}: {
|
||||
series: SeriesProjection;
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||
}) {
|
||||
const winnerTeamId =
|
||||
series.status === "completed" && series.outcome.type !== "draw"
|
||||
? series.outcome.winnerTeamId
|
||||
: null;
|
||||
|
||||
return (
|
||||
<article
|
||||
className="border border-base-content/10 bg-base-100"
|
||||
aria-label={`${series.code ?? "경기"} ${STATUS_LABEL[series.status]}`}
|
||||
>
|
||||
<header className="flex items-center justify-between gap-3 border-b border-base-content/8 px-3 py-2">
|
||||
<span className="truncate text-xs font-bold text-base-content/65">
|
||||
{series.code ?? "Series"}
|
||||
</span>
|
||||
<span className="shrink-0 text-[11px] text-base-content/40">
|
||||
{STATUS_LABEL[series.status]}
|
||||
</span>
|
||||
</header>
|
||||
<div className="divide-y divide-base-content/8">
|
||||
{series.entries.map((entry) => {
|
||||
const team = entry.teamId ? teamById.get(entry.teamId) : undefined;
|
||||
const isWinner = entry.teamId === winnerTeamId;
|
||||
return (
|
||||
<div
|
||||
key={entry.slot}
|
||||
className="grid grid-cols-[1.5rem_minmax(0,1fr)_2rem] items-center gap-2 px-3 py-2.5"
|
||||
>
|
||||
<span className="text-[10px] font-bold text-base-content/30">
|
||||
{entry.slot}
|
||||
</span>
|
||||
<span
|
||||
className={`truncate text-sm ${
|
||||
isWinner
|
||||
? "font-bold text-base-content"
|
||||
: "text-base-content/60"
|
||||
}`}
|
||||
>
|
||||
{team?.name ?? (entry.teamId ? "알 수 없는 팀" : "대기 중")}
|
||||
{isWinner && (
|
||||
<span className="ml-2 text-[10px] font-bold text-success">
|
||||
승리
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="text-right font-mono text-base font-bold tabular-nums text-base-content/75">
|
||||
{entry.gameWins}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -29,6 +29,9 @@ function resolveErrorMessage(status: number, data: unknown) {
|
||||
const message = (data as { message?: unknown }).message;
|
||||
if (typeof message === 'string') return message;
|
||||
if (Array.isArray(message)) return message.join(', ');
|
||||
const nestedMessage = (data as { error?: { message?: unknown } }).error
|
||||
?.message;
|
||||
if (typeof nestedMessage === 'string') return nestedMessage;
|
||||
}
|
||||
return `API request failed (${status})`;
|
||||
}
|
||||
@@ -85,7 +88,11 @@ export async function apiFetch<T>(
|
||||
|
||||
const data = await readResponseBody(response);
|
||||
if (!response.ok) {
|
||||
throw new ApiError(response.status, resolveErrorMessage(response.status, data), data);
|
||||
throw new ApiError(
|
||||
response.status,
|
||||
resolveErrorMessage(response.status, data),
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
return data as T;
|
||||
|
||||
@@ -390,23 +390,15 @@ function formatCompactDateTime(dateLike: string) {
|
||||
function HistoryMetaText({
|
||||
map,
|
||||
participants,
|
||||
result,
|
||||
}: {
|
||||
map: string;
|
||||
participants: number;
|
||||
result?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className={HISTORY_MOBILE_META_CLASS}>
|
||||
<span>{map}</span>
|
||||
<span className="text-base-content/20">·</span>
|
||||
<span>{participants}명</span>
|
||||
{result && (
|
||||
<>
|
||||
<span className="text-base-content/20">·</span>
|
||||
<span>{result}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -691,11 +683,12 @@ export default function HomePage() {
|
||||
{match.participants.length}명
|
||||
</td>
|
||||
<td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
|
||||
<span className="block truncate">
|
||||
{match.result?.winner
|
||||
? `${match.result.winner} 승리`
|
||||
: '-'}
|
||||
</span>
|
||||
<Link
|
||||
to={`/match/${match.id}`}
|
||||
className="font-semibold text-base-content/45 hover:text-primary"
|
||||
>
|
||||
공식 결과
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
@@ -717,10 +710,6 @@ export default function HomePage() {
|
||||
<div className="md:hidden border border-base-content/10">
|
||||
{historyMatches.length > 0 ? (
|
||||
historyMatches.map((match) => {
|
||||
const resultLabel = match.result?.winner
|
||||
? `${match.result.winner} 승리`
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={match.id}
|
||||
@@ -747,7 +736,6 @@ export default function HomePage() {
|
||||
<HistoryMetaText
|
||||
map={match.map}
|
||||
participants={match.participants.length}
|
||||
result={resultLabel}
|
||||
/>
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
+634
-2794
File diff suppressed because it is too large.
Load diff
@@ -1,625 +1,65 @@
|
||||
import { useState } from "react";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { AlertTriangle, ChevronDown, ChevronUp } from "lucide-react";
|
||||
import { Link, useLocation, useParams } from "react-router";
|
||||
import {
|
||||
useDdragonManifest,
|
||||
useMatch,
|
||||
useReplaceTournamentCode,
|
||||
useUserHistoryProfile,
|
||||
} from "../api/hooks";
|
||||
import { formatKoreanDate } from "../api/mappers";
|
||||
import { RankBadge } from "../components/RankBadge";
|
||||
import type {
|
||||
ApiMatch,
|
||||
ApiMatchGameResult,
|
||||
ApiMatchParticipant,
|
||||
ApiTierInfo,
|
||||
MatchGameMode,
|
||||
Position,
|
||||
TeamSide,
|
||||
TournamentCodeSlotView,
|
||||
} from "../api/types";
|
||||
import { Link, useParams } from "react-router";
|
||||
import { useCompetition, useTeamCompetition } from "../api/hooks";
|
||||
import { SeriesScoreCard } from "../components/competition/SeriesScoreCard";
|
||||
import { DEFAULT_COMMUNITY_ID } from "../config";
|
||||
import { profileIconUrl } from "../lib/ddragon";
|
||||
import { positionLabel, sideShortLabel, teamIndexLabel } from "../lib/league";
|
||||
|
||||
const GAME_MODE_LABEL: Record<MatchGameMode, string> = {
|
||||
pair: "페어 매치",
|
||||
bracket: "토너먼트",
|
||||
"round-robin": "리그전",
|
||||
"double-elimination": "더블 엘리미네이션",
|
||||
};
|
||||
|
||||
function resultBadgeClass(won: boolean) {
|
||||
return won
|
||||
? "border-info/20 bg-info/10 text-info"
|
||||
: "border-error/20 bg-error/10 text-error";
|
||||
}
|
||||
|
||||
function captainName(
|
||||
team: ApiMatch["teams"][number] | undefined,
|
||||
participantByUserId: Map<string, ApiMatchParticipant>,
|
||||
) {
|
||||
if (!team?.captainUserId) return undefined;
|
||||
return participantByUserId.get(team.captainUserId)?.gameName;
|
||||
}
|
||||
|
||||
function tierByQueue(tiers: ApiTierInfo[], queueType: string) {
|
||||
return tiers.find((tier) => tier.queueType === queueType);
|
||||
}
|
||||
|
||||
function SummonerStatsSummary({
|
||||
assignedPosition,
|
||||
fallbackTier,
|
||||
userId,
|
||||
}: {
|
||||
assignedPosition?: Position;
|
||||
fallbackTier?: ApiTierInfo;
|
||||
userId?: string;
|
||||
}) {
|
||||
const profileQuery = useUserHistoryProfile(userId, DEFAULT_COMMUNITY_ID);
|
||||
const tiers = profileQuery.data?.tiers ?? [];
|
||||
const soloTier =
|
||||
tierByQueue(tiers, "RANKED_SOLO_5x5") ??
|
||||
(fallbackTier?.queueType === "RANKED_SOLO_5x5" ? fallbackTier : undefined);
|
||||
const flexTier = tierByQueue(tiers, "RANKED_FLEX_SR");
|
||||
|
||||
return (
|
||||
<div className="ml-auto flex min-w-[148px] shrink-0 flex-col items-end text-right leading-tight">
|
||||
<div className="text-xs font-black text-primary">
|
||||
{assignedPosition ? positionLabel[assignedPosition] : "-"}
|
||||
</div>
|
||||
<div className="mt-1 flex items-center justify-end gap-2 text-xs font-black text-base-content/35">
|
||||
<span className="inline-flex items-center gap-1">
|
||||
<span>SOLO</span>
|
||||
<RankBadge tier={soloTier} size="sm" tooltipPlacement="left" />
|
||||
</span>
|
||||
<span className="inline-flex items-center gap-1">
|
||||
<span>FLEX</span>
|
||||
<RankBadge tier={flexTier} size="sm" tooltipPlacement="left" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TeamMemberScoutLine({
|
||||
isCaptain,
|
||||
member,
|
||||
participant,
|
||||
}: {
|
||||
isCaptain?: boolean;
|
||||
member: ApiMatch["teams"][number]["members"][number];
|
||||
participant?: ApiMatchParticipant;
|
||||
}) {
|
||||
return (
|
||||
<ParticipantLine
|
||||
assignedPosition={member.assignedPosition}
|
||||
isCaptain={isCaptain}
|
||||
participant={participant}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function ParticipantLine({
|
||||
participant,
|
||||
assignedPosition,
|
||||
isCaptain,
|
||||
}: {
|
||||
participant?: ApiMatchParticipant;
|
||||
assignedPosition?: Position;
|
||||
isCaptain?: boolean;
|
||||
}) {
|
||||
const { data: ddragon } = useDdragonManifest();
|
||||
const location = useLocation();
|
||||
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
|
||||
const name = participant?.gameName ?? "알 수 없는 참가자";
|
||||
const tag = participant?.tagLine ?? "----";
|
||||
const content = (
|
||||
<>
|
||||
<div className="h-8 w-8 shrink-0 overflow-hidden bg-base-content/10">
|
||||
<img
|
||||
src={profileIconUrl(ddragon, participant?.profileIconId ?? 0)}
|
||||
alt=""
|
||||
className="h-full w-full object-cover"
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<span className="truncate text-sm font-bold text-base-content">
|
||||
{name}
|
||||
</span>
|
||||
{isCaptain && (
|
||||
<span className="shrink-0 border border-accent/20 bg-accent/10 px-1.5 py-0.5 text-xs font-bold text-warning">
|
||||
팀장
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="text-xs text-base-content/30">#{tag}</div>
|
||||
</div>
|
||||
<SummonerStatsSummary
|
||||
assignedPosition={assignedPosition}
|
||||
fallbackTier={participant?.tier}
|
||||
userId={participant?.userId}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
const className =
|
||||
"flex items-center gap-3 border-b border-base-content/5 px-3 py-2 last:border-b-0";
|
||||
|
||||
if (participant?.userId) {
|
||||
return (
|
||||
<Link
|
||||
to={`/users/${participant.userId}/history`}
|
||||
state={{ backTo: historyBackTo }}
|
||||
className={`${className} hover:bg-base-content/[0.025]`}
|
||||
>
|
||||
{content}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
return <div className={className}>{content}</div>;
|
||||
}
|
||||
|
||||
function UpcomingGameCard({
|
||||
expanded,
|
||||
game,
|
||||
isNext,
|
||||
onToggle,
|
||||
onReplaceCode,
|
||||
participantByUserId,
|
||||
parsedTeamIndex,
|
||||
replacingCode,
|
||||
slot,
|
||||
teamByIndex,
|
||||
}: {
|
||||
expanded: boolean;
|
||||
game?: ApiMatchGameResult;
|
||||
isNext?: boolean;
|
||||
onToggle: () => void;
|
||||
onReplaceCode?: (slot: TournamentCodeSlotView) => void;
|
||||
participantByUserId: Map<string, ApiMatchParticipant>;
|
||||
parsedTeamIndex: number;
|
||||
replacingCode?: boolean;
|
||||
slot: TournamentCodeSlotView;
|
||||
teamByIndex: Map<number, ApiMatch["teams"][number]>;
|
||||
}) {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const opponentIndex =
|
||||
slot.teamAIndex === parsedTeamIndex ? slot.teamBIndex : slot.teamAIndex;
|
||||
const ourTeam = teamByIndex.get(parsedTeamIndex);
|
||||
const opponentTeam = opponentIndex ? teamByIndex.get(opponentIndex) : undefined;
|
||||
const ourTeamName = teamIndexLabel(parsedTeamIndex, ourTeam?.name);
|
||||
const opponentTeamName = opponentIndex
|
||||
? teamIndexLabel(opponentIndex, opponentTeam?.name)
|
||||
: "상대 미정";
|
||||
const ourCaptainName = captainName(ourTeam, participantByUserId);
|
||||
const opponentCaptainName = captainName(opponentTeam, participantByUserId);
|
||||
const opponentMembers = opponentTeam?.members ?? [];
|
||||
const finished = Boolean(game?.winnerTeamIndex);
|
||||
const won = finished && game?.winnerTeamIndex === parsedTeamIndex;
|
||||
const ourSide: TeamSide =
|
||||
slot.teamAIndex === parsedTeamIndex ? "blue" : "red";
|
||||
const replaceable = Boolean(slot.code && !finished && slot.state !== "used");
|
||||
|
||||
async function handleCopy() {
|
||||
if (!slot.code) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(slot.code);
|
||||
setCopied(true);
|
||||
window.setTimeout(() => setCopied(false), 1500);
|
||||
} catch {
|
||||
setCopied(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<li
|
||||
className={`w-full border bg-base-100 p-4 ${
|
||||
isNext
|
||||
? "border-primary/30 bg-primary/[0.03]"
|
||||
: "border-base-content/10"
|
||||
} ${finished ? "bg-base-content/[0.015]" : ""}`}
|
||||
>
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<span
|
||||
className={`border px-2 py-1 text-xs font-black ${
|
||||
isNext
|
||||
? "border-primary/25 bg-primary/10 text-primary"
|
||||
: "border-base-content/10 bg-base-content/5 text-base-content/55"
|
||||
}`}
|
||||
>
|
||||
{isNext ? "다음 경기" : `${slot.gameNumber}경기`}
|
||||
</span>
|
||||
<span className="text-xs font-semibold text-base-content/35">
|
||||
{sideShortLabel(ourSide)}
|
||||
</span>
|
||||
</div>
|
||||
{finished ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<span
|
||||
className={`border px-2 py-1 text-xs font-black ${resultBadgeClass(won)}`}
|
||||
>
|
||||
{won ? "승리" : "패배"}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex h-7 w-7 items-center justify-center text-base-content/45 hover:text-primary"
|
||||
onClick={onToggle}
|
||||
aria-expanded={expanded}
|
||||
aria-label={expanded ? "상대팀 정보 접기" : "상대팀 정보 펼치기"}
|
||||
>
|
||||
{expanded ? (
|
||||
<ChevronUp className="h-4 w-4" aria-hidden="true" />
|
||||
) : (
|
||||
<ChevronDown className="h-4 w-4" aria-hidden="true" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex h-7 w-7 items-center justify-center text-base-content/45 hover:text-primary"
|
||||
onClick={onToggle}
|
||||
aria-expanded={expanded}
|
||||
aria-label={expanded ? "상대팀 정보 접기" : "상대팀 정보 펼치기"}
|
||||
>
|
||||
{expanded ? (
|
||||
<ChevronUp className="h-4 w-4" aria-hidden="true" />
|
||||
) : (
|
||||
<ChevronDown className="h-4 w-4" aria-hidden="true" />
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-4 grid grid-cols-[1fr_auto_1fr] items-start gap-2">
|
||||
<div className="min-w-0">
|
||||
<div className="truncate text-sm font-black text-primary">
|
||||
{ourTeamName}
|
||||
</div>
|
||||
{ourCaptainName && (
|
||||
<div className="mt-1 truncate text-xs text-base-content/35">
|
||||
팀장 {ourCaptainName}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="pt-0.5 text-xs font-black uppercase tracking-wider text-base-content/25">
|
||||
vs
|
||||
</div>
|
||||
<div className="min-w-0 text-right">
|
||||
<div className="truncate text-sm font-bold text-base-content/70">
|
||||
{opponentTeamName}
|
||||
</div>
|
||||
{opponentCaptainName && (
|
||||
<div className="mt-1 truncate text-xs text-base-content/35">
|
||||
팀장 {opponentCaptainName}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-4 border border-base-content/8 bg-base-content/[0.02] px-3 py-2">
|
||||
<div className="text-xs font-black uppercase tracking-wider text-base-content/35">
|
||||
토너먼트 코드
|
||||
</div>
|
||||
<div className="mt-1 flex items-center gap-2">
|
||||
{slot.code ? (
|
||||
<>
|
||||
<code className="min-w-0 flex-1 truncate font-mono text-xs font-black text-primary">
|
||||
{slot.code}
|
||||
</code>
|
||||
<button
|
||||
type="button"
|
||||
className="whitespace-nowrap border border-base-content/10 px-2 py-1 text-xs font-bold text-base-content/45 hover:text-primary"
|
||||
onClick={handleCopy}
|
||||
>
|
||||
{copied ? "복사됨" : "복사"}
|
||||
</button>
|
||||
{replaceable && (
|
||||
<button
|
||||
type="button"
|
||||
className="whitespace-nowrap border border-base-content/10 px-2 py-1 text-xs font-bold text-base-content/45 hover:text-primary disabled:cursor-not-allowed disabled:opacity-45"
|
||||
disabled={replacingCode}
|
||||
onClick={() => onReplaceCode?.(slot)}
|
||||
>
|
||||
{replacingCode ? "교체 중" : "교체"}
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<span className="text-xs font-semibold text-base-content/30">
|
||||
발급 대기
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{expanded && (
|
||||
<div className="mt-3 border border-base-content/8 bg-base-content/[0.015]">
|
||||
<div className="flex items-center justify-between gap-2 border-b border-base-content/8 px-3 py-2">
|
||||
<div>
|
||||
<div className="text-xs font-black text-base-content/55">
|
||||
상대팀 멤버
|
||||
</div>
|
||||
<div className="mt-0.5 text-xs text-base-content/30">
|
||||
라인 · 티어
|
||||
</div>
|
||||
</div>
|
||||
<div className="truncate text-right text-xs font-bold text-base-content/45">
|
||||
{opponentTeamName}
|
||||
</div>
|
||||
</div>
|
||||
{opponentMembers.length > 0 ? (
|
||||
<div>
|
||||
{opponentMembers.map((member) => (
|
||||
<TeamMemberScoutLine
|
||||
key={member.userId}
|
||||
isCaptain={opponentTeam?.captainUserId === member.userId}
|
||||
member={member}
|
||||
participant={participantByUserId.get(member.userId)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="px-3 py-5 text-center text-xs text-base-content/30">
|
||||
상대팀 멤버 정보가 아직 없습니다.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{finished && game?.riotMatchId && (
|
||||
<div className="mt-2 truncate font-mono text-xs text-base-content/25">
|
||||
{game.riotMatchId}
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
function TeamGameCardsSection({
|
||||
defaultExpandedGameNumber,
|
||||
emptyMessage,
|
||||
gameByNumber,
|
||||
isPreTeamBuilt,
|
||||
match,
|
||||
participantByUserId,
|
||||
parsedTeamIndex,
|
||||
replaceError,
|
||||
replacingGameNumber,
|
||||
teamByIndex,
|
||||
slots,
|
||||
title,
|
||||
onReplaceCode,
|
||||
}: {
|
||||
defaultExpandedGameNumber?: number | null;
|
||||
emptyMessage: string;
|
||||
gameByNumber: Map<number, ApiMatchGameResult>;
|
||||
isPreTeamBuilt?: boolean;
|
||||
match: ApiMatch;
|
||||
participantByUserId: Map<string, ApiMatchParticipant>;
|
||||
parsedTeamIndex: number;
|
||||
replaceError?: string | null;
|
||||
replacingGameNumber?: number | null;
|
||||
teamByIndex: Map<number, ApiMatch["teams"][number]>;
|
||||
slots: TournamentCodeSlotView[];
|
||||
title: string;
|
||||
onReplaceCode?: (slot: TournamentCodeSlotView) => void;
|
||||
}) {
|
||||
const formatted = formatKoreanDate(match.scheduledAt);
|
||||
const [expandedGameNumber, setExpandedGameNumber] = useState<number | null>(
|
||||
defaultExpandedGameNumber ?? null,
|
||||
);
|
||||
const nextGameNumber = defaultExpandedGameNumber ?? null;
|
||||
|
||||
return (
|
||||
<section className="mb-4 border border-base-content/10 bg-base-100">
|
||||
<div className="flex flex-col gap-1 border-b border-base-content/10 bg-base-200/40 px-4 py-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
<h2 className="text-xs font-bold uppercase tracking-wider text-base-content/40">
|
||||
{title}
|
||||
</h2>
|
||||
<div className="sm:text-right">
|
||||
<div className="text-sm font-black text-base-content/70">
|
||||
{formatted.date} {formatted.time}
|
||||
</div>
|
||||
<div className="mt-0.5 text-xs font-semibold text-base-content/35">
|
||||
{GAME_MODE_LABEL[match.gameMode]}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="p-4">
|
||||
{replaceError && (
|
||||
<div className="mb-3 border border-error/20 bg-error/8 px-3 py-2 text-xs text-error">
|
||||
{replaceError}
|
||||
</div>
|
||||
)}
|
||||
{isPreTeamBuilt ? (
|
||||
<div className="border border-dashed border-base-content/10 px-4 py-8 text-center text-xs text-base-content/35">
|
||||
팀 빌딩이 끝나면 일정이 표시됩니다.
|
||||
</div>
|
||||
) : slots.length === 0 ? (
|
||||
<div className="border border-dashed border-base-content/10 px-4 py-8 text-center text-xs text-base-content/35">
|
||||
{emptyMessage}
|
||||
</div>
|
||||
) : (
|
||||
<ul className="space-y-3">
|
||||
{slots.map((slot) => (
|
||||
<UpcomingGameCard
|
||||
key={slot.gameNumber}
|
||||
expanded={expandedGameNumber === slot.gameNumber}
|
||||
game={gameByNumber.get(slot.gameNumber)}
|
||||
isNext={slot.gameNumber === nextGameNumber}
|
||||
onToggle={() =>
|
||||
setExpandedGameNumber((current) =>
|
||||
current === slot.gameNumber ? null : slot.gameNumber,
|
||||
)
|
||||
}
|
||||
onReplaceCode={onReplaceCode}
|
||||
participantByUserId={participantByUserId}
|
||||
parsedTeamIndex={parsedTeamIndex}
|
||||
replacingCode={replacingGameNumber === slot.gameNumber}
|
||||
slot={slot}
|
||||
teamByIndex={teamByIndex}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function buildFinishedSlot(
|
||||
game: ApiMatchGameResult,
|
||||
slotByGameNumber: Map<number, TournamentCodeSlotView>,
|
||||
): TournamentCodeSlotView {
|
||||
const slot = slotByGameNumber.get(game.gameNumber);
|
||||
|
||||
return {
|
||||
gameNumber: game.gameNumber,
|
||||
teamAIndex: game.blueTeamIndex,
|
||||
teamBIndex: game.redTeamIndex,
|
||||
code: slot?.code ?? null,
|
||||
expiresAt: slot?.expiresAt ?? null,
|
||||
state: slot?.state ?? "used",
|
||||
riotMatchId: slot?.riotMatchId ?? game.riotMatchId,
|
||||
};
|
||||
}
|
||||
|
||||
export default function MatchTeamProgressPage() {
|
||||
const { id, teamIndex } = useParams();
|
||||
const parsedTeamIndex = Number(teamIndex);
|
||||
const queryClient = useQueryClient();
|
||||
const matchQuery = useMatch(id, DEFAULT_COMMUNITY_ID);
|
||||
const replaceTournamentCodeMutation =
|
||||
useReplaceTournamentCode(DEFAULT_COMMUNITY_ID);
|
||||
const [replaceCodeSlot, setReplaceCodeSlot] =
|
||||
useState<TournamentCodeSlotView | null>(null);
|
||||
const [replaceCodeConfirmText, setReplaceCodeConfirmText] = useState("");
|
||||
const { id } = useParams();
|
||||
const competitionQuery = useCompetition(id, DEFAULT_COMMUNITY_ID);
|
||||
const teamQuery = useTeamCompetition(id, DEFAULT_COMMUNITY_ID);
|
||||
const [copiedSlotId, setCopiedSlotId] = useState<string | null>(null);
|
||||
|
||||
function handleReplaceTournamentCode(slot: TournamentCodeSlotView) {
|
||||
if (!slot.code) return;
|
||||
setReplaceCodeConfirmText("");
|
||||
setReplaceCodeSlot(slot);
|
||||
}
|
||||
|
||||
function closeReplaceTournamentCodeDialog() {
|
||||
setReplaceCodeSlot(null);
|
||||
setReplaceCodeConfirmText("");
|
||||
}
|
||||
|
||||
function handleConfirmReplaceTournamentCode() {
|
||||
if (!id || !replaceCodeSlot || replaceCodeConfirmText.trim() !== "예") {
|
||||
return;
|
||||
}
|
||||
replaceTournamentCodeMutation.mutate(
|
||||
{ matchId: id, gameNumber: replaceCodeSlot.gameNumber },
|
||||
{
|
||||
onSuccess: async () => {
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: ["match", DEFAULT_COMMUNITY_ID, id ?? null],
|
||||
});
|
||||
closeReplaceTournamentCodeDialog();
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if (!DEFAULT_COMMUNITY_ID) {
|
||||
if (competitionQuery.isLoading || teamQuery.isLoading) {
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-20 text-center text-sm text-warning">
|
||||
`VITE_DEFAULT_COMMUNITY_ID` 설정이 필요합니다.
|
||||
<main
|
||||
className="mx-auto max-w-5xl space-y-3 px-4 py-12 sm:px-6"
|
||||
aria-busy="true"
|
||||
aria-label="팀 진행 정보를 불러오는 중"
|
||||
>
|
||||
<div className="h-7 w-48 animate-pulse bg-base-200" />
|
||||
<div className="h-32 animate-pulse bg-base-200/70" />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
if (matchQuery.isLoading) {
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-20 text-center text-sm text-base-content/40">
|
||||
팀 진행 정보를 불러오는 중...
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!Number.isInteger(parsedTeamIndex) ||
|
||||
parsedTeamIndex < 1 ||
|
||||
!matchQuery.data
|
||||
) {
|
||||
const competition = competitionQuery.data;
|
||||
const teamView = teamQuery.data;
|
||||
if (!competition || !teamView) {
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-20 text-center">
|
||||
<h1 className="text-lg font-bold">팀 정보를 찾을 수 없습니다</h1>
|
||||
<Link
|
||||
to={`/match/${id}`}
|
||||
className="btn btn-primary btn-sm mt-4 px-5 text-xs"
|
||||
>
|
||||
내전 상세로
|
||||
</Link>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
const match = matchQuery.data;
|
||||
const team = match.teams.find((item) => item.teamIndex === parsedTeamIndex);
|
||||
const participantByUserId = new Map(
|
||||
match.participants.map((participant) => [participant.userId, participant]),
|
||||
);
|
||||
const slotByGameNumber = new Map(
|
||||
(match.tournamentCodes ?? []).map((slot) => [slot.gameNumber, slot]),
|
||||
);
|
||||
const codes = (match.tournamentCodes ?? []).filter(
|
||||
(slot) =>
|
||||
slot.teamAIndex === parsedTeamIndex ||
|
||||
slot.teamBIndex === parsedTeamIndex,
|
||||
);
|
||||
const upcomingSlots = [...codes].sort(
|
||||
(left, right) => left.gameNumber - right.gameNumber,
|
||||
);
|
||||
const teamByIndex = new Map(
|
||||
match.teams.map((team) => [team.teamIndex, team]),
|
||||
);
|
||||
const gameByNumber = new Map(
|
||||
(match.result?.games ?? []).map((game) => [game.gameNumber, game]),
|
||||
);
|
||||
const isPreTeamBuilt =
|
||||
match.status === "recruiting" || (match.teams ?? []).length === 0;
|
||||
const teamGames = (match.result?.games ?? []).filter(
|
||||
(game) =>
|
||||
game.blueTeamIndex === parsedTeamIndex ||
|
||||
game.redTeamIndex === parsedTeamIndex,
|
||||
);
|
||||
const finishedSlots = teamGames
|
||||
.filter((game) => Boolean(game.winnerTeamIndex))
|
||||
.map((game) => buildFinishedSlot(game, slotByGameNumber))
|
||||
.sort((left, right) => left.gameNumber - right.gameNumber);
|
||||
const activeSlots = upcomingSlots.filter(
|
||||
(slot) => !gameByNumber.get(slot.gameNumber)?.winnerTeamIndex,
|
||||
);
|
||||
|
||||
if (!team) {
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-20 text-center">
|
||||
<h1 className="text-lg font-bold">아직 팀이 생성되지 않았습니다</h1>
|
||||
<p className="mt-2 text-sm text-base-content/40">
|
||||
경매가 완료되면 팀별 진행 페이지를 사용할 수 있습니다.
|
||||
<h1 className="text-lg font-bold">팀 진행 정보를 볼 수 없습니다</h1>
|
||||
<p className="mt-2 text-sm text-base-content/45">
|
||||
이 내전에 참여한 계정으로 로그인했는지 확인해주세요.
|
||||
</p>
|
||||
<Link
|
||||
to={`/match/${id}`}
|
||||
className="btn btn-primary btn-sm mt-4 px-5 text-xs"
|
||||
>
|
||||
<Link to={`/match/${id}`} className="btn btn-primary btn-sm mt-5">
|
||||
내전 상세로
|
||||
</Link>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
const teamById = new Map(
|
||||
competition.teams.map((team) => [team.teamId, team]),
|
||||
);
|
||||
const team = teamById.get(teamView.teamId);
|
||||
const completedSeries = competition.projection.series.filter(
|
||||
(series) =>
|
||||
series.status === "completed" &&
|
||||
series.entries.some((entry) => entry.teamId === teamView.teamId),
|
||||
);
|
||||
|
||||
async function copyCode(gameSlotId: string, code: string | null) {
|
||||
if (!code) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(code);
|
||||
setCopiedSlotId(gameSlotId);
|
||||
window.setTimeout(() => setCopiedSlotId(null), 1500);
|
||||
} catch {
|
||||
setCopiedSlotId(null);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-6 sm:px-6">
|
||||
<Link
|
||||
@@ -629,153 +69,152 @@ export default function MatchTeamProgressPage() {
|
||||
← 내전 상세로
|
||||
</Link>
|
||||
|
||||
<div className="mb-6 border-b border-base-content/8 pb-5">
|
||||
<h1 className="text-2xl font-black text-base-content">
|
||||
{teamIndexLabel(team.teamIndex, team.name)}
|
||||
</h1>
|
||||
<p className="mt-1 text-sm text-base-content/45">
|
||||
이 팀의 다가오는 경기 일정과 결과를 한곳에서 확인합니다.
|
||||
<header className="mb-6 border-b border-base-content/10 pb-5">
|
||||
<p className="text-[11px] font-bold uppercase tracking-wider text-base-content/35">
|
||||
My Competition
|
||||
</p>
|
||||
</div>
|
||||
<h1 className="mt-1 text-2xl font-black">{team?.name ?? "내 팀"}</h1>
|
||||
<p className="mt-1 text-sm text-base-content/45">
|
||||
우리 팀의 공식 대진과 토너먼트 코드는 이 페이지에서만 표시됩니다.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<TeamGameCardsSection
|
||||
defaultExpandedGameNumber={activeSlots[0]?.gameNumber ?? null}
|
||||
emptyMessage="남은 경기가 없습니다."
|
||||
gameByNumber={gameByNumber}
|
||||
isPreTeamBuilt={isPreTeamBuilt}
|
||||
match={match}
|
||||
onReplaceCode={handleReplaceTournamentCode}
|
||||
participantByUserId={participantByUserId}
|
||||
parsedTeamIndex={parsedTeamIndex}
|
||||
replaceError={
|
||||
replaceTournamentCodeMutation.error instanceof Error
|
||||
? replaceTournamentCodeMutation.error.message
|
||||
: null
|
||||
}
|
||||
replacingGameNumber={
|
||||
replaceTournamentCodeMutation.isPending
|
||||
? replaceTournamentCodeMutation.variables?.gameNumber ?? null
|
||||
: null
|
||||
}
|
||||
teamByIndex={teamByIndex}
|
||||
slots={activeSlots}
|
||||
title="다가오는 경기"
|
||||
/>
|
||||
|
||||
<TeamGameCardsSection
|
||||
defaultExpandedGameNumber={null}
|
||||
emptyMessage="아직 종료된 경기가 없습니다."
|
||||
gameByNumber={gameByNumber}
|
||||
match={match}
|
||||
participantByUserId={participantByUserId}
|
||||
parsedTeamIndex={parsedTeamIndex}
|
||||
teamByIndex={teamByIndex}
|
||||
slots={finishedSlots}
|
||||
title="종료된 경기"
|
||||
/>
|
||||
|
||||
<section className="border border-base-content/10 bg-base-100">
|
||||
<div className="border-b border-base-content/10 bg-base-200/40 px-4 py-2">
|
||||
<h2 className="text-xs font-bold uppercase tracking-wider text-base-content/40">
|
||||
팀 구성
|
||||
</h2>
|
||||
</div>
|
||||
<ParticipantLine
|
||||
participant={
|
||||
team.captainUserId
|
||||
? participantByUserId.get(team.captainUserId)
|
||||
: undefined
|
||||
}
|
||||
isCaptain
|
||||
/>
|
||||
{team.members.map((member) => (
|
||||
<ParticipantLine
|
||||
key={member.userId}
|
||||
participant={participantByUserId.get(member.userId)}
|
||||
assignedPosition={member.assignedPosition}
|
||||
/>
|
||||
))}
|
||||
<section className="mb-6" aria-labelledby="active-series-heading">
|
||||
<h2
|
||||
id="active-series-heading"
|
||||
className="mb-3 text-xs font-bold uppercase tracking-wider text-base-content/40"
|
||||
>
|
||||
진행할 Series
|
||||
</h2>
|
||||
{teamView.activeSeries.length > 0 ? (
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
{teamView.activeSeries.map((series) => (
|
||||
<SeriesScoreCard
|
||||
key={series.seriesId}
|
||||
series={series}
|
||||
teamById={teamById}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState message="현재 진행할 대진이 없습니다." />
|
||||
)}
|
||||
</section>
|
||||
|
||||
{replaceCodeSlot && (
|
||||
<div
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/55 px-4"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="team-tournament-code-replace-title"
|
||||
<section className="mb-6" aria-labelledby="codes-heading">
|
||||
<h2
|
||||
id="codes-heading"
|
||||
className="mb-3 text-xs font-bold uppercase tracking-wider text-base-content/40"
|
||||
>
|
||||
<div className="w-full max-w-md border border-warning/25 bg-base-100 p-5 shadow-2xl">
|
||||
<div className="flex items-start gap-3">
|
||||
<span className="inline-flex h-9 w-9 shrink-0 items-center justify-center border border-warning/25 bg-warning/10 text-warning">
|
||||
<AlertTriangle className="h-4 w-4" />
|
||||
</span>
|
||||
<div className="min-w-0">
|
||||
<h2
|
||||
id="team-tournament-code-replace-title"
|
||||
className="text-base font-bold text-base-content"
|
||||
>
|
||||
토너먼트 코드 교체
|
||||
</h2>
|
||||
<p className="mt-2 text-sm leading-6 text-base-content/60">
|
||||
정상적인 경기 진행이 불가한 경우 우리팀과 상대팀에
|
||||
상황을 알린 뒤 {replaceCodeSlot.gameNumber}경기 코드를
|
||||
교체하세요.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label
|
||||
htmlFor="team-tournament-code-replace-confirm"
|
||||
className="mt-5 block text-xs font-bold uppercase tracking-wider text-base-content/40"
|
||||
>
|
||||
계속하려면 예 입력
|
||||
</label>
|
||||
<input
|
||||
id="team-tournament-code-replace-confirm"
|
||||
value={replaceCodeConfirmText}
|
||||
onChange={(event) => setReplaceCodeConfirmText(event.target.value)}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "Escape") {
|
||||
closeReplaceTournamentCodeDialog();
|
||||
}
|
||||
if (
|
||||
event.key === "Enter" &&
|
||||
replaceCodeConfirmText.trim() === "예" &&
|
||||
!replaceTournamentCodeMutation.isPending
|
||||
) {
|
||||
handleConfirmReplaceTournamentCode();
|
||||
}
|
||||
}}
|
||||
className="mt-2 h-10 w-full border border-base-content/15 bg-base-100 px-3 text-sm text-base-content outline-none transition-colors focus:border-warning/60"
|
||||
placeholder="예"
|
||||
/>
|
||||
|
||||
<div className="mt-5 flex flex-wrap justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-ghost btn-sm px-4 text-xs"
|
||||
onClick={closeReplaceTournamentCodeDialog}
|
||||
disabled={replaceTournamentCodeMutation.isPending}
|
||||
토너먼트 코드
|
||||
</h2>
|
||||
{teamView.tournamentCodes.length > 0 ? (
|
||||
<ul className="grid gap-3 sm:grid-cols-2">
|
||||
{teamView.tournamentCodes.map((assignment) => (
|
||||
<li
|
||||
key={assignment.gameSlotId}
|
||||
className="border border-base-content/10 bg-base-100 p-4"
|
||||
>
|
||||
닫기
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-warning btn-sm px-4 text-xs"
|
||||
onClick={handleConfirmReplaceTournamentCode}
|
||||
disabled={
|
||||
replaceCodeConfirmText.trim() !== "예" ||
|
||||
replaceTournamentCodeMutation.isPending
|
||||
}
|
||||
>
|
||||
{replaceTournamentCodeMutation.isPending
|
||||
? "교체 중..."
|
||||
: "코드 교체 진행"}
|
||||
</button>
|
||||
</div>
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<span className="text-xs font-bold text-base-content/45">
|
||||
Game {assignment.displayNumber}
|
||||
</span>
|
||||
<span className="text-[11px] text-base-content/35">
|
||||
{assignment.state === "used"
|
||||
? "사용됨"
|
||||
: assignment.state === "reserved"
|
||||
? "사용 가능"
|
||||
: "발급 대기"}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-3 flex items-center gap-2">
|
||||
<code className="min-w-0 flex-1 truncate font-mono text-sm font-bold text-primary">
|
||||
{assignment.code ?? "발급 대기"}
|
||||
</code>
|
||||
{assignment.code && assignment.state !== "used" && (
|
||||
<button
|
||||
type="button"
|
||||
className="border border-base-content/10 px-2 py-1 text-xs font-bold hover:border-primary/30 hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
|
||||
onClick={() =>
|
||||
void copyCode(assignment.gameSlotId, assignment.code)
|
||||
}
|
||||
>
|
||||
{copiedSlotId === assignment.gameSlotId
|
||||
? "복사됨"
|
||||
: "복사"}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<EmptyState message="배정된 토너먼트 코드가 없습니다." />
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="mb-6" aria-labelledby="completed-heading">
|
||||
<h2
|
||||
id="completed-heading"
|
||||
className="mb-3 text-xs font-bold uppercase tracking-wider text-base-content/40"
|
||||
>
|
||||
종료된 Series
|
||||
</h2>
|
||||
{completedSeries.length > 0 ? (
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
{completedSeries.map((series) => (
|
||||
<SeriesScoreCard
|
||||
key={series.seriesId}
|
||||
series={series}
|
||||
teamById={teamById}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState message="아직 종료된 대진이 없습니다." />
|
||||
)}
|
||||
</section>
|
||||
|
||||
{team && (
|
||||
<section className="border border-base-content/10 bg-base-100">
|
||||
<h2 className="border-b border-base-content/10 bg-base-200/40 px-4 py-2 text-xs font-bold uppercase tracking-wider text-base-content/40">
|
||||
팀 구성
|
||||
</h2>
|
||||
<ul className="divide-y divide-base-content/8">
|
||||
{team.members.map((member) => (
|
||||
<li
|
||||
key={member.userId}
|
||||
className="flex items-center gap-3 px-4 py-3"
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="truncate text-sm font-bold">
|
||||
{member.displayName}
|
||||
</p>
|
||||
{member.assignedPosition && (
|
||||
<p className="mt-0.5 text-xs text-base-content/35">
|
||||
{member.assignedPosition}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{member.userId === team.captainUserId && (
|
||||
<span className="text-xs font-bold text-warning">팀장</span>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function EmptyState({ message }: { message: string }) {
|
||||
return (
|
||||
<p
|
||||
role="status"
|
||||
className="border border-dashed border-base-content/10 px-4 py-8 text-center text-sm text-base-content/40"
|
||||
>
|
||||
{message}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
@@ -32,7 +32,6 @@ const DEFAULT_FORM: MatchMutationRequest = {
|
||||
|
||||
const GAME_MODE_LABEL: Record<MatchGameMode, string> = {
|
||||
pair: '페어',
|
||||
bracket: '브래킷',
|
||||
'round-robin': '라운드 로빈',
|
||||
'double-elimination': '더블 엘리미네이션',
|
||||
};
|
||||
@@ -131,7 +130,7 @@ function makeForm(match?: ApiMatch): MatchMutationRequest & {
|
||||
gameMode: match.gameMode ?? 'pair',
|
||||
roundRobinMaxRounds: match.roundRobinMaxRounds,
|
||||
doubleEliminationResetFinalEnabled:
|
||||
match.doubleElimination?.resetFinalEnabled ?? true,
|
||||
match.doubleEliminationResetFinalEnabled ?? true,
|
||||
prizes: match.prizes,
|
||||
notices: match.notices,
|
||||
schedule: match.schedule,
|
||||
@@ -533,7 +532,7 @@ export default function MatchAdminPage() {
|
||||
{match.gameMode === 'double-elimination' && (
|
||||
<span className="block text-xs text-base-content/30">
|
||||
GF 리셋{' '}
|
||||
{match.doubleElimination?.resetFinalEnabled
|
||||
{match.doubleEliminationResetFinalEnabled
|
||||
? '허용'
|
||||
: '없음'}
|
||||
</span>
|
||||
|
||||
Reference in new issue
Block a user