import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsArray, ValidateNested, ArrayMinSize, IsString, IsNumber, Min } from 'class-validator';
import { Type } from 'class-transformer';

export class BulkReserveFoodItemDto {
  @ApiProperty({ example: 'food-123', description: 'Food ID' })
  @IsNotEmpty()
  @IsString()
  foodId!: string;

  @ApiProperty({ example: 5, description: 'Quantity to reserve' })
  @IsNotEmpty()
  @IsNumber()
  @Min(1)
  @Type(() => Number)
  quantity!: number;
}

export class BulkReserveFoodDto {
  @ApiProperty({
    description: 'Array of food reservations to create',
    type: [BulkReserveFoodItemDto],
    example: [
      { foodId: 'food-123', quantity: 5 },
      { foodId: 'food-789', quantity: 3 },
    ],
  })
  @IsNotEmpty()
  @IsArray()
  @ArrayMinSize(1, { message: 'At least one item is required' })
  @ValidateNested({ each: true })
  @Type(() => BulkReserveFoodItemDto)
  items!: BulkReserveFoodItemDto[];
}
