This commit is contained in:
dahyeon committed 2026-05-02 04:05:35 -07:00
1 parent 4baea89f89
commit fd386ed202
32 files changed
+1128 -601

No files matched your search

+28 -40
View File
@@ -11,10 +11,9 @@ import type {
MatchStatus,
Position,
RiotLane,
TeamSide,
TournamentCodeSlotView,
} from "./types";
import { POSITION_ORDER, sideLabel } from "../lib/league";
import { POSITION_ORDER, teamIndexLabel } from "../lib/league";
export interface ParticipantView {
id: string;
@@ -34,8 +33,7 @@ export interface TeamParticipantView extends ParticipantView {
}
export interface TeamView {
side: TeamSide;
groupIndex: number;
teamIndex: number;
name: string;
participants: TeamParticipantView[];
}
@@ -57,21 +55,21 @@ export interface MatchDetailView {
teams: TeamView[];
result?: {
winner?: string;
winnerSide?: TeamSide;
blueScore: number;
redScore: number;
winnerTeamIndex?: number;
riotMatchIds: string[];
games: Array<{
gameNumber: number;
riotMatchId: string;
winnerSide: TeamSide;
blueGroupIndex: number;
redGroupIndex: number;
blueTeamIndex: number;
redTeamIndex: number;
winnerTeamIndex: number;
winnerSide: "blue" | "red";
gameCreation: number;
gameDuration: number;
participants: Array<{
userId: string;
side: TeamSide;
teamIndex: number;
side: "blue" | "red";
championId: number;
kills: number;
deaths: number;
@@ -101,8 +99,8 @@ export interface AuctionPlayerView extends ParticipantView {
}
export interface AuctionTeamView {
side: TeamSide;
groupIndex: number;
teamIndex: number;
name: string;
captainUserId: string;
captainName: string;
points: number;
@@ -121,13 +119,12 @@ export interface AuctionStateView {
totalPlayers: number;
auctionOrder: AuctionPlayerView[];
bids: {
side: TeamSide;
groupIndex: number;
teamIndex: number;
amount: number;
timestamp: string;
}[];
currentBid: number;
currentBidder: { side: TeamSide; groupIndex: number } | null;
currentBidder: { teamIndex: number } | null;
timer: number;
maxTimer: number;
deadline?: string;
@@ -270,8 +267,8 @@ function mapAuctionTeamToView(
participantLookup: Map<string, ParticipantView>,
): AuctionTeamView {
return {
side: team.side,
groupIndex: team.groupIndex ?? 1,
teamIndex: team.teamIndex,
name: teamIndexLabel(team.teamIndex),
captainUserId: team.captainUserId,
captainName:
participantLookup.get(team.captainUserId)?.summonerName ??
@@ -405,9 +402,8 @@ 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),
teamIndex: team.teamIndex,
name: teamIndexLabel(team.teamIndex, team.name),
participants: team.members.map((member) => {
const participant =
participantLookup.get(member.userId) ??
@@ -421,8 +417,8 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
}),
}));
const winnerTeam = match.result?.winnerSide
? teams.find((team) => team.side === match.result?.winnerSide)
const winnerTeam = match.result?.winnerTeamIndex
? teams.find((team) => team.teamIndex === match.result?.winnerTeamIndex)
: undefined;
return {
@@ -434,20 +430,16 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
description: match.description,
map: mapIdToLabel(match.mapId),
maxParticipants: match.maxParticipants,
gameCount: match.gameCount ?? 3,
gameMode: match.gameMode ?? "pair",
gameCount: match.gameCount ?? 3,
gameMode: match.gameMode ?? "pair",
tournamentCodes: match.tournamentCodes ?? [],
joined: Boolean(match.joined),
participants,
teams,
result: match.result
? {
winner: match.result.winnerSide
? winnerTeam?.name ?? sideLabel(match.result.winnerSide)
: undefined,
winnerSide: match.result.winnerSide,
blueScore: match.result.blueScore,
redScore: match.result.redScore,
? {
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,
@@ -476,9 +468,7 @@ export function mapApiAuctionToAuctionState(
auctionOrder.map((player) => [player.userId, player]),
);
const teams = [...auction.teams].sort(
(left, right) =>
(left.groupIndex ?? 1) - (right.groupIndex ?? 1) ||
(left.side === "blue" ? -1 : 1),
(left, right) => left.teamIndex - right.teamIndex,
);
const totalPlayers = auctionOrder.length;
@@ -510,16 +500,14 @@ export function mapApiAuctionToAuctionState(
totalPlayers,
auctionOrder,
bids: auction.bids.map((bid) => ({
side: bid.side,
groupIndex: bid.groupIndex ?? 1,
teamIndex: bid.teamIndex,
amount: bid.amount,
timestamp: bid.timestamp,
})),
currentBid: auction.currentBid,
currentBidder: auction.currentBidder
currentBidder: auction.currentBidderTeamIndex
? {
side: auction.currentBidder,
groupIndex: auction.currentBidderGroupIndex ?? 1,
teamIndex: auction.currentBidderTeamIndex,
}
: null,
timer,
+35 -27
View File
@@ -117,8 +117,8 @@ export type TournamentCodeSlotState = TournamentCodeState | 'pending';
export interface TournamentCodeSlotView {
gameNumber: number;
blueGroupIndex: number;
redGroupIndex: number;
teamAIndex: number;
teamBIndex: number;
code: string | null;
expiresAt: string | null;
state: TournamentCodeSlotState;
@@ -144,8 +144,7 @@ export interface ApiMatchTeamMember {
}
export interface ApiMatchTeam {
side: TeamSide;
groupIndex: number;
teamIndex: number;
name: string;
captainUserId?: string;
members: ApiMatchTeamMember[];
@@ -153,6 +152,7 @@ export interface ApiMatchTeam {
export interface ApiMatchGameResultParticipant {
userId: string;
teamIndex: number;
side: TeamSide;
championId: number;
kills: number;
@@ -164,27 +164,26 @@ export interface ApiMatchGameResultParticipant {
export interface ApiMatchGameResult {
gameNumber: number;
riotMatchId: string;
blueTeamIndex: number;
redTeamIndex: number;
winnerTeamIndex: number;
winnerSide: TeamSide;
blueGroupIndex: number;
redGroupIndex: number;
gameCreation: number;
gameDuration: number;
participants: ApiMatchGameResultParticipant[];
}
export interface ApiMatchResult {
winnerSide?: TeamSide;
blueScore: number;
redScore: number;
winnerTeamIndex?: number;
mvpUserId?: string;
riotMatchIds: string[];
games: ApiMatchGameResult[];
seriesResults?: Array<{
blueGroupIndex: number;
redGroupIndex: number;
blueScore: number;
redScore: number;
winnerSide?: TeamSide;
teamAIndex: number;
teamBIndex: number;
teamAWins: number;
teamBWins: number;
winnerTeamIndex?: number;
}>;
}
@@ -236,16 +235,14 @@ export interface ApiAuctionTeamMember {
}
export interface ApiAuctionTeam {
side: TeamSide;
groupIndex: number;
teamIndex: number;
captainUserId: string;
points: number;
members: ApiAuctionTeamMember[];
}
export interface ApiAuctionBid {
side: TeamSide;
groupIndex?: number;
teamIndex: number;
amount: number;
bidderUserId: string;
timestamp: string;
@@ -260,8 +257,7 @@ export interface ApiAuction {
currentIndex: number;
bids: ApiAuctionBid[];
currentBid: number;
currentBidder?: TeamSide;
currentBidderGroupIndex?: number;
currentBidderTeamIndex?: number;
maxTimerSeconds: number;
currentDeadline?: string;
initialPoints: number;
@@ -520,17 +516,25 @@ export interface ApiInternalMatchCard {
scheduledAt: string;
status: 'finished' | 'in-progress';
gameCount: number;
blueScore: number;
redScore: number;
winnerSide?: TeamSide;
winnerTeamIndex?: number;
seriesResults: Array<{
teamAIndex: number;
teamBIndex: number;
teamAWins: number;
teamBWins: number;
winnerTeamIndex?: number;
}>;
games: Array<{
gameNumber: number;
riotMatchId: string | null;
blueTeamIndex: number;
redTeamIndex: number;
winnerTeamIndex: number | null;
winnerSide: TeamSide | null;
gameDuration: number;
}>;
teams: Array<{
side: TeamSide;
teamIndex: number;
name: string;
members: Array<{
userId: string;
@@ -605,12 +609,14 @@ export interface ApiInternalMatchDetailResponse {
gameCreation: number;
gameDuration: number;
teams: Array<{
teamIndex: number;
side: TeamSide;
win: boolean;
objectives: { baron: number; dragon: number; tower: number };
participants: Array<{
userId: string | null;
summonerName: string;
teamIndex: number;
side: TeamSide;
teamPosition: string;
championId: number;
@@ -725,9 +731,11 @@ export interface LegacyMatchListItem {
riotMatchId: string | null;
memberCount: number;
externalCount: number;
blueScore: number;
redScore: number;
winnerSide?: TeamSide;
teamAIndex: number;
teamBIndex: number;
teamAWins: number;
teamBWins: number;
winnerTeamIndex?: number;
}
export interface LegacyMatchListResponse {
+2 -3
View File
@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react';
import { io, type Socket } from 'socket.io-client';
import { API_BASE_URL, useAuthUserId } from '../config';
import { acquireAccessToken } from '../lib/auth/token-provider';
import type { ApiAuction, Position, TeamSide } from './types';
import type { ApiAuction, Position } from './types';
type ConnectionStatus =
| 'idle'
@@ -12,8 +12,7 @@ type ConnectionStatus =
| 'error';
interface BidPayload {
side: TeamSide;
groupIndex?: number;
teamIndex: number;
amount: number;
bidderUserId?: string;
}