import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
import { SeasonPeriodEntity } from '../../domain/entities/season-period.entity';
import { EnumDays } from '../../constants';
import { ApiProperty } from '@nestjs/swagger';
import { IsObject, ValidateIf, ValidateNested } from 'class-validator';
import { Exclude } from 'class-transformer';
import { SeasonTypeModel } from 'src/modules/season-related/season-type/data/models/season-type.model';
import { SeasonPeriodHolidayDto } from './season-period-holiday.dto';
import { ItemRateModel } from 'src/modules/item-related/item-rate/data/models/item-rate.model';
import { ItemDto } from 'src/modules/item-related/item/infrastructure/dto/item.dto';

export class SeasonPeriodDto
  extends BaseStatusDto
  implements SeasonPeriodEntity
{
  @ApiProperty({
    type: Object,
    required: true,
    example: {
      id: 'uuid',
      name: 'High Season',
    },
  })
  @IsObject()
  season_type: SeasonTypeModel;

  @ApiProperty({
    type: Date,
    required: true,
    example: '2024/01/01',
  })
  start_date: Date;

  @ApiProperty({
    type: Date,
    required: true,
    example: '2024/12/30',
  })
  end_date: Date;

  @ApiProperty({
    type: [String],
    required: false,
    example: [EnumDays.FRIDAY, EnumDays.MONDAY],
  })
  @ValidateIf((body) => body.days)
  days: EnumDays[];

  @ApiProperty({
    type: [SeasonPeriodHolidayDto],
    required: false,
    example: [
      {
        start_date: '2024/01/01',
        end_date: '2024/12/30',
        holiday_name: 'Hari Raya',
      },
    ],
  })
  @ValidateNested({ each: true })
  @ValidateIf((body) => body.holidays)
  holidays: SeasonPeriodHolidayDto[];

  @Exclude()
  holiday_name: string;

  @ApiProperty({
    type: [Object],
    example: [
      {
        item: {
          id: 'uuid',
          name: 'Entrance Ticket',
        },
        price: 10000,
      },
    ],
  })
  item_rates: ItemRateModel[];
}
