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

export class ItemSplitQueueDto {
  @ApiProperty({ name: 'queue_item_id', required: true })
  @IsString()
  @IsNotEmpty()
  queue_item_id: string;
  @ApiProperty({
    type: Number,
    required: true,
    example: 1,
  })
  @IsNumber()
  @Min(1)
  @IsNotEmpty()
  qty: number;
}

export class SplitQueueDto {
  @ApiProperty({ name: 'order_id', required: true })
  @IsString()
  @IsNotEmpty()
  order_id: string;

  @ApiProperty({ name: 'name', required: true })
  @IsString()
  @IsNotEmpty()
  name: string;

  @ApiProperty({ name: 'phone', required: true })
  @IsString()
  @IsNotEmpty()
  phone: string;

  @ApiProperty({
    type: [ItemSplitQueueDto],
    required: false,
    example: [
      {
        queue_item_id: 'string',
        qty: 1,
      },
    ],
  })
  @ValidateNested({ each: true })
  @IsArray()
  items: ItemSplitQueueDto[];
}
