Files
gridpilot.gg/apps/website/lib/view-models/MembershipFeeViewModel.ts
2026-01-12 01:01:49 +01:00

51 lines
1.2 KiB
TypeScript

import type { MembershipFeeDTO } from '@/lib/types/generated';
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();
}
}