import { ApiProperty } from "@nestjs/swagger"
import {
  IsString,
  IsInt,
  IsOptional,
  IsEmail,
  IsIn,
  IsArray,
  ValidateNested,
  IsDate,
  IsNumber,
} from "class-validator"
import { Type } from "class-transformer"
import { CreateAddressDto } from "../address/create-address.dto"
import { CreateIdProofDto } from "../id-proof/create-id-proof.dto"

export class UpdateTeamMemberDto {
  @ApiProperty({
    example: 1,
    description: "Role ID of the team member",
    required: false,
  })
  @IsOptional()
  @IsInt()
  role_id?: number

  // @ApiProperty({ example: 2, description: "Department ID", required: false })
  // @IsOptional()
  // @IsInt()
  // department_id?: number

  // @ApiProperty({
  //   example: 3,
  //   description: "Business Vertical ID",
  //   required: false,
  // })
  // @IsOptional()
  // @IsInt()
  // business_vertical_id?: number

  @ApiProperty({
    description: "ID of the department associated with the role",
    example: [1, 2],
    required: false,
  })
  @IsOptional()
  @IsArray()
  @IsNumber({}, { each: true })
  @Type(() => Number)
  department?: number[]

  @ApiProperty({
    description: "ID of the business vertical associated with the role",
    example: [1, 2],
    required: false,
  })
  @IsOptional()
  @IsArray()
  @IsNumber({}, { each: true })
  @Type(() => Number)
  business_vertical?: number[]

  @ApiProperty({
    example: [1, 3, 5],
    description: "IDs of the languages spoken by the team member",
    required: false,
  })
  @IsOptional()
  // @IsArray()
  // @IsNumber({}, { each: true })
  // @Type(() => Number)
  languages?: number[]

  @ApiProperty({
    example: 4,
    description: "Reporting to Team Member ID",
    required: false,
  })
  @IsOptional()
  @IsInt()
  reporting_to_id?: number

  @ApiProperty({
    type: "string",
    format: "binary",
    description: "Profile photo file to upload",
    required: false,
  })
  @IsOptional()
  profile_photo?: any

  @ApiProperty({ example: "John", description: "First name", required: false })
  @IsOptional()
  @IsString()
  first_name?: string

  @ApiProperty({ example: "Doe", description: "Last name", required: false })
  @IsOptional()
  @IsString()
  last_name?: string

  @ApiProperty({
    example: "john.doe@example.com",
    description: "Email address",
    required: false,
  })
  @IsOptional()
  @IsEmail()
  email?: string

  @ApiProperty({
    example: "9876543210",
    description: "Phone number",
    required: false,
  })
  @IsOptional()
  @IsString()
  phone_number?: string

  @ApiProperty({ example: "+91", description: "Country code", required: false })
  @IsOptional()
  @IsString()
  country_code?: string

  @ApiProperty({
    example: "1990-01-01",
    description: "Date of birth",
    required: false,
  })
  @IsOptional()
  @IsDate()
  @Type(() => Date)
  dob?: Date

  @ApiProperty({ example: "Male", description: "Gender", required: false })
  @IsOptional()
  @IsString()
  gender?: string

  @ApiProperty({
    example: "Jane Doe",
    description: "Emergency contact name",
    required: false,
  })
  @IsOptional()
  @IsString()
  emergency_contact_name?: string

  @ApiProperty({
    example: "+91",
    description: "Emergency contact country code",
    required: false,
  })
  @IsOptional()
  @IsString()
  emergency_contact_code?: string

  @ApiProperty({
    example: "9876543211",
    description: "Emergency contact number",
    required: false,
  })
  @IsOptional()
  @IsString()
  emergency_contact_number?: string

  @ApiProperty({
    example: "2024-04-01",
    description: "Joining date",
    required: false,
  })
  @IsOptional()
  @IsDate()
  @Type(() => Date)
  joining_date?: Date

  @ApiProperty({
    example: "India",
    description: "Working location",
    required: false,
  })
  @IsOptional()
  @IsInt()
  working_location?: number

  @ApiProperty({
    example: "India",
    description: "Working location",
    required: false,
  })
  @IsOptional()
  @IsInt()
  working_city_location?: number

  @ApiProperty({
    example: "employee",
    description: "Employment type",
    required: false,
    enum: ["employee", "contractor", "part-time-employee", "affiliate"],
  })
  @IsOptional()
  @IsString()
  @IsIn(["employee", "contractor", "part-time-employee", "affiliate"])
  employment_type?: string

  @ApiProperty({
    example: "active",
    description: "Status of the team member",
    required: false,
    enum: ["active", "inactive", "inprogress"],
  })
  @IsOptional()
  @IsString()
  @IsIn(["active", "inactive"])
  status?: string

  @ApiProperty({
    example: "off-duty",
    description: "Duty status of the team member",
    required: false,
    enum: ["on-duty", "off-duty"],
  })
  @IsOptional()
  @IsString()
  @IsIn(["on-duty", "off-duty"])
  duty_status?: string

  @ApiProperty({
    example: "active",
    description: "Form status of the team member",
    required: false,
    enum: ["draft", "submitted"],
  })
  @IsOptional()
  @IsString()
  @IsIn(["draft", "submitted"])
  form_status?: string

  @IsOptional()
  @IsInt()
  current_step?: number

  @ApiProperty({
    isArray: true,
    type: [CreateAddressDto],
    description: "Array of addresses",
    required: false,
  })
  @IsOptional()
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => CreateAddressDto)
  addresses?: CreateAddressDto[]

  @ApiProperty({
    isArray: true,
    type: [CreateIdProofDto],
    description: "Array of ID proofs",
    required: false,
  })
  @IsOptional()
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => CreateIdProofDto)
  id_proofs?: CreateIdProofDto[]
}
