This commit is contained in:
dahyeon committed 2026-05-02 02:59:33 -07:00
1 parent b152a5b0fa
commit 2379051196
32 files changed
+1682 -383

No files matched your search

+21
View File
@@ -30,6 +30,7 @@ import type {
StartLegacyImportRequest,
StartLegacyImportResponse,
MatchStatus,
MatchMutationRequest,
MatchesResponse,
MeResponse,
RiotQueueGroup,
@@ -130,6 +131,26 @@ export function useAuction(
});
}
export function useCreateMatch(communityId = DEFAULT_COMMUNITY_ID) {
return useMutation({
mutationFn: (body: MatchMutationRequest) =>
apiFetch<ApiMatch>(`/communities/${communityId}/matches`, {
method: 'POST',
body: JSON.stringify(body),
}),
});
}
export function useUpdateMatch(communityId = DEFAULT_COMMUNITY_ID) {
return useMutation({
mutationFn: ({ matchId, body }: { matchId: string; body: Partial<MatchMutationRequest> }) =>
apiFetch<ApiMatch>(`/communities/${communityId}/matches/${matchId}`, {
method: 'PATCH',
body: JSON.stringify(body),
}),
});
}
function createUserHistoryPath(
communityId: string,
userId: string,
+31 -24
View File
@@ -25,6 +25,7 @@ export interface ParticipantView {
mainPosition: Position;
subPosition: Position;
profileIconId: number;
excluded?: boolean;
}
export interface TeamParticipantView extends ParticipantView {
@@ -34,6 +35,7 @@ export interface TeamParticipantView extends ParticipantView {
export interface TeamView {
side: TeamSide;
groupIndex: number;
name: string;
participants: TeamParticipantView[];
}
@@ -48,6 +50,7 @@ export interface MatchDetailView {
map: string;
maxParticipants: number;
gameCount: number;
gameMode: ApiMatch["gameMode"];
tournamentCodes: TournamentCodeSlotView[];
joined: boolean;
participants: ParticipantView[];
@@ -62,6 +65,8 @@ export interface MatchDetailView {
gameNumber: number;
riotMatchId: string;
winnerSide: TeamSide;
blueGroupIndex: number;
redGroupIndex: number;
gameCreation: number;
gameDuration: number;
participants: Array<{
@@ -74,6 +79,7 @@ export interface MatchDetailView {
win: boolean;
}>;
}>;
seriesResults: NonNullable<ApiMatch["result"]>["seriesResults"];
};
prizes: string[];
notices: string[];
@@ -96,6 +102,7 @@ export interface AuctionPlayerView extends ParticipantView {
export interface AuctionTeamView {
side: TeamSide;
groupIndex: number;
captainUserId: string;
captainName: string;
points: number;
@@ -108,18 +115,19 @@ export interface AuctionTeamView {
export interface AuctionStateView {
matchId: string;
phase: ApiAuction["phase"];
teams: [AuctionTeamView, AuctionTeamView];
teams: AuctionTeamView[];
currentPlayer: AuctionPlayerView | null;
currentPlayerIndex: number;
totalPlayers: number;
auctionOrder: AuctionPlayerView[];
bids: {
side: TeamSide;
groupIndex: number;
amount: number;
timestamp: string;
}[];
currentBid: number;
currentBidder: TeamSide | null;
currentBidder: { side: TeamSide; groupIndex: number } | null;
timer: number;
maxTimer: number;
deadline?: string;
@@ -208,6 +216,7 @@ function mapMatchParticipantToView(
mainPosition,
subPosition,
profileIconId: participant.profileIconId ?? 0,
excluded: participant.excluded ?? false,
};
}
@@ -262,6 +271,7 @@ function mapAuctionTeamToView(
): AuctionTeamView {
return {
side: team.side,
groupIndex: team.groupIndex ?? 1,
captainUserId: team.captainUserId,
captainName:
participantLookup.get(team.captainUserId)?.summonerName ??
@@ -396,6 +406,7 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
const teams = match.teams.map((team) => ({
side: team.side,
groupIndex: team.groupIndex ?? 1,
name: team.name || sideLabel(team.side),
participants: team.members.map((member) => {
const participant =
@@ -423,7 +434,8 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
description: match.description,
map: mapIdToLabel(match.mapId),
maxParticipants: match.maxParticipants,
gameCount: match.gameCount ?? 3,
gameCount: match.gameCount ?? 3,
gameMode: match.gameMode ?? "pair",
tournamentCodes: match.tournamentCodes ?? [],
joined: Boolean(match.joined),
participants,
@@ -440,6 +452,7 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
games: [...(match.result.games ?? [])].sort(
(left, right) => left.gameNumber - right.gameNumber,
),
seriesResults: match.result.seriesResults ?? [],
}
: undefined,
prizes: match.prizes,
@@ -462,22 +475,11 @@ export function mapApiAuctionToAuctionState(
const auctionPlayerLookup = new Map(
auctionOrder.map((player) => [player.userId, player]),
);
const blueTeam =
auction.teams.find((team) => team.side === "blue") ??
({
side: "blue",
captainUserId: "",
points: 0,
members: [],
} satisfies ApiAuctionTeam);
const redTeam =
auction.teams.find((team) => team.side === "red") ??
({
side: "red",
captainUserId: "",
points: 0,
members: [],
} satisfies ApiAuctionTeam);
const teams = [...auction.teams].sort(
(left, right) =>
(left.groupIndex ?? 1) - (right.groupIndex ?? 1) ||
(left.side === "blue" ? -1 : 1),
);
const totalPlayers = auctionOrder.length;
const currentPlayer =
@@ -500,21 +502,26 @@ export function mapApiAuctionToAuctionState(
return {
matchId: auction.matchId,
phase: auction.phase,
teams: [
mapAuctionTeamToView(blueTeam, auctionPlayerLookup, participantLookup),
mapAuctionTeamToView(redTeam, auctionPlayerLookup, participantLookup),
],
teams: teams.map((team) =>
mapAuctionTeamToView(team, auctionPlayerLookup, participantLookup),
),
currentPlayer,
currentPlayerIndex,
totalPlayers,
auctionOrder,
bids: auction.bids.map((bid) => ({
side: bid.side,
groupIndex: bid.groupIndex ?? 1,
amount: bid.amount,
timestamp: bid.timestamp,
})),
currentBid: auction.currentBid,
currentBidder: auction.currentBidder ?? null,
currentBidder: auction.currentBidder
? {
side: auction.currentBidder,
groupIndex: auction.currentBidderGroupIndex ?? 1,
}
: null,
timer,
maxTimer: auction.maxTimerSeconds,
deadline: auction.currentDeadline,
+31
View File
@@ -1,6 +1,7 @@
export type Position = 'TOP' | 'JGL' | 'MID' | 'ADC' | 'SUP';
export type RiotLane = 'TOP' | 'JUNGLE' | 'MIDDLE' | 'BOTTOM' | 'UTILITY';
export type TeamSide = 'blue' | 'red';
export type MatchGameMode = 'pair' | 'bracket' | 'round-robin';
export type MatchStatus =
| 'recruiting'
| 'team-built'
@@ -116,6 +117,8 @@ export type TournamentCodeSlotState = TournamentCodeState | 'pending';
export interface TournamentCodeSlotView {
gameNumber: number;
blueGroupIndex: number;
redGroupIndex: number;
code: string | null;
expiresAt: string | null;
state: TournamentCodeSlotState;
@@ -131,6 +134,7 @@ export interface ApiMatchParticipant {
tier?: ApiTierInfo;
preferredPositions: ApiPositionPreference[];
joinedAt: string;
excluded?: boolean;
}
export interface ApiMatchTeamMember {
@@ -141,6 +145,7 @@ export interface ApiMatchTeamMember {
export interface ApiMatchTeam {
side: TeamSide;
groupIndex: number;
name: string;
captainUserId?: string;
members: ApiMatchTeamMember[];
@@ -160,6 +165,8 @@ export interface ApiMatchGameResult {
gameNumber: number;
riotMatchId: string;
winnerSide: TeamSide;
blueGroupIndex: number;
redGroupIndex: number;
gameCreation: number;
gameDuration: number;
participants: ApiMatchGameResultParticipant[];
@@ -172,6 +179,13 @@ export interface ApiMatchResult {
mvpUserId?: string;
riotMatchIds: string[];
games: ApiMatchGameResult[];
seriesResults?: Array<{
blueGroupIndex: number;
redGroupIndex: number;
blueScore: number;
redScore: number;
winnerSide?: TeamSide;
}>;
}
export interface ApiMatchScheduleItem {
@@ -189,6 +203,7 @@ export interface ApiMatch {
scheduledAt: string;
maxParticipants: number;
gameCount: number;
gameMode: MatchGameMode;
tournamentCodes?: TournamentCodeSlotView[];
hostUserId?: string;
participants: ApiMatchParticipant[];
@@ -222,6 +237,7 @@ export interface ApiAuctionTeamMember {
export interface ApiAuctionTeam {
side: TeamSide;
groupIndex: number;
captainUserId: string;
points: number;
members: ApiAuctionTeamMember[];
@@ -229,6 +245,7 @@ export interface ApiAuctionTeam {
export interface ApiAuctionBid {
side: TeamSide;
groupIndex?: number;
amount: number;
bidderUserId: string;
timestamp: string;
@@ -244,6 +261,7 @@ export interface ApiAuction {
bids: ApiAuctionBid[];
currentBid: number;
currentBidder?: TeamSide;
currentBidderGroupIndex?: number;
maxTimerSeconds: number;
currentDeadline?: string;
initialPoints: number;
@@ -275,6 +293,19 @@ export interface MatchesResponse {
matches: ApiMatch[];
}
export interface MatchMutationRequest {
title: string;
description?: string;
mapId?: number;
scheduledAt: string;
maxParticipants?: number;
gameCount?: number;
gameMode?: MatchGameMode;
prizes?: string[];
notices?: string[];
schedule?: ApiMatchScheduleItem[];
}
export interface DdragonChampionEntry {
key: string;
name: string;
+1
View File
@@ -13,6 +13,7 @@ type ConnectionStatus =
interface BidPayload {
side: TeamSide;
groupIndex?: number;
amount: number;
bidderUserId?: string;
}