import type { MembershipFeeDTO } from '../types/generated/MembershipFeeDTO';

export class MembershipFeeViewModel {
  id!: string;
  leagueId!: string;
  seasonId?: string;
  type!: string;
  amount!: number;
  enabled!: boolean;
  createdAt!: Date;
  updatedAt!: Date;

  constructor(dto: MembershipFeeDTO) {
    Object.assign(this, dto);
  }

  /** UI-specific: Formatted amount */
  get formattedAmount(): string {
    return `€${this.amount.toFixed(2)}`; // Assuming EUR
  }

  /** UI-specific: Type display */
  get typeDisplay(): string {
    switch (this.type) {
      case 'season': return 'Per Season';
      case 'monthly': return 'Monthly';
      case 'per_race': return 'Per Race';
      default: return this.type;
    }
  }

  /** UI-specific: Status display */
  get statusDisplay(): string {
    return this.enabled ? 'Enabled' : 'Disabled';
  }

  /** UI-specific: Status color */
  get statusColor(): string {
    return this.enabled ? 'green' : 'red';
  }

  /** UI-specific: Formatted created date */
  get formattedCreatedAt(): string {
    return this.createdAt.toLocaleString();
  }

  /** UI-specific: Formatted updated date */
  get formattedUpdatedAt(): string {
    return this.updatedAt.toLocaleString();
  }
}