import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import {
  IsBoolean,
  IsIn,
  IsNotEmpty,
  IsOptional,
  ValidateNested,
} from 'class-validator';
import { ProductItem } from './add-order.dto';
import { PaymentGateway } from '../../payment/entities/payment.entity';

export class CalculatePriceForClientDto {
  @ApiProperty({ type: [ProductItem] })
  @IsNotEmpty({ message: 'لطفا اقلام محصولات موردنظر را وارد نمایید' })
  @ValidateNested({ each: true })
  @Type(() => ProductItem)
  productItems: ProductItem[];

  @ApiProperty({ type: 'boolean' })
  @IsNotEmpty()
  @IsBoolean()
  isService: boolean;

  @ApiProperty({ type: 'boolean' })
  @IsNotEmpty()
  @IsBoolean()
  isNewOrder: boolean;

  @ApiProperty({ type: 'boolean' })
  @IsNotEmpty()
  @IsBoolean()
  isOilGovernment: boolean;

  @ApiProperty({ type: 'boolean' })
  @IsOptional()
  @IsBoolean()
  checkStock: boolean;

  @ApiProperty()
  @IsOptional()
  carId: number;

  @ApiProperty()
  @IsOptional()
  makerBrandId: number;

  @ApiProperty()
  @IsOptional()
  couponCode: string;

  @ApiProperty()
  @IsOptional()
  addressId: number;

  @ApiProperty()
  @IsOptional()
  shippingType: number;

  @ApiProperty()
  @IsOptional()
  prevOrderShipping: number;

  @ApiProperty()
  @IsOptional()
  useWallet: boolean;

  @ApiProperty()
  @IsOptional()
  adminDiscountPercent: number;

  @ApiProperty()
  @IsOptional()
  userId: string;

  @ApiProperty({
    required: false,
    enum: PaymentGateway,
    example: PaymentGateway.meli,
  })
  @IsOptional()
  @IsIn(Object.values(PaymentGateway))
  paymentGateway: PaymentGateway;
}
