Files
gridpilot.gg/apps/website/lib/view-models/RenewalAlertViewModel.ts
Marc Mintel d97f50ed72
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 6m4s
Contract Testing / contract-snapshot (pull_request) Has been skipped
view data fixes
2026-01-23 11:59:49 +01:00

51 lines
1.2 KiB
TypeScript

/**
* Renewal Alert View Model
*
* View model for upcoming renewal alerts.
*/
import { ViewModel } from "../contracts/view-models/ViewModel";
export class RenewalAlertViewModel extends ViewModel {
id: string;
name: string;
type: 'league' | 'team' | 'driver' | 'race' | 'platform';
renewDate: Date;
price: number;
constructor(data: any) {
this.id = data.id;
this.name = data.name;
this.type = data.type;
this.renewDate = new Date(data.renewDate);
this.price = data.price;
}
get formattedPrice(): string {
return `$${this.price}`;
}
get formattedRenewDate(): string {
return this.renewDate.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
}
get typeIcon() {
const icons = {
league: 'Trophy',
team: 'Users',
driver: 'Car',
race: 'Flag',
platform: 'Megaphone',
};
return icons[this.type] || 'Trophy';
}
get daysUntilRenewal(): number {
const now = new Date();
const diffTime = this.renewDate.getTime() - now.getTime();
return Math.ceil(diffTime / (1000 * 60 * 60 * 24));
}
get isUrgent(): boolean {
return this.daysUntilRenewal <= 30;
}
}