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

export class LoginDto {
  @ApiProperty({ description: 'Department API Key', example: 'fire_api_key_123' })
  @IsString()
  @IsNotEmpty()
  apiKey: string;

  @ApiProperty({ description: 'Department Code', example: 'FIRE_DEPT' })
  @IsString()
  @IsNotEmpty()
  departmentCode: string;
}

export class DigiLockerLoginDto {
  @ApiProperty({ description: 'DigiLocker ID', example: 'DL-GOA-123456789' })
  @IsString()
  @IsNotEmpty()
  digilockerId: string;

  @ApiPropertyOptional({ description: 'User name' })
  @IsString()
  @IsOptional()
  name?: string;

  @ApiPropertyOptional({ description: 'User email' })
  @IsEmail()
  @IsOptional()
  email?: string;

  @ApiPropertyOptional({ description: 'User phone' })
  @IsString()
  @IsOptional()
  phone?: string;
}

export class LoginResponseDto {
  @ApiProperty()
  accessToken: string;

  @ApiProperty()
  department: {
    id: string;
    code: string;
    name: string;
  };
}

export class DigiLockerLoginResponseDto {
  @ApiProperty()
  accessToken: string;

  @ApiProperty()
  applicant: {
    id: string;
    name: string;
    email: string;
  };
}

export class EmailPasswordLoginDto {
  @ApiProperty({ description: 'User email', example: 'admin@goa.gov.in' })
  @IsEmail()
  @IsNotEmpty()
  email: string;

  @ApiProperty({ description: 'User password', example: 'Admin@123' })
  @IsString()
  @IsNotEmpty()
  password: string;
}

export class UserLoginResponseDto {
  @ApiProperty()
  accessToken: string;

  @ApiProperty()
  user: {
    id: string;
    email: string;
    name: string;
    role: string;
    walletAddress: string;
    departmentId?: string;
  };
}
