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