/**
 * Renewal Alert View Model
 *
 * View model for upcoming renewal alerts.
 */
export class RenewalAlertViewModel {
  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;
  }
}