view data fixes
This commit is contained in:
@@ -4,14 +4,26 @@
|
||||
*/
|
||||
import { ViewModel } from "../contracts/view-models/ViewModel";
|
||||
|
||||
/**
|
||||
* ViewData for LeagueStewarding
|
||||
* This is the JSON-serializable input for the Template.
|
||||
*/
|
||||
export interface LeagueStewardingViewData {
|
||||
racesWithData: RaceWithProtests[];
|
||||
driverMap: Record<string, { id: string; name: string; avatarUrl?: string; iracingId?: string; rating?: number }>;
|
||||
}
|
||||
|
||||
export class LeagueStewardingViewModel extends ViewModel {
|
||||
constructor(
|
||||
public readonly racesWithData: RaceWithProtests[],
|
||||
public readonly driverMap: Record<string, { id: string; name: string; avatarUrl?: string; iracingId?: string; rating?: number }>
|
||||
) {
|
||||
private readonly data: LeagueStewardingViewData;
|
||||
|
||||
constructor(data: LeagueStewardingViewData) {
|
||||
super();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
get racesWithData(): RaceWithProtests[] { return this.data.racesWithData; }
|
||||
get driverMap() { return this.data.driverMap; }
|
||||
|
||||
/** UI-specific: Total pending protests count */
|
||||
get totalPending(): number {
|
||||
return this.racesWithData.reduce((sum, r) => sum + r.pendingProtests.length, 0);
|
||||
|
||||
Reference in New Issue
Block a user