import { BaseFilterDto } from 'src/core/modules/infrastructure/dto/base-filter.dto';
import { FilterItemRateEntity } from '../../domain/entities/filter-item-rate.entity';
import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { ItemType } from 'src/modules/item-related/item-category/constants';

export class FilterItemRateDto
  extends BaseFilterDto
  implements FilterItemRateEntity
{
  @ApiProperty({
    required: false,
    type: Date,
    example: '2024-04-01',
  })
  start_date: Date;

  @ApiProperty({
    required: false,
    type: Date,
    example: '2024-04-30',
  })
  end_date: Date;

  @ApiProperty({
    type: ['string'],
    required: false,
    description: `Select ["${Object.values(ItemType)}"]`,
  })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  item_types: ItemType[];

  @ApiProperty({ type: ['string'], required: false })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  item_ids: string[];

  @ApiProperty({ type: ['string'], required: false })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  season_period_ids: string[];
}
