refactor
This commit is contained in:
@@ -291,6 +291,161 @@ export interface RaceStatsDto {
|
||||
totalRaces: number;
|
||||
}
|
||||
|
||||
// Race Management Types
|
||||
export interface RaceDetailEntryViewModel {
|
||||
id: string;
|
||||
name: string;
|
||||
country: string;
|
||||
avatarUrl: string;
|
||||
rating: number | null;
|
||||
isCurrentUser: boolean;
|
||||
}
|
||||
|
||||
export interface RaceDetailUserResultViewModel {
|
||||
position: number;
|
||||
startPosition: number;
|
||||
incidents: number;
|
||||
fastestLap: number;
|
||||
positionChange: number;
|
||||
isPodium: boolean;
|
||||
isClean: boolean;
|
||||
ratingChange: number | null;
|
||||
}
|
||||
|
||||
export interface RaceDetailRaceViewModel {
|
||||
id: string;
|
||||
leagueId: string;
|
||||
track: string;
|
||||
car: string;
|
||||
scheduledAt: string;
|
||||
sessionType: string;
|
||||
status: string;
|
||||
strengthOfField: number | null;
|
||||
registeredCount?: number;
|
||||
maxParticipants?: number;
|
||||
}
|
||||
|
||||
export interface RaceDetailLeagueViewModel {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
settings: {
|
||||
maxDrivers?: number;
|
||||
qualifyingFormat?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface RaceDetailRegistrationViewModel {
|
||||
isUserRegistered: boolean;
|
||||
canRegister: boolean;
|
||||
}
|
||||
|
||||
export interface RaceDetailViewModel {
|
||||
race: RaceDetailRaceViewModel | null;
|
||||
league: RaceDetailLeagueViewModel | null;
|
||||
entryList: RaceDetailEntryViewModel[];
|
||||
registration: RaceDetailRegistrationViewModel;
|
||||
userResult: RaceDetailUserResultViewModel | null;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface RacesPageDataRaceViewModel {
|
||||
id: string;
|
||||
track: string;
|
||||
car: string;
|
||||
scheduledAt: string;
|
||||
status: string;
|
||||
leagueId: string;
|
||||
leagueName: string;
|
||||
strengthOfField: number | null;
|
||||
isUpcoming: boolean;
|
||||
isLive: boolean;
|
||||
isPast: boolean;
|
||||
}
|
||||
|
||||
export interface RacesPageDataViewModel {
|
||||
races: RacesPageDataRaceViewModel[];
|
||||
}
|
||||
|
||||
export interface RaceResultViewModel {
|
||||
driverId: string;
|
||||
driverName: string;
|
||||
avatarUrl: string;
|
||||
position: number;
|
||||
startPosition: number;
|
||||
incidents: number;
|
||||
fastestLap: number;
|
||||
positionChange: number;
|
||||
isPodium: boolean;
|
||||
isClean: boolean;
|
||||
}
|
||||
|
||||
export interface RaceResultsDetailViewModel {
|
||||
raceId: string;
|
||||
track: string;
|
||||
results: RaceResultViewModel[];
|
||||
}
|
||||
|
||||
export interface RaceWithSOFViewModel {
|
||||
id: string;
|
||||
track: string;
|
||||
strengthOfField: number | null;
|
||||
}
|
||||
|
||||
export interface RaceProtestViewModel {
|
||||
id: string;
|
||||
protestingDriverId: string;
|
||||
accusedDriverId: string;
|
||||
incident: {
|
||||
lap: number;
|
||||
description: string;
|
||||
};
|
||||
status: string;
|
||||
filedAt: string;
|
||||
}
|
||||
|
||||
export interface RaceProtestsViewModel {
|
||||
protests: RaceProtestViewModel[];
|
||||
driverMap: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface RacePenaltyViewModel {
|
||||
id: string;
|
||||
driverId: string;
|
||||
type: string;
|
||||
value: number;
|
||||
reason: string;
|
||||
issuedBy: string;
|
||||
issuedAt: string;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
export interface RacePenaltiesViewModel {
|
||||
penalties: RacePenaltyViewModel[];
|
||||
driverMap: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface RegisterForRaceParams {
|
||||
leagueId: string;
|
||||
driverId: string;
|
||||
}
|
||||
|
||||
export interface WithdrawFromRaceParams {
|
||||
driverId: string;
|
||||
}
|
||||
|
||||
export interface ImportRaceResultsInput {
|
||||
resultsFileContent: string;
|
||||
}
|
||||
|
||||
export interface ImportRaceResultsSummaryViewModel {
|
||||
success: boolean;
|
||||
raceId: string;
|
||||
driversProcessed: number;
|
||||
resultsRecorded: number;
|
||||
errors?: string[];
|
||||
}
|
||||
|
||||
// Sponsor Types
|
||||
export interface GetEntitySponsorshipPricingResultDto {
|
||||
mainSlotPrice: number;
|
||||
@@ -738,6 +893,66 @@ class RacesApiClient extends BaseApiClient {
|
||||
getTotal(): Promise<RaceStatsDto> {
|
||||
return this.get<RaceStatsDto>('/races/total-races');
|
||||
}
|
||||
|
||||
/** Get races page data */
|
||||
getPageData(): Promise<RacesPageDataViewModel> {
|
||||
return this.get<RacesPageDataViewModel>('/races/page-data');
|
||||
}
|
||||
|
||||
/** Get all races page data */
|
||||
getAllPageData(): Promise<RacesPageDataViewModel> {
|
||||
return this.get<RacesPageDataViewModel>('/races/all/page-data');
|
||||
}
|
||||
|
||||
/** Get race detail */
|
||||
getDetail(raceId: string, driverId: string): Promise<RaceDetailViewModel> {
|
||||
return this.get<RaceDetailViewModel>(`/races/${raceId}?driverId=${driverId}`);
|
||||
}
|
||||
|
||||
/** Get race results detail */
|
||||
getResultsDetail(raceId: string): Promise<RaceResultsDetailViewModel> {
|
||||
return this.get<RaceResultsDetailViewModel>(`/races/${raceId}/results`);
|
||||
}
|
||||
|
||||
/** Get race with strength of field */
|
||||
getWithSOF(raceId: string): Promise<RaceWithSOFViewModel> {
|
||||
return this.get<RaceWithSOFViewModel>(`/races/${raceId}/sof`);
|
||||
}
|
||||
|
||||
/** Get race protests */
|
||||
getProtests(raceId: string): Promise<RaceProtestsViewModel> {
|
||||
return this.get<RaceProtestsViewModel>(`/races/${raceId}/protests`);
|
||||
}
|
||||
|
||||
/** Get race penalties */
|
||||
getPenalties(raceId: string): Promise<RacePenaltiesViewModel> {
|
||||
return this.get<RacePenaltiesViewModel>(`/races/${raceId}/penalties`);
|
||||
}
|
||||
|
||||
/** Register for race */
|
||||
register(raceId: string, params: RegisterForRaceParams): Promise<void> {
|
||||
return this.post<void>(`/races/${raceId}/register`, params);
|
||||
}
|
||||
|
||||
/** Withdraw from race */
|
||||
withdraw(raceId: string, params: WithdrawFromRaceParams): Promise<void> {
|
||||
return this.post<void>(`/races/${raceId}/withdraw`, params);
|
||||
}
|
||||
|
||||
/** Cancel race */
|
||||
cancel(raceId: string): Promise<void> {
|
||||
return this.post<void>(`/races/${raceId}/cancel`, {});
|
||||
}
|
||||
|
||||
/** Complete race */
|
||||
complete(raceId: string): Promise<void> {
|
||||
return this.post<void>(`/races/${raceId}/complete`, {});
|
||||
}
|
||||
|
||||
/** Import race results */
|
||||
importResults(raceId: string, input: ImportRaceResultsInput): Promise<ImportRaceResultsSummaryViewModel> {
|
||||
return this.post<ImportRaceResultsSummaryViewModel>(`/races/${raceId}/import-results`, input);
|
||||
}
|
||||
}
|
||||
|
||||
class SponsorsApiClient extends BaseApiClient {
|
||||
|
||||
Reference in New Issue
Block a user