import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
  ArrayMinSize,
  IsArray,
  IsDateString,
  IsIn,
  IsOptional,
  IsString,
  IsUUID,
} from 'class-validator';

import { RESCHEDULE_TRIGGERS } from '../entities/scheduling-event.entity';

export class PreviewRescheduleDto {
  @ApiProperty({ type: [String] })
  @IsArray()
  @ArrayMinSize(1)
  @IsUUID('4', { each: true })
  incomingBookingIds!: string[];

  @ApiProperty({ enum: RESCHEDULE_TRIGGERS })
  @IsIn([...RESCHEDULE_TRIGGERS])
  trigger!: (typeof RESCHEDULE_TRIGGERS)[number];

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  reason?: string;

  @ApiPropertyOptional({ example: '2026-06-22T08:00:00.000Z' })
  @IsOptional()
  @IsDateString()
  newDepartureDate?: string;
}

export class ExecuteRescheduleDto extends PreviewRescheduleDto {
  @ApiProperty({ type: [String], description: 'Booking IDs to assign after reschedule' })
  @IsArray()
  @IsUUID('4', { each: true })
  finalBookingIds!: string[];

  @ApiProperty({ type: [String], description: 'Booking IDs removed from the schedule' })
  @IsArray()
  @IsUUID('4', { each: true })
  displacedBookingIds!: string[];
}
