view models
This commit is contained in:
@@ -1,24 +1,30 @@
|
||||
import { TransactionDto } from '../types/generated/TransactionDto';
|
||||
|
||||
export class WalletTransactionViewModel implements TransactionDto {
|
||||
// TODO: Use generated TransactionDto when it includes all required fields
|
||||
export type FullTransactionDto = TransactionDto & {
|
||||
amount: number;
|
||||
description: string;
|
||||
createdAt: string;
|
||||
type: 'deposit' | 'withdrawal';
|
||||
};
|
||||
|
||||
export class WalletTransactionViewModel implements FullTransactionDto {
|
||||
id: string;
|
||||
walletId: string;
|
||||
amount: number;
|
||||
description: string;
|
||||
createdAt: string;
|
||||
type: 'deposit' | 'withdrawal';
|
||||
|
||||
constructor(dto: TransactionDto) {
|
||||
constructor(dto: FullTransactionDto) {
|
||||
this.id = dto.id;
|
||||
this.walletId = dto.walletId;
|
||||
this.amount = dto.amount;
|
||||
this.description = dto.description;
|
||||
this.createdAt = dto.createdAt;
|
||||
this.type = dto.type;
|
||||
}
|
||||
|
||||
// Note: The generated DTO doesn't have type field
|
||||
// This will need to be added when the OpenAPI spec is updated
|
||||
type: 'deposit' | 'withdrawal' = 'deposit';
|
||||
|
||||
/** UI-specific: Formatted amount with sign */
|
||||
get formattedAmount(): string {
|
||||
const sign = this.type === 'deposit' ? '+' : '-';
|
||||
|
||||
Reference in New Issue
Block a user