import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { TransferCategory, TransferCondition } from '@prisma/client';
import { Type } from 'class-transformer';
import { IsArray, IsEnum, IsInt, IsNumber, IsOptional, IsString, ValidateNested } from 'class-validator';

export class EstimateItemDto {
  @ApiProperty({ enum: TransferCategory })
  @IsEnum(TransferCategory)
  category!: TransferCategory;

  @ApiProperty({ enum: TransferCondition })
  @IsEnum(TransferCondition)
  condition!: TransferCondition;

  @ApiProperty({ description: 'Giá mua ban đầu (VND)' })
  @IsNumber()
  @Type(() => Number)
  originalPriceVND!: number;

  @ApiProperty({ description: 'Năm mua' })
  @IsInt()
  @Type(() => Number)
  purchaseYear!: number;

  @ApiPropertyOptional({ description: 'Thương hiệu' })
  @IsOptional()
  @IsString()
  brand?: string;
}

export class EstimateTransferPricesDto {
  @ApiProperty({ type: [EstimateItemDto] })
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => EstimateItemDto)
  items!: EstimateItemDto[];
}
