view data fixes
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 5m51s
Contract Testing / contract-snapshot (pull_request) Has been skipped

This commit is contained in:
2026-01-24 12:14:08 +01:00
parent dde77e717a
commit 046852703f
94 changed files with 1333 additions and 4885 deletions

View File

@@ -1,14 +1,11 @@
'use client';
import type { AllLeaguesWithCapacityAndScoringDTO } from '@/lib/types/generated/AllLeaguesWithCapacityAndScoringDTO';
import type { LeaguesViewData } from '@/lib/view-data/LeaguesViewData';
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
export class LeaguesViewDataBuilder implements ViewDataBuilder<any, any> {
build(input: any): any {
return LeaguesViewDataBuilder.build(input);
}
static build(apiDto: AllLeaguesWithCapacityAndScoringDTO): LeaguesViewData {
export class LeaguesViewDataBuilder {
public static build(apiDto: AllLeaguesWithCapacityAndScoringDTO): LeaguesViewData {
return {
leagues: apiDto.leagues.map((league) => ({
id: league.id,
@@ -17,19 +14,19 @@ export class LeaguesViewDataBuilder implements ViewDataBuilder<any, any> {
logoUrl: league.logoUrl || null,
ownerId: league.ownerId,
createdAt: league.createdAt,
maxDrivers: league.settings.maxDrivers,
maxDrivers: league.settings?.maxDrivers || 0,
usedDriverSlots: league.usedSlots,
activeDriversCount: (league as any).activeDriversCount,
nextRaceAt: (league as any).nextRaceAt,
maxTeams: undefined, // Not provided in DTO
usedTeamSlots: undefined, // Not provided in DTO
structureSummary: league.settings.qualifyingFormat || '',
activeDriversCount: undefined,
nextRaceAt: undefined,
maxTeams: undefined,
usedTeamSlots: undefined,
structureSummary: league.settings?.qualifyingFormat || '',
timingSummary: league.timingSummary || '',
category: league.category || null,
scoring: league.scoring ? {
gameId: league.scoring.gameId,
gameName: league.scoring.gameName,
primaryChampionshipType: league.scoring.primaryChampionshipType as any,
primaryChampionshipType: league.scoring.primaryChampionshipType,
scoringPresetId: league.scoring.scoringPresetId,
scoringPresetName: league.scoring.scoringPresetName,
dropPolicySummary: league.scoring.dropPolicySummary,
@@ -38,4 +35,6 @@ export class LeaguesViewDataBuilder implements ViewDataBuilder<any, any> {
})),
};
}
}
}
LeaguesViewDataBuilder satisfies ViewDataBuilder<AllLeaguesWithCapacityAndScoringDTO, LeaguesViewData>;