import {
  IsString,
  IsUUID,
  IsOptional,
  IsDateString,
  IsEmail,
  IsEnum,
  MaxLength,
  MinLength,
} from 'class-validator';
import { EmployeeStatus } from '../entities/employee.entity';

/**
 * DTO for updating an existing employee
 * All fields are optional since it's a partial update
 */
export class UpdateEmployeeDto {
  @IsOptional()
  @IsString()
  @MinLength(1)
  @MaxLength(100)
  firstName?: string;

  @IsOptional()
  @IsString()
  @MinLength(1)
  @MaxLength(100)
  lastName?: string;

  @IsOptional()
  @IsUUID()
  userId?: string | null;

  @IsOptional()
  @IsUUID()
  partnerId?: string | null;

  @IsOptional()
  @IsUUID()
  departmentId?: string | null;

  @IsOptional()
  @IsUUID()
  jobPositionId?: string | null;

  @IsOptional()
  @IsUUID()
  managerId?: string | null;

  // Work contact
  @IsOptional()
  @IsEmail()
  @MaxLength(255)
  workEmail?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  workPhone?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  workMobile?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(255)
  workLocation?: string | null;

  // Personal data
  @IsOptional()
  @IsEmail()
  @MaxLength(255)
  personalEmail?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  personalPhone?: string | null;

  @IsOptional()
  @IsDateString()
  birthDate?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(20)
  gender?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(20)
  maritalStatus?: string | null;

  // Identification
  @IsOptional()
  @IsString()
  @MaxLength(50)
  identificationType?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(100)
  identificationNumber?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  taxId?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  socialSecurityNumber?: string | null;

  // Address
  @IsOptional()
  @IsString()
  @MaxLength(255)
  street?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(100)
  city?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(100)
  state?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(20)
  postalCode?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(100)
  country?: string | null;

  // Employment
  @IsOptional()
  @IsDateString()
  hireDate?: string;

  @IsOptional()
  @IsDateString()
  terminationDate?: string | null;

  @IsOptional()
  @IsEnum(['active', 'inactive', 'on_leave', 'terminated'])
  status?: EmployeeStatus;

  // Emergency contact
  @IsOptional()
  @IsString()
  @MaxLength(255)
  emergencyContactName?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  emergencyContactPhone?: string | null;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  emergencyContactRelationship?: string | null;

  // Metadata
  @IsOptional()
  @IsString()
  notes?: string | null;

  @IsOptional()
  @IsString()
  avatarUrl?: string | null;
}
