website refactor
This commit is contained in:
@@ -1,22 +1,26 @@
|
||||
import type { DriversLeaderboardDTO } from '@/lib/types/generated/DriversLeaderboardDTO';
|
||||
import type { DriversViewData } from './DriversViewData';
|
||||
import type { DriversViewData } from '@/lib/types/view-data/DriversViewData';
|
||||
|
||||
/**
|
||||
* DriversViewDataBuilder
|
||||
*
|
||||
* Transforms DriversLeaderboardDTO into ViewData for the drivers listing page.
|
||||
* Deterministic, side-effect free, no HTTP calls.
|
||||
*
|
||||
* This builder does NOT perform filtering or sorting - that belongs in the API.
|
||||
* If the API doesn't support filtering, it should be marked as NotImplemented.
|
||||
*/
|
||||
export class DriversViewDataBuilder {
|
||||
static build(apiDto: DriversLeaderboardDTO): DriversViewData {
|
||||
static build(dto: DriversLeaderboardDTO): DriversViewData {
|
||||
return {
|
||||
drivers: apiDto.drivers,
|
||||
totalRaces: apiDto.totalRaces,
|
||||
totalWins: apiDto.totalWins,
|
||||
activeCount: apiDto.activeCount,
|
||||
drivers: dto.drivers.map(driver => ({
|
||||
id: driver.id,
|
||||
name: driver.name,
|
||||
rating: 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,
|
||||
totalWins: dto.totalWins,
|
||||
activeCount: dto.activeCount,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user