import { Type } from 'class-transformer';
import {
  ArrayUnique,
  IsArray,
  IsBoolean,
  IsEnum,
  IsInt,
  IsNotEmpty,
  IsNumber,
  IsOptional,
  IsString,
  Max,
  Min,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { MealType } from '../interface/food.interface';

export class CreateFoodDto {
  @IsNotEmpty()
  @IsString()
  @ApiProperty()
  categoryId: string;

  @IsOptional()
  @IsString()
  @ApiPropertyOptional({ example: 'قرمه سبزی' })
  title?: string;

  @IsOptional()
  @IsString()
  @ApiPropertyOptional({ example: 'توضیحات غذا' })
  desc?: string;

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  @ApiPropertyOptional({ type: [String] })
  content?: string[];

  @IsOptional()
  @IsArray()
  @ArrayUnique()
  @IsInt({ each: true })
  @Min(0, { each: true })
  @Max(6, { each: true })
  @Type(() => Number)
  @ApiPropertyOptional({ type: [Number], example: [0, 1, 2, 3, 4, 5, 6] })
  weekDays?: number[];

  @IsOptional()
  @IsArray()
  @ArrayUnique()
  @IsEnum(MealType, { each: true })
  @ApiPropertyOptional({ enum: MealType, isArray: true })
  mealTypes?: MealType[];

  @IsOptional()
  @IsNumber()
  @Min(0)
  @Type(() => Number)
  @ApiPropertyOptional({ example: 120000 })
  price?: number;

  @IsOptional()
  @IsInt()
  @Min(0)
  @Type(() => Number)
  @ApiPropertyOptional({ example: 15 })
  prepareTime?: number;

  @IsOptional()
  @IsBoolean()
  @ApiPropertyOptional({ example: true })
  @Type(() => Boolean)
  isActive?: boolean;

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  @ApiPropertyOptional({ type: [String] })
  images?: string[];

  @IsOptional()
  @IsBoolean()
  @ApiPropertyOptional({ example: false })
  @Type(() => Boolean)
  inPlaceServe?: boolean;

  @IsOptional()
  @IsBoolean()
  @ApiPropertyOptional({ example: false })
  @Type(() => Boolean)
  pickupServe?: boolean;

  @IsOptional()
  @IsNumber()
  @Min(0)
  @Type(() => Number)
  @ApiPropertyOptional({ example: 0 })
  discount?: number;

  @IsOptional()
  @IsNumber()
  @Min(0)
  @Type(() => Number)
  @ApiProperty({ example: 50 })
  dailyStock: number;

  @IsOptional()
  @IsBoolean()
  @ApiPropertyOptional({ example: false })
  @Type(() => Boolean)
  isSpecialOffer?: boolean;

  @IsOptional()
  @IsInt()
  @Min(0)
  @Type(() => Number)
  @ApiPropertyOptional({ example: 1 })
  order?: number;

}
