// Export the DTO type that WalletTransactionViewModel expects
export type FullTransactionDto = {
  id: string;
  type: 'sponsorship' | 'membership' | 'withdrawal' | 'prize' | 'deposit';
  description: string;
  amount: number;
  fee: number;
  netAmount: number;
  date: Date;
  status: 'completed' | 'pending' | 'failed';
  reference?: string;
};

export class WalletTransactionViewModel {
  id: string;
  type: 'sponsorship' | 'membership' | 'withdrawal' | 'prize' | 'deposit';
  description: string;
  amount: number;
  fee: number;
  netAmount: number;
  date: Date;
  status: 'completed' | 'pending' | 'failed';
  reference?: string;

  constructor(dto: FullTransactionDto) {
    this.id = dto.id;
    this.type = dto.type;
    this.description = dto.description;
    this.amount = dto.amount;
    this.fee = dto.fee;
    this.netAmount = dto.netAmount;
    this.date = dto.date;
    this.status = dto.status;
    this.reference = dto.reference;
  }

  /** UI-specific: Formatted amount with sign */
  get formattedAmount(): string {
    const sign = this.amount > 0 ? '+' : '';
    return `${sign}$${Math.abs(this.amount).toFixed(2)}`;
  }

  /** UI-specific: Amount color */
  get amountColor(): string {
    return this.amount > 0 ? 'green' : 'red';
  }

  /** UI-specific: Type display */
  get typeDisplay(): string {
    return this.type.charAt(0).toUpperCase() + this.type.slice(1);
  }

  /** UI-specific: Formatted date */
  get formattedDate(): string {
    return this.date.toLocaleDateString();
  }

  /** UI-specific: Is incoming */
  get isIncoming(): boolean {
    return this.amount > 0;
  }
}