view data fixes
Some checks failed
Contract Testing / contract-snapshot (pull_request) Has been cancelled
Contract Testing / contract-tests (pull_request) Has been cancelled

This commit is contained in:
2026-01-25 00:12:30 +01:00
parent 1b0a1f4aee
commit 6c07abe5e7
37 changed files with 400 additions and 185 deletions

View File

@@ -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>;

View File

@@ -1,16 +1,29 @@
/**
* Rulebook View Data Builder
*
*
* Transforms API DTO to ViewData for templates.
*/
import type { RulebookViewData } from '@/lib/view-data/RulebookViewData';
import { LeagueScoringConfigDTO } from '@/lib/types/generated/LeagueScoringConfigDTO';
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
interface RulebookApiDto {
leagueId: string;
scoringConfig: LeagueScoringConfigDTO;
scoringConfig: {
gameName: string;
scoringPresetName: string;
championships: Array<{
type: string;
sessionTypes: string[];
pointsPreview: Array<{
sessionType: string;
position: number;
points: number;
}>;
bonusSummary: string[];
}>;
dropPolicySummary: string;
};
}
export class RulebookViewDataBuilder {