website refactor

This commit is contained in:
2026-01-14 02:02:24 +01:00
parent 8d7c709e0c
commit 4522d41aef
291 changed files with 12763 additions and 9309 deletions

View File

@@ -0,0 +1,39 @@
import type { AllLeaguesWithCapacityAndScoringDTO } from '@/lib/types/generated/AllLeaguesWithCapacityAndScoringDTO';
import type { LeaguesViewData } from '@/lib/view-data/LeaguesViewData';
/**
* LeaguesViewDataBuilder
*
* Transforms AllLeaguesWithCapacityAndScoringDTO (API DTO) into LeaguesViewData for server-side rendering.
* Deterministic; side-effect free; no HTTP calls.
*/
export class LeaguesViewDataBuilder {
static build(apiDto: AllLeaguesWithCapacityAndScoringDTO): LeaguesViewData {
return {
leagues: apiDto.leagues.map((league) => ({
id: league.id,
name: league.name,
description: league.description || null,
logoUrl: league.logoUrl || null,
ownerId: league.ownerId,
createdAt: league.createdAt,
maxDrivers: league.settings.maxDrivers,
usedDriverSlots: league.usedSlots,
maxTeams: undefined, // Not provided in DTO
usedTeamSlots: undefined, // Not provided in DTO
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,
scoringPresetId: league.scoring.scoringPresetId,
scoringPresetName: league.scoring.scoringPresetName,
dropPolicySummary: league.scoring.dropPolicySummary,
scoringPatternSummary: league.scoring.scoringPatternSummary,
} : undefined,
})),
};
}
}