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

export class ApproveStepDto {
  @ApiProperty({ description: 'LINE_STAFF | DIRECTOR | CEO' })
  @IsString()
  requiredRole!: string;
}

export class RequestChangesDto {
  @ApiProperty({ description: 'Note explaining what the customer must fix' })
  @IsString()
  @MinLength(1)
  note!: string;
}

export class RejectContractDto {
  @ApiProperty()
  @IsString()
  @MinLength(1)
  reason!: string;
}

export class RejectStepDto {
  @ApiProperty()
  @IsString()
  @MinLength(1)
  reason!: string;

  /**
   * Where the rejection lands. Omitted → the customer: the contract goes to
   * REJECTED and the customer must resubmit (unchanged legacy behaviour, and
   * the only option for the first approver in the chain). Set to an EARLIER
   * approved step's id → send-back: that step and everything after it reset to
   * PENDING and the chain re-runs from there; the contract never leaves
   * PENDING_APPROVAL and the customer is not involved.
   */
  @ApiPropertyOptional({
    description:
      'Id of an earlier approval step to send the contract back to. Omit to reject to the customer.',
  })
  @IsOptional()
  @IsUUID()
  returnToStepId?: string;
}

export class CancelContractDto {
  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  reason?: string;
}
