view data fixes
This commit is contained in:
@@ -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>;
|
||||
Reference in New Issue
Block a user