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,12 +1,10 @@
'use client';
import type { LeagueWithCapacityAndScoringDTO } from '@/lib/types/generated/LeagueWithCapacityAndScoringDTO';
import type { LeagueMembershipsDTO } from '@/lib/types/generated/LeagueMembershipsDTO';
import type { RaceDTO } from '@/lib/types/generated/RaceDTO';
import type { GetDriverOutputDTO } from '@/lib/types/generated/GetDriverOutputDTO';
import type { LeagueScoringConfigDTO } from '@/lib/types/generated/LeagueScoringConfigDTO';
import type { LeagueDetailViewData, LeagueInfoData, LiveRaceData, DriverSummaryData, SponsorInfo, NextRaceInfo, SeasonProgress, RecentResult } from '@/lib/view-data/LeagueDetailViewData';
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
import type { GetDriverOutputDTO } from '@/lib/types/generated/GetDriverOutputDTO';
import type { LeagueMembershipsDTO } from '@/lib/types/generated/LeagueMembershipsDTO';
import type { LeagueScoringConfigDTO } from '@/lib/types/generated/LeagueScoringConfigDTO';
import type { LeagueWithCapacityAndScoringDTO } from '@/lib/types/generated/LeagueWithCapacityAndScoringDTO';
import type { RaceDTO } from '@/lib/types/generated/RaceDTO';
import type { DriverSummaryData, LeagueDetailViewData, LeagueInfoData, LiveRaceData, NextRaceInfo, RecentResult, SeasonProgress, SponsorInfo } from '@/lib/view-data/LeagueDetailViewData';
type LeagueDetailInputDTO = {
league: LeagueWithCapacityAndScoringDTO;
@@ -25,6 +23,12 @@ type LeagueDetailInputDTO = {
}
export class LeagueDetailViewDataBuilder {
/**
* Transform API DTO to ViewData
*
* @param apiDto - The DTO from the service
* @returns ViewData for the league detail page
*/
public static build(apiDto: LeagueDetailInputDTO): LeagueDetailViewData {
const { league, owner, scoringConfig, memberships, races, sponsors } = apiDto;
@@ -170,6 +174,32 @@ export class LeagueDetailViewDataBuilder {
}));
return {
league: {
id: league.id,
name: league.name,
game: scoringConfig?.gameName || 'iRacing',
tier: 'standard',
season: 'Current Season',
description: league.description || '',
drivers: membersCount,
races: racesCount,
completedRaces,
totalImpressions: 0,
avgViewsPerRace: 0,
engagement: 0,
rating: 0,
seasonStatus: 'active',
seasonDates: {
start: league.createdAt,
end: races.length > 0 ? races[races.length - 1].date : league.createdAt,
},
sponsorSlots: {
main: { price: 0, status: 'available' },
secondary: { price: 0, total: 0, occupied: 0 },
},
},
drivers: [],
races: [],
leagueId: league.id,
name: league.name,
description: league.description || '',