import { District, Province, SubDistrict } from '../address';
import { Status } from '../types';
import { User } from '../user/types';

import { Customer, CustomerBranch } from '../customer/types';

export type Employee = {
  selectedImage?: string;
  id: string;
  code: string;
  nrcNo: string;
  createdByUserId: string;
  updatedByUserId: string;
  statusOrder: string;
  namePrefix: string;
  firstName: string;
  firstNameEN: string;
  lastName: string;
  lastNameEN: string;
  dateOfBirth: Date;
  gender: string;
  nationality: string;
  address: string;
  addressEN: string;
  provinceId: string;
  districtId: string;
  subDistrictId: string;
  zipCode: string;
  passportType: string;
  passportNumber: string;
  passportIssuingCountry: string;
  passportIssuingPlace: string;
  passportIssueDate: Date;
  passportExpiryDate: Date;
  previousPassportReference: string;
  visaType: string;
  visaNumber: string;
  visaIssueDate: Date;
  visaExpiryDate: Date;
  visaIssuingPlace: string;
  visaStayUntilDate: Date;
  workerStatus: string;
  customerBranchId: string;
  status: Status;
  tm6Number: string;
  entryDate: Date;
  createdAt: Date;
  createdBy: string;
  updatedAt: Date;
  updatedBy: string;
  subDistrict: SubDistrict | null;
  district: District | null;
  province: Province | null;
  customerBranch: CustomerBranch & { customer: Customer };
  employeeWork?: EmployeeWorkCreate[];
  employeeCheckup?: EmployeeCheckupCreate[];
  employeeOtherInfo?: EmployeeOtherCreate;
};

export type EmployeeCreate = {
  selectedImage?: string;
  id?: string;
  code: string;
  image: File | null;
  customerBranchId: string;
  status?: Status;
  nrcNo: string;

  dateOfBirth: Date | null;
  gender: string;
  nationality: string;

  namePrefix: string;
  firstName: string;
  firstNameEN: string;
  lastName: string;
  lastNameEN: string;
  middleName?: string;
  middleNameEN?: string;

  addressEN: string;
  address: string;
  zipCode: string;

  subDistrictId?: string | null;
  districtId?: string | null;
  provinceId?: string | null;

  employeeWork?: EmployeeWorkCreate[];

  employeeCheckup?: EmployeeCheckupCreate[];

  employeeOtherInfo?: EmployeeOtherCreate;

  file?: {
    name?: string;
    group?: string;
    url?: string;
    file?: File;
    _meta?: Record<string, any>;
  }[];
};

export type EmployeeUpdate = {
  customerBranchId?: string;
  status?: 'ACTIVE' | 'INACTIVE';

  code?: string;
  nrcNo?: string;

  dateOfBirth?: Date;
  gender?: string;
  nationality?: string;

  firstName?: string;
  firstNameEN?: string;
  lastName?: string;
  lastNameEN?: string;

  addressEN?: string;
  address?: string;
  zipCode?: string;
  email?: string;
  telephoneNo?: string;

  arrivalBarricade?: string;
  arrivalCardNo?: string;

  subDistrictId?: string | null;
  districtId?: string | null;
  provinceId?: string | null;
  image?: File;
};

export type EmployeeCheckup = {
  updatedAt: Date;
  updatedBy: Date;
  createdAt: Date;
  createdBy: string;
  coverageExpireDate: Date;
  coverageStartDate: Date;
  insuranceCompany: string;
  medicalBenefitScheme: string;
  remark: string;
  hospitalName: string;
  provinceId: string;
  checkupType: string;
  checkupResult: string;
  employeeId: string;
  id: string;
};

export type EmployeeCheckupCreate = {
  coverageExpireDate?: Date | null;
  coverageStartDate?: Date | null;
  insuranceCompany?: string;
  medicalBenefitScheme?: string;
  remark?: string;
  hospitalName?: string;
  provinceId?: string;
  checkupResult?: string;
  checkupType?: string;
  statusSave?: boolean;
  id?: string;
  updatedAt?: Date | string;
  updatedByUserId?: string;
  createdAt?: Date | string;
  createdByUserId?: string;
  employeeId?: string;
};

export type EmployeeWork = {
  updatedAt: Date;
  updatedBy: string;
  createdAt: Date;
  createdBy: string;
  workEndDate: Date;
  workPermitExpireDate: Date;
  workPermitIssuDate: Date;
  workPermitNo: string;
  workplace: string;
  jobType: string;
  positionName: string;
  ownerName: string;
  employeeId: string;
  id: string;
  remark?: string;
};

export type EmployeeWorkCreate = {
  workEndDate?: Date | null;
  workPermitExpireDate?: Date | null;
  workPermitIssuDate?: Date | null;
  workPermitNo?: string;
  workplace?: string;
  jobType?: string;
  positionName?: string;
  ownerName?: string;
  remark?: string;
  statusSave?: boolean;
  id?: string;
  updatedAt?: Date | string;
  updatedByUserId?: string;
  createdAt?: Date | string;
  createdByUserId?: string;
  employeeId?: string;
};

export type EmployeeOther = {
  motherBirthPlace: string;
  motherLastNameEN: string;
  motherFirstNameEN: string;
  fatherLastNameEN: string;
  fatherFirstNameEN: string;
  motherLastName: string;
  motherFirstName: string;
  fatherLastName: string;
  fatherFirstName: string;
  fatherBirthPlace: string;
  citizenId: string;
};

export type EmployeeOtherCreate = {
  motherBirthPlace?: string;
  motherLastNameEN?: string;
  motherFirstNameEN?: string;
  fatherLastNameEN?: string;
  fatherFirstNameEN?: string;
  motherLastName?: string;
  motherFirstName?: string;
  fatherLastName?: string;
  fatherFirstName?: string;
  fatherBirthPlace?: string;
  citizenId?: string;
  id?: string;
  statusSave?: boolean;
  updatedAt?: Date | string;
  updatedByUserId?: string;
  createdAt?: Date | string;
  createdByUserId?: string;
  employeeId?: string;
};

export type EmployeeHistory = {
  masterId: string;
  // updatedBy: string;
  updatedBy: User;
  updatedByUserId: string;
  valueAfter: string;
  valueBefore: string;
  field: string;
  updatedAt: Date;
  id: string;
};

export type NewEmployeeHistory = {
  date: string;
  data: {
    masterId: string;
    // updatedBy: string;
    updatedBy: User;
    updatedByUserId: string;
    updatedAt: Date;
    id: string;
    history: { valueAfter: string; valueBefore: string; field: string }[];
  }[];
};

export type EmployeeVisaPayload = {
  number: string;
  type: string;
  entryCount: number;
  issueCountry: string;
  issuePlace: string;
  issueDate: Date;
  expireDate: Date;
  mrz?: string;
  remark?: string;
};

export type EmployeePassportPayload = {
  number: string;
  type: string;
  issueDate: Date;
  expireDate: Date;
  issueCountry: string;
  issuePlace: string;
  previousPassportRef?: string | null;
};

export type EmployeeInCountryNoticePayload = {
  noticeNumber: string;
  noticeDate: string;
  nextNoticeDate: Date;
  tmNumber: string;
  entryDate: Date;
  travelBy: string;
  travelFrom: string;
};
