import { IsNumber, IsBoolean, IsOptional, IsString, Min, IsEnum } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { DeliveryFeeTypeEnum, DeliveryMethodEnum } from '../interface/delivery';

export class CreateDeliveryDto {
  @ApiProperty({ example: 'dineIn', description: 'Delivery method name', enum: DeliveryMethodEnum })
  @IsEnum(DeliveryMethodEnum)
  method!: DeliveryMethodEnum;

  @ApiProperty({ example: 5000, description: 'Delivery fee' })
  @IsNumber()
  @Min(0)
  @Type(() => Number)
  deliveryFee!: number;

  @ApiProperty({ example: 100000, description: 'Minimum order price for free delivery' })
  @IsNumber()
  @Min(0)
  @Type(() => Number)
  minOrderPrice!: number;

  @ApiPropertyOptional({ example: 'توضیحات روش ارسال', description: 'Delivery method description' })
  @IsOptional()
  @IsString()
  description?: string;

  @ApiPropertyOptional({ example: true, description: 'Is this delivery method enabled?' })
  @IsOptional()
  @IsBoolean()
  @Type(() => Boolean)
  enabled?: boolean;

  @ApiPropertyOptional({ example: 0, description: 'Display order for sorting delivery methods' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  order?: number;

  @ApiPropertyOptional({ example: 0, description: 'Kilometer number' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  distanceBasedMinCost?: number;

  @ApiPropertyOptional({ example: 0, description: 'Delivery fee per kilometer' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  perKilometerFee?: number;

  @ApiPropertyOptional({
    example: DeliveryFeeTypeEnum.FIXED,
    description: 'Delivery fee type',
    enum: DeliveryFeeTypeEnum,
  })
  @IsOptional()
  @IsEnum(DeliveryFeeTypeEnum)
  deliveryFeeType!: DeliveryFeeTypeEnum;
}
