import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsArray, ValidateNested, ArrayMinSize } from 'class-validator';
import { Type } from 'class-transformer';
import { SetStockDto } from './set-stock.dto';

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

export class BulkSetStockDto {
  @ApiProperty({
    description: 'Array of stock items to set',
    type: [BulkSetStockItemDto],
    example: [
      { foodId: 'food-123', totalStock: 100, availableStock: 80 },
      { foodId: 'food-456', totalStock: 50, availableStock: 45 },
    ],
  })
  @IsNotEmpty()
  @IsArray()
  @ArrayMinSize(1, { message: 'At least one item is required' })
  @ValidateNested({ each: true })
  @Type(() => BulkSetStockItemDto)
  items!: BulkSetStockItemDto[];
}
