import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { ApprovalStatus } from '../../../common/enums';
import { RejectionReason } from '../enums/rejection-reason.enum';

export class ApprovalResponseDto {
  @ApiProperty({
    description: 'Approval ID (UUID)',
    example: '550e8400-e29b-41d4-a716-446655440000',
  })
  id: string;

  @ApiProperty({
    description: 'Approval ID (UUID) - alias for id',
    example: '550e8400-e29b-41d4-a716-446655440000',
  })
  approvalId?: string;

  @ApiPropertyOptional({
    description: 'Rejection ID (UUID) - alias for id when status is REJECTED',
    example: '550e8400-e29b-41d4-a716-446655440000',
  })
  rejectionId?: string;

  @ApiProperty({
    description: 'License request ID',
    example: '660e8400-e29b-41d4-a716-446655440001',
  })
  requestId: string;

  @ApiProperty({
    description: 'Department ID',
    example: 'FIRE_SAFETY',
  })
  departmentId: string;

  @ApiProperty({
    description: 'Department name',
    example: 'Fire Safety Department',
  })
  departmentName: string;

  @ApiProperty({
    description: 'Current approval status',
    enum: ApprovalStatus,
  })
  status: ApprovalStatus;

  @ApiPropertyOptional({
    description: 'ID of the user who approved/rejected',
    example: 'user-id-123',
  })
  approvedBy?: string;

  @ApiPropertyOptional({
    description: 'ID of the user who rejected (alias for approvedBy when status is REJECTED)',
    example: 'user-id-123',
  })
  rejectedBy?: string;

  @ApiPropertyOptional({
    description: 'Department code',
    example: 'FIRE_DEPT',
  })
  departmentCode?: string;

  @ApiPropertyOptional({
    description: 'When the approval was completed',
    example: '2024-01-20T14:30:00Z',
  })
  approvedAt?: Date;

  @ApiPropertyOptional({
    description: 'When the rejection was completed',
    example: '2024-01-20T14:30:00Z',
  })
  rejectedAt?: Date;

  @ApiProperty({
    description: 'Reviewer remarks or comments',
    example: 'All documents are in order and meet requirements.',
  })
  remarks: string;

  @ApiPropertyOptional({
    description: 'Reviewer comments (alias for remarks)',
    example: 'All documents are in order and meet requirements.',
  })
  comments?: string;

  @ApiPropertyOptional({
    description: 'IDs of documents reviewed',
    type: [String],
    example: ['550e8400-e29b-41d4-a716-446655440000'],
  })
  reviewedDocuments?: string[];

  @ApiPropertyOptional({
    description: 'Reason for rejection (if rejected)',
    enum: RejectionReason,
  })
  rejectionReason?: RejectionReason;

  @ApiPropertyOptional({
    description: 'List of required documents',
    type: [String],
    example: ['FIRE_SAFETY_CERTIFICATE', 'BUILDING_PLAN'],
  })
  requiredDocuments?: string[];

  @ApiPropertyOptional({
    description: 'When this approval was invalidated',
    example: '2024-01-20T15:30:00Z',
  })
  invalidatedAt?: Date;

  @ApiPropertyOptional({
    description: 'Reason for invalidation',
    example: 'Document was modified after approval',
  })
  invalidationReason?: string;

  @ApiPropertyOptional({
    description: 'When this approval was revalidated after invalidation',
    example: '2024-01-20T16:00:00Z',
  })
  revalidatedAt?: Date;

  @ApiProperty({
    description: 'Approval creation timestamp',
    example: '2024-01-15T10:30:00Z',
  })
  createdAt: Date;

  @ApiProperty({
    description: 'Approval last update timestamp',
    example: '2024-01-20T15:30:00Z',
  })
  updatedAt: Date;

  @ApiPropertyOptional({
    description: 'When the approval was completed (approved/rejected/etc)',
    example: '2024-01-20T14:30:00Z',
  })
  completedAt?: Date;

  @ApiPropertyOptional({
    description: 'Blockchain transaction hash for this approval',
    example: '0x1234567890abcdef...',
  })
  blockchainTxHash?: string;

  @ApiPropertyOptional({
    description: 'Whether the blockchain transaction has been confirmed',
    example: true,
  })
  blockchainConfirmed?: boolean;

  @ApiPropertyOptional({
    description: 'Whether the entire workflow is complete after this approval',
    example: false,
  })
  workflowComplete?: boolean;

  @ApiPropertyOptional({
    description: 'Next workflow step information',
    example: { id: 'step-2', name: 'Health Department Review' },
  })
  nextStep?: any;

  @ApiPropertyOptional({
    description: 'Next department assigned for approval',
    example: 'HEALTH_DEPT',
  })
  nextDepartment?: string;

  @ApiPropertyOptional({
    description: 'Current workflow step index (0-based)',
    example: 1,
  })
  currentStepIndex?: number;
}
