play walkout songs
This commit is contained in:
@@ -100,7 +100,7 @@ export function createPlayersService(pb: PocketBase) {
|
||||
expand: "tournament,home,away",
|
||||
});
|
||||
|
||||
return result.map(transformMatch);
|
||||
return result.map((match) => transformMatch(match));
|
||||
},
|
||||
|
||||
async getUnenrolledPlayers(tournamentId: string): Promise<Player[]> {
|
||||
|
||||
@@ -100,7 +100,7 @@ export function createTeamsService(pb: PocketBase) {
|
||||
expand: "tournament,home,away",
|
||||
});
|
||||
|
||||
return result.map(transformMatch);
|
||||
return result.map((match) => transformMatch(match));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ import { PlayerInfo } from "@/features/players/types";
|
||||
|
||||
export function createTournamentsService(pb: PocketBase) {
|
||||
return {
|
||||
async getTournament(id: string): Promise<Tournament> {
|
||||
async getTournament(id: string, isAdmin: boolean = false): Promise<Tournament> {
|
||||
const result = await pb.collection("tournaments").getOne(id, {
|
||||
expand: "teams, teams.players, matches, matches.tournament, matches.home, matches.away, matches.home.players, matches.away.players",
|
||||
});
|
||||
return transformTournament(result);
|
||||
return transformTournament(result, isAdmin);
|
||||
},
|
||||
async getMostRecentTournament(): Promise<Tournament> {
|
||||
const result = await pb
|
||||
|
||||
@@ -27,7 +27,7 @@ export function transformTeamInfo(record: any): TeamInfo {
|
||||
};
|
||||
}
|
||||
|
||||
export const transformMatch = (record: any): Match => {
|
||||
export const transformMatch = (record: any, isAdmin: boolean = false): Match => {
|
||||
return {
|
||||
id: record.id,
|
||||
order: record.order,
|
||||
@@ -47,8 +47,8 @@ export const transformMatch = (record: any): Match => {
|
||||
is_losers_bracket: record.is_losers_bracket,
|
||||
status: record.status || "tbd",
|
||||
tournament: record.expand?.tournament ? transformTournamentInfo(record.expand?.tournament) : record.tournament,
|
||||
home: record.expand?.home ? transformTeamInfo(record.expand.home) : record.home,
|
||||
away: record.expand?.away ? transformTeamInfo(record.expand.away) : record.away,
|
||||
home: record.expand?.home ? (isAdmin ? transformTeam(record.expand.home) : transformTeamInfo(record.expand.home)) : record.home,
|
||||
away: record.expand?.away ? (isAdmin ? transformTeam(record.expand.away) : transformTeamInfo(record.expand.away)) : record.away,
|
||||
created: record.created,
|
||||
updated: record.updated,
|
||||
home_seed: record.home_seed,
|
||||
@@ -135,20 +135,20 @@ export function transformTeam(record: any): Team {
|
||||
};
|
||||
}
|
||||
|
||||
export function transformTournament(record: any): Tournament {
|
||||
export function transformTournament(record: any, isAdmin: boolean = false): Tournament {
|
||||
const teams =
|
||||
record.expand?.teams
|
||||
?.sort((a: any, b: any) =>
|
||||
new Date(a.created) < new Date(b.created) ? -1 : 0
|
||||
)
|
||||
?.map(transformTeamInfo) ?? [];
|
||||
?.map(isAdmin ? transformTeam : transformTeamInfo) ?? [];
|
||||
|
||||
const matches =
|
||||
record.expand?.matches
|
||||
?.sort((a: any, b: any) =>
|
||||
a.lid - b.lid ? -1 : 0
|
||||
)
|
||||
?.map(transformMatch) ?? [];
|
||||
?.map((match: any) => transformMatch(match, isAdmin)) ?? [];
|
||||
|
||||
return {
|
||||
id: record.id,
|
||||
|
||||
Reference in New Issue
Block a user