import { IsArray, IsBoolean, IsEnum, IsInt, IsOptional, Min } from 'class-validator';
import { Type } from 'class-transformer';
import type { StageType } from '../entities/audit-report.entity';

export class CreateReportDto {
  @IsInt() @Type(() => Number)
  audit_schedule_row_id: number;

  /** A single standard of this audit. Leave out (or 0) when creating the combined report. */
  @IsOptional() @IsInt() @Min(0) @Type(() => Number)
  standard_id?: number;

  /** true = ONE report that covers every standard booked for this audit (needs 2+ standards). */
  @IsOptional() @IsBoolean()
  combined?: boolean;

  /** Optional. If omitted the stage is inferred from the audit row (audit_type / stage). */
  @IsOptional() @IsEnum(['stage1', 'stage2', 'surveillance', 'recert'])
  stage_type?: StageType;

  /**
   * Combined report only. standards.id values of booked standards the auditor does NOT want shown on this report
   * (cover, title, wording). At least two standards must remain. Stored in extras_json.hidden_standards.
   */
  @IsOptional() @IsArray() @IsInt({ each: true }) @Type(() => Number)
  exclude_standard_ids?: number[];
}
