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

/**
 * Admin maintenance reschedule: move a train's departure to a new date/time.
 * Every allocated booking rides along (links and wagon assignments untouched);
 * only the dates move — the schedule's train set, route, and window rule
 * snapshot all stay exactly as they were.
 */
export class MaintenanceRescheduleDto {
  @ApiProperty({
    example: '2026-07-20T05:00:00.000Z',
    description: 'New scheduled departure date/time (ISO 8601)',
  })
  @IsISO8601()
  newDepartureDate!: string;

  @ApiPropertyOptional({ description: 'Why the train is being moved (logged)' })
  @IsOptional()
  @IsString()
  reason?: string;

  @ApiPropertyOptional({
    description: 'Client-side trigger tag (e.g. TRAIN_MAINTENANCE) — logged only',
  })
  @IsOptional()
  @IsString()
  trigger?: string;

  @ApiPropertyOptional({
    description:
      "The bookings the client believes are aboard — informational; the server moves the schedule's actual bookings",
    type: [String],
  })
  @IsOptional()
  @IsArray()
  @IsUUID('4', { each: true })
  incomingBookingIds?: string[];
}
