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