import { ApiProperty } from '@nestjs/swagger';
import { TransferOrder } from '../../../domain/aggregates/transfer-order.aggregate';

export class TransferOrderResponse {
  @ApiProperty() transferOrderNo: string;
  @ApiProperty() sellerAccountSequence: string;
  @ApiProperty() buyerAccountSequence: string;
  @ApiProperty() sourceOrderNo: string;
  @ApiProperty() treeCount: number;
  @ApiProperty() transferPrice: string;
  @ApiProperty() platformFeeAmount: string;
  @ApiProperty() sellerReceiveAmount: string;
  @ApiProperty() status: string;
  @ApiProperty() selectedProvince: string;
  @ApiProperty() selectedCity: string;
  @ApiProperty() createdAt: string;
  @ApiProperty({ required: false }) sellerConfirmedAt?: string;
  @ApiProperty({ required: false }) completedAt?: string;
  @ApiProperty({ required: false }) cancelledAt?: string;

  static fromDomain(order: TransferOrder): TransferOrderResponse {
    const response = new TransferOrderResponse();
    response.transferOrderNo = order.transferOrderNo;
    response.sellerAccountSequence = order.sellerAccountSequence;
    response.buyerAccountSequence = order.buyerAccountSequence;
    response.sourceOrderNo = order.sourceOrderNo;
    response.treeCount = order.treeCount;
    response.transferPrice = order.transferPrice;
    response.platformFeeAmount = order.platformFeeAmount;
    response.sellerReceiveAmount = order.sellerReceiveAmount;
    response.status = order.status;
    response.selectedProvince = order.selectedProvince;
    response.selectedCity = order.selectedCity;
    response.createdAt = order.createdAt.toISOString();
    response.sellerConfirmedAt = order.sellerConfirmedAt?.toISOString();
    response.completedAt = order.completedAt?.toISOString();
    response.cancelledAt = order.cancelledAt?.toISOString();
    return response;
  }
}
