view data fixes
This commit is contained in:
@@ -1,34 +1,34 @@
|
||||
import type { MembershipFeeDTO } from '@/lib/types/generated';
|
||||
|
||||
import { ViewModel } from "../contracts/view-models/ViewModel";
|
||||
import { CurrencyDisplay } from "../display-objects/CurrencyDisplay";
|
||||
import { DateDisplay } from "../display-objects/DateDisplay";
|
||||
import { MembershipFeeTypeDisplay } from "../display-objects/MembershipFeeTypeDisplay";
|
||||
import type { MembershipFeeViewData } from "../view-data/MembershipFeeViewData";
|
||||
|
||||
export class MembershipFeeViewModel extends ViewModel {
|
||||
id!: string;
|
||||
leagueId!: string;
|
||||
seasonId?: string;
|
||||
type!: string;
|
||||
amount!: number;
|
||||
enabled!: boolean;
|
||||
createdAt!: Date;
|
||||
updatedAt!: Date;
|
||||
private readonly data: MembershipFeeViewData;
|
||||
|
||||
constructor(dto: MembershipFeeDTO) {
|
||||
Object.assign(this, dto);
|
||||
constructor(data: MembershipFeeViewData) {
|
||||
super();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
get id(): string { return this.data.id; }
|
||||
get leagueId(): string { return this.data.leagueId; }
|
||||
get seasonId(): string | undefined { return this.data.seasonId; }
|
||||
get type(): string { return this.data.type; }
|
||||
get amount(): number { return this.data.amount; }
|
||||
get enabled(): boolean { return this.data.enabled; }
|
||||
get createdAt(): string { return this.data.createdAt; }
|
||||
get updatedAt(): string { return this.data.updatedAt; }
|
||||
|
||||
/** UI-specific: Formatted amount */
|
||||
get formattedAmount(): string {
|
||||
return `€${this.amount.toFixed(2)}`; // Assuming EUR
|
||||
return CurrencyDisplay.format(this.amount, '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;
|
||||
}
|
||||
return MembershipFeeTypeDisplay.format(this.type);
|
||||
}
|
||||
|
||||
/** UI-specific: Status display */
|
||||
@@ -43,11 +43,11 @@ export class MembershipFeeViewModel extends ViewModel {
|
||||
|
||||
/** UI-specific: Formatted created date */
|
||||
get formattedCreatedAt(): string {
|
||||
return this.createdAt.toLocaleString();
|
||||
return DateDisplay.formatShort(this.createdAt);
|
||||
}
|
||||
|
||||
/** UI-specific: Formatted updated date */
|
||||
get formattedUpdatedAt(): string {
|
||||
return this.updatedAt.toLocaleString();
|
||||
return DateDisplay.formatShort(this.updatedAt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user