website refactor
This commit is contained in:
25
lib/builders/view-data/DriversViewDataBuilder.ts
Normal file
25
lib/builders/view-data/DriversViewDataBuilder.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { DriversLeaderboardDTO } from '@/lib/types/generated/DriversLeaderboardDTO';
|
||||
import type { DriversViewData } from '@/lib/types/view-data/DriversViewData';
|
||||
|
||||
export class DriversViewDataBuilder {
|
||||
static build(dto: DriversLeaderboardDTO): DriversViewData {
|
||||
return {
|
||||
drivers: dto.drivers.map(driver => ({
|
||||
id: driver.id,
|
||||
name: driver.name,
|
||||
country: driver.country,
|
||||
avatarUrl: driver.avatarUrl || '',
|
||||
iracingId: driver.iracingId || null,
|
||||
rating: driver.rating || null,
|
||||
globalRank: driver.globalRank || null,
|
||||
consistency: driver.consistency || null,
|
||||
totalRaces: driver.racesCompleted,
|
||||
wins: driver.wins,
|
||||
isActive: driver.isActive,
|
||||
})),
|
||||
totalRaces: dto.totalRaces,
|
||||
totalWins: dto.totalWins,
|
||||
activeCount: dto.activeCount,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user