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
+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[];
|
||||
|
||||
Reference in new issue
Block a user