Files
gridpilot.gg/apps/website/lib/view-models/DriverSummaryViewModel.ts
Marc Mintel e22033be38
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 5m54s
Contract Testing / contract-snapshot (pull_request) Has been skipped
view data fixes
2026-01-23 13:04:05 +01:00

55 lines
1.2 KiB
TypeScript

import { ViewModel } from "../contracts/view-models/ViewModel";
import type { DriverSummaryData } from "../view-data/LeagueDetailViewData";
import { NumberDisplay } from "../display-objects/NumberDisplay";
import { RatingDisplay } from "../display-objects/RatingDisplay";
/**
* View Model for driver summary with rating and rank
*
* Client-only UI helper built from ViewData.
*/
export class DriverSummaryViewModel extends ViewModel {
constructor(private readonly viewData: DriverSummaryData) {
super();
}
get id(): string {
return this.viewData.driverId;
}
get name(): string {
return this.viewData.driverName;
}
get avatarUrl(): string | null {
return this.viewData.avatarUrl;
}
get rating(): number | null {
return this.viewData.rating;
}
get ratingLabel(): string {
return RatingDisplay.format(this.rating);
}
get rank(): number | null {
return this.viewData.rank;
}
get rankLabel(): string {
return this.rank === null ? '—' : NumberDisplay.format(this.rank);
}
get roleBadgeText(): string {
return this.viewData.roleBadgeText;
}
get roleBadgeClasses(): string {
return this.viewData.roleBadgeClasses;
}
get profileUrl(): string {
return this.viewData.profileUrl;
}
}