38 lines
943 B
TypeScript
38 lines
943 B
TypeScript
import { PaymentDTO } from '../types/generated/PaymentDto';
|
|
|
|
export class PaymentViewModel implements PaymentDTO {
|
|
id: string;
|
|
amount: number;
|
|
currency: string;
|
|
status: string;
|
|
createdAt: string;
|
|
|
|
constructor(dto: PaymentDTO) {
|
|
Object.assign(this, dto);
|
|
}
|
|
|
|
/** UI-specific: Formatted amount */
|
|
get formattedAmount(): string {
|
|
return `${this.currency} ${this.amount.toFixed(2)}`;
|
|
}
|
|
|
|
/** UI-specific: Status color */
|
|
get statusColor(): string {
|
|
switch (this.status) {
|
|
case 'completed': return 'green';
|
|
case 'pending': return 'yellow';
|
|
case 'failed': return 'red';
|
|
default: return 'gray';
|
|
}
|
|
}
|
|
|
|
/** UI-specific: Formatted created date */
|
|
get formattedCreatedAt(): string {
|
|
return new Date(this.createdAt).toLocaleString();
|
|
}
|
|
|
|
/** UI-specific: Status display */
|
|
get statusDisplay(): string {
|
|
return this.status.charAt(0).toUpperCase() + this.status.slice(1);
|
|
}
|
|
} |