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

This commit is contained in:
2026-01-23 11:59:49 +01:00
parent ae58839eb2
commit d97f50ed72
191 changed files with 2889 additions and 1019 deletions

View File

@@ -1,13 +1,77 @@
export interface DriverProfileDriverSummaryViewModel {
id: string;
name: string;
country: string;
avatarUrl: string;
iracingId: string | null;
joinedAt: string;
rating: number | null;
globalRank: number | null;
consistency: number | null;
bio: string | null;
totalDrivers: number | null;
import { ViewModel } from "../contracts/view-models/ViewModel";
import { ProfileViewData } from "../view-data/ProfileViewData";
import { RatingDisplay } from "../display-objects/RatingDisplay";
import { DashboardConsistencyDisplay } from "../display-objects/DashboardConsistencyDisplay";
import { NumberDisplay } from "../display-objects/NumberDisplay";
/**
* Driver Profile Driver Summary View Model
*
* Represents a fully prepared UI state for driver summary display.
* Transforms ViewData into UI-ready data structures.
*/
export class DriverProfileDriverSummaryViewModel extends ViewModel {
constructor(private readonly viewData: ProfileViewData) {
super();
}
get id(): string {
return this.viewData.driver.id;
}
get name(): string {
return this.viewData.driver.name;
}
get country(): string {
return this.viewData.driver.countryCode;
}
get avatarUrl(): string {
return this.viewData.driver.avatarUrl;
}
get iracingId(): string | null {
return this.viewData.driver.iracingId;
}
get joinedAt(): string {
return this.viewData.driver.joinedAtLabel;
}
get rating(): number | null {
return this.viewData.stats?.ratingLabel ? Number(this.viewData.stats.ratingLabel) : null;
}
get ratingLabel(): string {
return RatingDisplay.format(this.rating);
}
get globalRank(): number | null {
return this.viewData.stats?.globalRankLabel ? Number(this.viewData.stats.globalRankLabel) : null;
}
get globalRankLabel(): string {
return this.globalRank ? NumberDisplay.format(this.globalRank) : '—';
}
get consistency(): number | null {
return this.viewData.stats?.consistencyLabel ? Number(this.viewData.stats.consistencyLabel) : null;
}
get consistencyLabel(): string {
return this.consistency ? DashboardConsistencyDisplay.format(this.consistency) : '—';
}
get bio(): string | null {
return this.viewData.driver.bio;
}
get totalDrivers(): number | null {
return this.viewData.stats?.totalRacesLabel ? Number(this.viewData.stats.totalRacesLabel) : null;
}
get totalDriversLabel(): string {
return this.totalDrivers ? NumberDisplay.format(this.totalDrivers) : '—';
}
}