view data fixes
This commit is contained in:
@@ -1,34 +1,24 @@
|
||||
|
||||
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
import { DashboardDateFormatter } from '@/lib/formatters/DashboardDateFormatter';
|
||||
import type { DashboardOverviewDTO } from '@/lib/types/generated/DashboardOverviewDTO';
|
||||
import type { HomeDataDTO } from '@/lib/types/dtos/HomeDataDTO';
|
||||
import type { HomeViewData } from '@/lib/view-data/HomeViewData';
|
||||
|
||||
export class HomeViewDataBuilder {
|
||||
/**
|
||||
* Build HomeViewData from DashboardOverviewDTO
|
||||
* Build HomeViewData from HomeDataDTO
|
||||
*
|
||||
* @param apiDto - The API DTO
|
||||
* @returns HomeViewData
|
||||
*/
|
||||
public static build(apiDto: DashboardOverviewDTO): HomeViewData {
|
||||
public static build(apiDto: HomeDataDTO): HomeViewData {
|
||||
return {
|
||||
isAlpha: true,
|
||||
upcomingRaces: (apiDto.upcomingRaces || []).map(race => ({
|
||||
id: race.id,
|
||||
track: race.track,
|
||||
car: race.car,
|
||||
formattedDate: DashboardDateFormatter.format(new Date(race.scheduledAt)).date,
|
||||
})),
|
||||
topLeagues: (apiDto.leagueStandingsSummaries || []).map(league => ({
|
||||
id: league.leagueId,
|
||||
name: league.leagueName,
|
||||
description: '',
|
||||
})),
|
||||
teams: [],
|
||||
isAlpha: apiDto.isAlpha,
|
||||
upcomingRaces: apiDto.upcomingRaces,
|
||||
topLeagues: apiDto.topLeagues,
|
||||
teams: apiDto.teams,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
HomeViewDataBuilder satisfies ViewDataBuilder<DashboardOverviewDTO, HomeViewData>;
|
||||
HomeViewDataBuilder satisfies ViewDataBuilder<HomeDataDTO, HomeViewData>;
|
||||
|
||||
Reference in New Issue
Block a user