import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
import { ItemQueueEntity } from '../../domain/entities/item-queue.entity';
import { IsArray, IsNumber, IsString } from 'class-validator';
import { ItemType } from '../../constants';
import { ApiProperty } from '@nestjs/swagger';
import { ItemEntity } from 'src/modules/item-related/item/domain/entities/item.entity';
import { Exclude, Transform } from 'class-transformer';

export class ItemQueueDto extends BaseStatusDto implements ItemQueueEntity {
  @ApiProperty({
    name: 'max_peak_level',
    required: false,
    example: 'Menentukan level peak maksimal penuhnya wahana',
    default: 100,
  })
  @IsNumber()
  max_peak_level: number;

  @ApiProperty({
    name: 'call_preparation',
    required: false,
    example: 'Waktu persiapan untuk memanggil antrian dalam menit',
    default: 5,
  })
  @IsNumber()
  call_preparation: number;

  @Exclude()
  items: ItemEntity[];

  @ApiProperty({ name: 'name', required: true, example: 'Bundling w Entrance' })
  @IsString()
  name: string;

  @ApiProperty({
    name: 'information',
    required: false,
    example: 'Running text untuk display antrian',
  })
  @IsString()
  information: string;

  @ApiProperty({
    type: 'string',
    required: true,
    description: `Select (${JSON.stringify(Object.values(ItemType))})`,
    example: ItemType.BUNDLING,
  })
  item_type: ItemType;

  @ApiProperty({ type: [String], required: true })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  @IsArray()
  @IsString({ each: true })
  item_ids: string[];
}
