import { ApiProperty } from '@nestjs/swagger';
import { Applicant } from '../../../database/models/applicant.model';

export class ApplicantResponseDto {
  @ApiProperty({
    description: 'Unique identifier for the applicant',
    example: '550e8400-e29b-41d4-a716-446655440000',
  })
  id: string;

  @ApiProperty({
    description: 'Email address of the applicant',
    example: 'john@example.com',
  })
  email: string;

  @ApiProperty({
    description: 'DigiLocker ID',
    example: '1234567890',
  })
  digilockerId: string;

  @ApiProperty({
    description: 'First name',
    example: 'John',
    required: false,
  })
  firstName?: string;

  @ApiProperty({
    description: 'Last name',
    example: 'Doe',
    required: false,
  })
  lastName?: string;

  @ApiProperty({
    description: 'Blockchain wallet address',
    example: '0x742d35Cc6634C0532925a3b844Bc112e6E6baB10',
  })
  walletAddress: string;

  @ApiProperty({
    description: 'Associated department code',
    example: 'DEPT001',
    required: false,
  })
  departmentCode?: string;

  @ApiProperty({
    description: 'Whether the applicant is active',
    example: true,
  })
  isActive: boolean;

  @ApiProperty({
    description: 'Timestamp when the applicant was created',
    example: '2024-01-15T10:30:00Z',
  })
  createdAt: Date;

  @ApiProperty({
    description: 'Timestamp when the applicant was last updated',
    example: '2024-01-15T10:30:00Z',
  })
  updatedAt: Date;

  @ApiProperty({
    description: 'Timestamp of last login',
    example: '2024-01-15T10:30:00Z',
    required: false,
  })
  lastLoginAt?: Date;

  static fromEntity(applicant: Applicant): ApplicantResponseDto {
    const dto = new ApplicantResponseDto();
    dto.id = applicant.id;
    dto.email = applicant.email;
    dto.digilockerId = applicant.digilockerId;
    dto.firstName = applicant.firstName;
    dto.lastName = applicant.lastName;
    dto.walletAddress = applicant.walletAddress;
    dto.departmentCode = applicant.departmentCode;
    dto.isActive = applicant.isActive;
    dto.createdAt = applicant.createdAt;
    dto.updatedAt = applicant.updatedAt;
    dto.lastLoginAt = applicant.lastLoginAt;
    return dto;
  }
}
