view data fixes

This commit is contained in:
2026-01-24 00:52:27 +01:00
parent 62e8b768ce
commit ae59df61eb
321 changed files with 1157 additions and 2234 deletions

View File

@@ -1,19 +1,24 @@
import { LeagueScheduleViewData } from '@/lib/view-data/leagues/LeagueScheduleViewData';
import { LeagueScheduleApiDto } from '@/lib/types/tbd/LeagueScheduleApiDto';
import type { LeagueScheduleViewData } from '@/lib/view-data/LeagueScheduleViewData';
import type { LeagueScheduleDTO } from '@/lib/types/generated/LeagueScheduleDTO';
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
export class LeagueScheduleViewDataBuilder implements ViewDataBuilder<any, any> {
build(input: any): any {
return LeagueScheduleViewDataBuilder.build(input);
export interface LeagueScheduleInputDTO {
apiDto: LeagueScheduleDTO;
currentDriverId?: string;
isAdmin?: boolean;
}
export class LeagueScheduleViewDataBuilder implements ViewDataBuilder<LeagueScheduleInputDTO, LeagueScheduleViewData> {
build(input: LeagueScheduleInputDTO): LeagueScheduleViewData {
return LeagueScheduleViewDataBuilder.build(input.apiDto, input.currentDriverId, input.isAdmin);
}
static build(
static build(apiDto: LeagueScheduleApiDto, currentDriverId?: string, isAdmin: boolean = false): LeagueScheduleViewData {
public static build(apiDto: LeagueScheduleDTO, currentDriverId?: string, isAdmin: boolean = false): LeagueScheduleViewData {
const now = new Date();
return {
leagueId: apiDto.leagueId,
leagueId: (apiDto as any).leagueId || '',
races: apiDto.races.map((race) => {
const scheduledAt = new Date(race.date);
const isPast = scheduledAt.getTime() <= now.getTime();
@@ -23,12 +28,12 @@ export class LeagueScheduleViewDataBuilder implements ViewDataBuilder<any, any>
id: race.id,
name: race.name,
scheduledAt: race.date,
track: race.track,
car: race.car,
sessionType: race.sessionType,
track: race.track || '',
car: race.car || '',
sessionType: race.sessionType || 'race',
isPast,
isUpcoming,
status: isPast ? 'completed' : 'scheduled',
status: (race.status as any) || (isPast ? 'completed' : 'scheduled'),
// Registration info (would come from API in real implementation)
isUserRegistered: false,
canRegister: isUpcoming,