view data fixes
This commit is contained in:
@@ -13,44 +13,37 @@ import { LeagueTierDisplay } from "../display-objects/LeagueTierDisplay";
|
||||
import { SeasonStatusDisplay } from "../display-objects/SeasonStatusDisplay";
|
||||
|
||||
export class AvailableLeaguesViewModel extends ViewModel {
|
||||
private readonly data: AvailableLeaguesViewData;
|
||||
readonly leagues: AvailableLeagueViewModel[];
|
||||
|
||||
constructor(viewData: AvailableLeaguesViewData) {
|
||||
constructor(data: AvailableLeaguesViewData) {
|
||||
super();
|
||||
this.leagues = viewData.leagues.map(league => new AvailableLeagueViewModel(league));
|
||||
this.data = data;
|
||||
this.leagues = data.leagues.map(league => new AvailableLeagueViewModel(league));
|
||||
}
|
||||
}
|
||||
|
||||
export class AvailableLeagueViewModel extends ViewModel {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly game: string;
|
||||
readonly drivers: number;
|
||||
readonly avgViewsPerRace: number;
|
||||
readonly mainSponsorSlot: { available: boolean; price: number };
|
||||
readonly secondarySlots: { available: number; total: number; price: number };
|
||||
readonly rating: number;
|
||||
readonly tier: 'premium' | 'standard' | 'starter';
|
||||
readonly nextRace?: string;
|
||||
readonly seasonStatus: 'active' | 'upcoming' | 'completed';
|
||||
readonly description: string;
|
||||
private readonly data: AvailableLeagueViewData;
|
||||
|
||||
constructor(viewData: AvailableLeagueViewData) {
|
||||
constructor(data: AvailableLeagueViewData) {
|
||||
super();
|
||||
this.id = viewData.id;
|
||||
this.name = viewData.name;
|
||||
this.game = viewData.game;
|
||||
this.drivers = viewData.drivers;
|
||||
this.avgViewsPerRace = viewData.avgViewsPerRace;
|
||||
this.mainSponsorSlot = viewData.mainSponsorSlot;
|
||||
this.secondarySlots = viewData.secondarySlots;
|
||||
this.rating = viewData.rating;
|
||||
this.tier = viewData.tier;
|
||||
this.nextRace = viewData.nextRace;
|
||||
this.seasonStatus = viewData.seasonStatus;
|
||||
this.description = viewData.description;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
get id(): string { return this.data.id; }
|
||||
get name(): string { return this.data.name; }
|
||||
get game(): string { return this.data.game; }
|
||||
get drivers(): number { return this.data.drivers; }
|
||||
get avgViewsPerRace(): number { return this.data.avgViewsPerRace; }
|
||||
get mainSponsorSlot() { return this.data.mainSponsorSlot; }
|
||||
get secondarySlots() { return this.data.secondarySlots; }
|
||||
get rating(): number { return this.data.rating; }
|
||||
get tier(): 'premium' | 'standard' | 'starter' { return this.data.tier; }
|
||||
get nextRace(): string | undefined { return this.data.nextRace; }
|
||||
get seasonStatus(): 'active' | 'upcoming' | 'completed' { return this.data.seasonStatus; }
|
||||
get description(): string { return this.data.description; }
|
||||
|
||||
/** UI-specific: Formatted average views */
|
||||
get formattedAvgViews(): string {
|
||||
return NumberDisplay.formatCompact(this.avgViewsPerRace);
|
||||
|
||||
Reference in New Issue
Block a user