refactor page to use services

This commit is contained in:
2025-12-18 15:58:09 +01:00
parent f54fa5de5b
commit fc386db06a
45 changed files with 2254 additions and 1292 deletions

View File

@@ -153,6 +153,37 @@ export class LeagueController {
return this.leagueService.getLeagueProtests(query);
}
@Get(':leagueId/protests/:protestId')
@ApiOperation({ summary: 'Get a specific protest for a league' })
@ApiResponse({ status: 200, description: 'Protest details', type: LeagueAdminProtestsDTO })
async getLeagueProtest(
@Param('leagueId') leagueId: string,
@Param('protestId') protestId: string,
): Promise<LeagueAdminProtestsDTO> {
const query: GetLeagueProtestsQuery = { leagueId };
const allProtests = await this.leagueService.getLeagueProtests(query);
// Filter to only include the specific protest
const protest = allProtests.protests.find(p => p.id === protestId);
if (!protest) {
throw new Error('Protest not found');
}
// Find the race for this protest
const race = allProtests.racesById[protest.raceId];
const protestingDriver = allProtests.driversById[protest.protestingDriverId];
const accusedDriver = allProtests.driversById[protest.accusedDriverId];
return {
protests: [protest],
racesById: race ? { [race.id]: race } : {},
driversById: {
...(protestingDriver ? { [protestingDriver.id]: protestingDriver } : {}),
...(accusedDriver ? { [accusedDriver.id]: accusedDriver } : {}),
},
};
}
@Get(':leagueId/seasons')
@ApiOperation({ summary: 'Get seasons for a league' })
@ApiResponse({ status: 200, description: 'List of seasons for the league', type: [LeagueSeasonSummaryDTO] })