view data fixes

This commit is contained in:
2026-01-23 15:30:23 +01:00
parent e22033be38
commit f8099f04bc
213 changed files with 3466 additions and 3003 deletions

View File

@@ -1,29 +1,20 @@
// Note: No generated DTO available for UserProfile yet
interface UserProfileDTO {
id: string;
name: string;
avatarUrl?: string;
iracingId?: string;
rating?: number;
}
import { ViewModel } from "../contracts/view-models/ViewModel";
import type { UserProfileViewData } from "../view-data/UserProfileViewData";
export class UserProfileViewModel extends ViewModel {
id: string;
name: string;
avatarUrl?: string;
iracingId?: string;
rating?: number;
private readonly data: UserProfileViewData;
constructor(dto: UserProfileDTO) {
this.id = dto.id;
this.name = dto.name;
if (dto.avatarUrl !== undefined) this.avatarUrl = dto.avatarUrl;
if (dto.iracingId !== undefined) this.iracingId = dto.iracingId;
if (dto.rating !== undefined) this.rating = dto.rating;
constructor(data: UserProfileViewData) {
super();
this.data = data;
}
get id(): string { return this.data.id; }
get name(): string { return this.data.name; }
get avatarUrl(): string | undefined { return this.data.avatarUrl; }
get iracingId(): string | undefined { return this.data.iracingId; }
get rating(): number | undefined { return this.data.rating; }
/** UI-specific: Formatted rating */
get formattedRating(): string {
return this.rating ? this.rating.toFixed(0) : 'Unrated';
@@ -47,4 +38,4 @@ export class UserProfileViewModel extends ViewModel {
get avatarInitials(): string {
return this.name.split(' ').map(n => n[0]).join('').toUpperCase();
}
}
}