
import {
  ArrayNotEmpty,
  IsArray,
  IsInt,
  IsOptional,
  IsString,
  MaxLength,
  ValidateNested,
} from 'class-validator';
import { Type } from 'class-transformer';

export class ProceedToInquiryDto {
 
  @IsOptional()
  @IsString()
  @MaxLength(50)
  inquiry_type?: string;

  // Falls back to request.proposed_date
  @IsOptional()
  @IsString()
  @MaxLength(20)
  audit_date?: string;

  
  @IsOptional()
  @IsString()
  @MaxLength(150)
  auditor_name?: string;

  // Falls back to request.client_group (QRS / TQS / QRS_B)
  @IsOptional()
  @IsString()
  @MaxLength(20)
  cert_body?: string;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  audit_stage?: string;

  // Falls back to request.previous_cert_no
  @IsOptional()
  @IsString()
  @MaxLength(120)
  previous_cert_no?: string;

  // Falls back to request.scope_of_work — edits here also update
  // companies.scope_of_work via the sync inside InquiriesService.create()
  @IsOptional()
  @IsString()
  @MaxLength(5000)
  scope_of_work?: string;

  // Falls back to request.marketing_remarks
  @IsOptional()
  @IsString()
  @MaxLength(2000)
  notes?: string;

  @IsOptional()
  @IsString()
  @MaxLength(20)
  surveillance_audit_due?: string;

  @IsOptional()
  @IsString()
  @MaxLength(20)
  recertification_due?: string;

  // Falls back to request.standard_ids
  @IsOptional()
  @IsArray()
  @IsInt({ each: true })
  @Type(() => Number)
  standards?: number[];

  // Scheme user to assign the inquiry to (optional)
  @IsOptional()
  @IsInt()
  @Type(() => Number)
  assigned_to_id?: number;
}

/** Batch — for the multi-checkbox "Proceed" button. Shared overrides apply to every request. */
export class ProceedBatchToInquiryDto {
  @IsArray()
  @ArrayNotEmpty({ message: 'At least one request id is required' })
  @IsInt({ each: true })
  @Type(() => Number)
  request_ids: number[];

  @IsOptional()
  @ValidateNested()
  @Type(() => ProceedToInquiryDto)
  overrides?: ProceedToInquiryDto;
}