46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { ViewModel } from "../contracts/view-models/ViewModel";
|
|
import type { RaceStewardingViewData } from "../view-data/RaceStewardingViewData";
|
|
|
|
export class RaceStewardingViewModel extends ViewModel {
|
|
private readonly data: RaceStewardingViewData;
|
|
|
|
constructor(data: RaceStewardingViewData) {
|
|
super();
|
|
this.data = data;
|
|
}
|
|
|
|
get race() { return this.data.race; }
|
|
get league() { return this.data.league; }
|
|
get protests() { return this.data.protests; }
|
|
get penalties() { return this.data.penalties; }
|
|
get driverMap() { return this.data.driverMap; }
|
|
|
|
/** UI-specific: Pending protests */
|
|
get pendingProtests() {
|
|
return this.protests.filter(p => p.status === 'pending' || p.status === 'under_review');
|
|
}
|
|
|
|
/** UI-specific: Resolved protests */
|
|
get resolvedProtests() {
|
|
return this.protests.filter(p =>
|
|
p.status === 'upheld' ||
|
|
p.status === 'dismissed' ||
|
|
p.status === 'withdrawn'
|
|
);
|
|
}
|
|
|
|
/** UI-specific: Total pending protests count */
|
|
get pendingCount(): number {
|
|
return this.pendingProtests.length;
|
|
}
|
|
|
|
/** UI-specific: Total resolved protests count */
|
|
get resolvedCount(): number {
|
|
return this.resolvedProtests.length;
|
|
}
|
|
|
|
/** UI-specific: Total penalties count */
|
|
get penaltiesCount(): number {
|
|
return this.penalties.length;
|
|
}
|
|
} |