40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import type { DriversLeaderboardDTO } from '@/lib/types/generated/DriversLeaderboardDTO';
|
|
import type { DriversViewData } from '@/lib/view-data/DriversViewData';
|
|
import { RatingDisplay } from '@/lib/display-objects/RatingDisplay';
|
|
import { NumberDisplay } from '@/lib/display-objects/NumberDisplay';
|
|
|
|
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
|
|
|
|
export class DriversViewDataBuilder implements ViewDataBuilder<any, any> {
|
|
build(input: any): any {
|
|
return DriversViewDataBuilder.build(input);
|
|
}
|
|
|
|
static build(
|
|
static build(dto: DriversLeaderboardDTO): DriversViewData {
|
|
return {
|
|
drivers: dto.drivers.map(driver => ({
|
|
id: driver.id,
|
|
name: driver.name,
|
|
rating: driver.rating,
|
|
ratingLabel: RatingDisplay.format(driver.rating),
|
|
skillLevel: driver.skillLevel,
|
|
category: driver.category,
|
|
nationality: driver.nationality,
|
|
racesCompleted: driver.racesCompleted,
|
|
wins: driver.wins,
|
|
podiums: driver.podiums,
|
|
isActive: driver.isActive,
|
|
rank: driver.rank,
|
|
avatarUrl: driver.avatarUrl,
|
|
})),
|
|
totalRaces: dto.totalRaces,
|
|
totalRacesLabel: NumberDisplay.format(dto.totalRaces),
|
|
totalWins: dto.totalWins,
|
|
totalWinsLabel: NumberDisplay.format(dto.totalWins),
|
|
activeCount: dto.activeCount,
|
|
activeCountLabel: NumberDisplay.format(dto.activeCount),
|
|
totalDriversLabel: NumberDisplay.format(dto.drivers.length),
|
|
};
|
|
}
|
|
} |