import { IsString, IsArray, IsUUID, MinLength, IsOptional, IsEnum } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { ApprovalStatus } from '../../../common/enums';

export class ApproveRequestDto {
  @ApiPropertyOptional({
    description: 'Approval remarks or comments',
    minLength: 5,
    maxLength: 1000,
    example: 'All required documents have been reviewed and verified. Request is approved.',
  })
  @IsOptional()
  @IsString()
  @MinLength(5)
  remarks?: string;

  @ApiPropertyOptional({
    description: 'Approval comments (alternative to remarks)',
    minLength: 5,
    maxLength: 1000,
  })
  @IsOptional()
  @IsString()
  @MinLength(5)
  comments?: string;

  @ApiPropertyOptional({
    description: 'Array of reviewed document IDs (UUIDs)',
    type: [String],
    example: ['550e8400-e29b-41d4-a716-446655440000', '660e8400-e29b-41d4-a716-446655440001'],
  })
  @IsOptional()
  @IsArray()
  @IsUUID('4', { each: true })
  reviewedDocuments?: string[];

  @ApiPropertyOptional({
    description: 'ID of the reviewer (optional, will use authenticated user if not provided)',
    example: 'user-id-123',
  })
  @IsOptional()
  @IsString()
  reviewedBy?: string;

  @ApiPropertyOptional({
    description: 'The status of the approval (defaults to APPROVED)',
    enum: ApprovalStatus,
    example: ApprovalStatus.APPROVED,
  })
  @IsOptional()
  @IsEnum(ApprovalStatus)
  status?: ApprovalStatus;

  @ApiPropertyOptional({
    description: 'Digital signature of the approver',
  })
  @IsOptional()
  @IsString()
  signature?: string;
}
