76 lines
2.5 KiB
TypeScript
76 lines
2.5 KiB
TypeScript
import { ViewModel } from "../contracts/view-models/ViewModel";
|
|
import { CurrencyDisplay } from "../display-objects/CurrencyDisplay";
|
|
import { DateDisplay } from "../display-objects/DateDisplay";
|
|
import { PaymentTypeDisplay } from "../display-objects/PaymentTypeDisplay";
|
|
import { PayerTypeDisplay } from "../display-objects/PayerTypeDisplay";
|
|
import { StatusDisplay } from "../display-objects/StatusDisplay";
|
|
import type { PaymentViewData } from "../view-data/PaymentViewData";
|
|
|
|
export class PaymentViewModel extends ViewModel {
|
|
private readonly data: PaymentViewData;
|
|
|
|
constructor(data: PaymentViewData) {
|
|
super();
|
|
this.data = data;
|
|
}
|
|
|
|
get id(): string { return this.data.id; }
|
|
get type(): string { return this.data.type; }
|
|
get amount(): number { return this.data.amount; }
|
|
get platformFee(): number { return this.data.platformFee; }
|
|
get netAmount(): number { return this.data.netAmount; }
|
|
get payerId(): string { return this.data.payerId; }
|
|
get payerType(): string { return this.data.payerType; }
|
|
get leagueId(): string { return this.data.leagueId; }
|
|
get seasonId(): string | undefined { return this.data.seasonId; }
|
|
get status(): string { return this.data.status; }
|
|
get createdAt(): string { return this.data.createdAt; }
|
|
get completedAt(): string | undefined { return this.data.completedAt; }
|
|
|
|
/** UI-specific: Formatted amount */
|
|
get formattedAmount(): string {
|
|
return CurrencyDisplay.format(this.amount, 'EUR');
|
|
}
|
|
|
|
/** UI-specific: Formatted net amount */
|
|
get formattedNetAmount(): string {
|
|
return CurrencyDisplay.format(this.netAmount, 'EUR');
|
|
}
|
|
|
|
/** UI-specific: Status color */
|
|
get statusColor(): string {
|
|
switch (this.status) {
|
|
case 'completed': return 'green';
|
|
case 'pending': return 'yellow';
|
|
case 'failed': return 'red';
|
|
case 'refunded': return 'orange';
|
|
default: return 'gray';
|
|
}
|
|
}
|
|
|
|
/** UI-specific: Formatted created date */
|
|
get formattedCreatedAt(): string {
|
|
return DateDisplay.formatShort(this.createdAt);
|
|
}
|
|
|
|
/** UI-specific: Formatted completed date */
|
|
get formattedCompletedAt(): string {
|
|
return this.completedAt ? DateDisplay.formatShort(this.completedAt) : 'Not completed';
|
|
}
|
|
|
|
/** UI-specific: Status display */
|
|
get statusDisplay(): string {
|
|
return StatusDisplay.transactionStatus(this.status);
|
|
}
|
|
|
|
/** UI-specific: Type display */
|
|
get typeDisplay(): string {
|
|
return PaymentTypeDisplay.format(this.type);
|
|
}
|
|
|
|
/** UI-specific: Payer type display */
|
|
get payerTypeDisplay(): string {
|
|
return PayerTypeDisplay.format(this.payerType);
|
|
}
|
|
}
|