Files
gridpilot.gg/apps/website/lib/services/races/RaceService.ts
2025-12-18 01:20:23 +01:00

45 lines
1.2 KiB
TypeScript

import { RacesApiClient } from '../../api/races/RacesApiClient';
import { RaceDetailViewModel } from '../../view-models/RaceDetailViewModel';
// TODO: Move these types to apps/website/lib/types/generated when available
type RacesPageDataDto = { races: Array<any> };
type RaceStatsDto = { totalRaces: number };
/**
* Race Service
*
* Orchestrates race operations by coordinating API calls and view model creation.
* All dependencies are injected via constructor.
*/
export class RaceService {
constructor(
private readonly apiClient: RacesApiClient
) {}
/**
* Get race detail with view model transformation
*/
async getRaceDetail(
raceId: string,
driverId: string
): Promise<RaceDetailViewModel> {
const dto = await this.apiClient.getDetail(raceId, driverId);
return new RaceDetailViewModel(dto);
}
/**
* Get races page data
* TODO: Add view model transformation when view model is available
*/
async getRacesPageData(): Promise<RacesPageDataDto> {
return this.apiClient.getPageData();
}
/**
* Get total races statistics
* TODO: Add view model transformation when view model is available
*/
async getRacesTotal(): Promise<RaceStatsDto> {
return this.apiClient.getTotal();
}
}