import { IsString, IsNumber, IsEnum, IsArray, ValidateNested, IsOptional } from 'class-validator';
import { Type } from 'class-transformer';
import { ExecutionType } from '../enums/execution-type.enum';
import { CompletionCriteria } from '../enums/completion-criteria.enum';
import { RejectionHandling } from '../enums/rejection-handling.enum';
import { DepartmentApprovalDto } from './department-approval.dto';

export class WorkflowStageDto {
  @IsString()
  stageId: string;

  @IsString()
  stageName: string;

  @IsNumber()
  stageOrder: number;

  @IsEnum(ExecutionType)
  executionType: ExecutionType;

  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => DepartmentApprovalDto)
  requiredApprovals: DepartmentApprovalDto[];

  @IsEnum(CompletionCriteria)
  completionCriteria: CompletionCriteria;

  @IsOptional()
  @IsNumber()
  threshold?: number;

  @IsOptional()
  @IsNumber()
  timeoutDays?: number;

  @IsEnum(RejectionHandling)
  rejectionHandling: RejectionHandling;

  @IsOptional()
  @IsString()
  escalationDepartment?: string;

  @IsOptional()
  metadata?: Record<string, any>;
}
