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

This commit is contained in:
2026-01-24 23:29:55 +01:00
parent c1750a33dd
commit 1b0a1f4aee
134 changed files with 10380 additions and 415 deletions

View File

@@ -9,13 +9,17 @@ import { AvatarFormatter } from "../formatters/AvatarFormatter";
* Transforms AvatarViewData into UI-ready state with formatting and derived fields.
*/
export class AvatarViewModel extends ViewModel {
private readonly data: AvatarViewData;
private readonly data: any;
constructor(data: AvatarViewData) {
constructor(data: any) {
super();
this.data = data;
}
get driverId(): string { return this.data.driverId; }
get avatarUrl(): string | undefined { return this.data.avatarUrl; }
get hasAvatar(): boolean { return !!this.data.avatarUrl; }
/** UI-specific: Buffer is already base64 encoded in ViewData */
get bufferBase64(): string {
return this.data.buffer;

View File

@@ -11,6 +11,7 @@ export class LeagueMemberViewModel extends ViewModel {
}
get driverId(): string { return this.data.driverId; }
get currentUserId(): string { return this.data.currentUserId; }
get driver(): any { return this.data.driver; }
get role(): string { return this.data.role; }
get joinedAt(): string { return this.data.joinedAt; }

View File

@@ -1,6 +1,25 @@
import { ViewModel } from "../contracts/view-models/ViewModel";
export interface LeagueScheduleRaceViewModel extends ViewModel {
export class LeagueScheduleRaceViewModel extends ViewModel {
constructor(private readonly data: any) {
super();
}
get id(): string { return this.data.id; }
get name(): string { return this.data.name; }
get scheduledAt(): Date { return new Date(this.data.scheduledAt); }
get formattedDate(): string { return this.data.formattedDate; }
get formattedTime(): string { return this.data.formattedTime; }
get isPast(): boolean { return this.data.isPast; }
get isUpcoming(): boolean { return this.data.isUpcoming; }
get status(): string { return this.data.status; }
get track(): string | undefined { return this.data.track; }
get car(): string | undefined { return this.data.car; }
get sessionType(): string | undefined { return this.data.sessionType; }
get isRegistered(): boolean | undefined { return this.data.isRegistered; }
}
export interface ILeagueScheduleRaceViewModel extends ViewModel {
id: string;
name: string;
scheduledAt: Date;

View File

@@ -1,13 +1,13 @@
import { ViewModel } from "../contracts/view-models/ViewModel";
import type { LeagueScheduleViewData } from "../view-data/LeagueScheduleViewData";
import type { LeagueScheduleRaceViewModel } from "./LeagueScheduleRaceViewModel";
import { LeagueScheduleRaceViewModel } from "./LeagueScheduleRaceViewModel";
export class LeagueScheduleViewModel extends ViewModel {
readonly races: LeagueScheduleRaceViewModel[];
constructor(data: LeagueScheduleViewData) {
super();
this.races = data.races;
this.races = data.races.map((r: any) => new LeagueScheduleRaceViewModel(r));
}
get raceCount(): number {

View File

@@ -11,32 +11,32 @@ export class RaceStewardingViewModel extends ViewModel {
get race() { return this.data.race; }
get league() { return this.data.league; }
get protests() { return this.data.protests; }
get penalties() { return this.data.penalties; }
get driverMap() { return this.data.driverMap; }
/** UI-specific: Pending protests */
get pendingProtests() {
return this.protests.filter(p => p.status === 'pending' || p.status === 'under_review');
return this.data.pendingProtests;
}
/** UI-specific: Resolved protests */
get resolvedProtests() {
return this.protests.filter(p =>
p.status === 'upheld' ||
p.status === 'dismissed' ||
p.status === 'withdrawn'
);
return this.data.resolvedProtests;
}
/** UI-specific: All protests */
get protests() {
return [...this.pendingProtests, ...this.resolvedProtests];
}
/** UI-specific: Total pending protests count */
get pendingCount(): number {
return this.pendingProtests.length;
return this.data.pendingCount;
}
/** UI-specific: Total resolved protests count */
get resolvedCount(): number {
return this.resolvedProtests.length;
return this.data.resolvedCount;
}
/** UI-specific: Total penalties count */

View File

@@ -4,10 +4,10 @@ export class RecordEngagementOutputViewModel extends ViewModel {
eventId: string;
engagementWeight: number;
constructor(eventId: string, engagementWeight: number) {
constructor(data: { eventId: string; engagementWeight: number }) {
super();
this.eventId = eventId;
this.engagementWeight = engagementWeight;
this.eventId = data.eventId;
this.engagementWeight = data.engagementWeight;
}
/** UI-specific: Formatted event ID for display */