import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsEnum, IsInt, IsOptional, Min, Max, ValidateIf } from 'class-validator';
import { ParticipantRole } from 'src/common/enum/participant-role.enum';

/**
 * Bulk-register a program's eligible registrants to an online session.
 * Exactly one of `programId` / `sessionId` is required (the session target);
 * `role` decides whether they join as attendees (default) or panelists.
 * Already-registered registrants are skipped.
 */
export class BulkRegisterParticipantsDto {
  @ApiPropertyOptional({
    description: 'Program id — registers confirmed registrants across all its sessions',
  })
  @ValidateIf((o) => !o.sessionId)
  @IsInt()
  programId?: number;

  @ApiPropertyOptional({
    description: 'Program session id — registers confirmed registrants of this session only',
  })
  @ValidateIf((o) => !o.programId)
  @IsInt()
  sessionId?: number;

  @ApiPropertyOptional({
    description: 'Register everyone as `Attendee` (default) or `Panelist`.',
    enum: ParticipantRole,
    default: ParticipantRole.ATTENDEE,
  })
  @IsOptional()
  @IsEnum(ParticipantRole)
  role?: ParticipantRole;

  @ApiPropertyOptional({
    description: 'How many registrants to process per batch. Defaults to 10.',
    minimum: 1,
    maximum: 50,
    default: 10,
  })
  @IsOptional()
  @IsInt()
  @Min(1)
  @Max(50)
  batchSize?: number;
}
