import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import {
    IsArray,
    IsNotEmpty,
    IsNumber,
    IsOptional,
    IsUUID,
    ValidateNested,
} from 'class-validator';

export class ItemCarritoDto {
  @ApiProperty()
  @IsUUID()
  producto_id: string;

  @ApiProperty()
  @IsNumber()
  cantidad: number;

  @ApiProperty()
  @IsNumber()
  precio_unitario: number;

  @ApiPropertyOptional({
    description: 'Precio resuelto por lista de precios del cliente (si aplica)',
  })
  @IsOptional()
  @IsNumber()
  precio_lista?: number;
}

export class EvaluarOfertasDto {
  @ApiProperty({ type: [ItemCarritoDto] })
  @IsArray()
  @IsNotEmpty()
  @ValidateNested({ each: true })
  @Type(() => ItemCarritoDto)
  items: ItemCarritoDto[];

  @ApiPropertyOptional()
  @IsOptional()
  @IsUUID()
  sucursal_id?: string;
}
