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

export type CustomerType = 'CORP' | 'PERS';

export type Customer = {
  registeredBranchId: string;
  imageUrl: string;
  id: string;
  code: string;
  customerType: CustomerType;
  status: Status;

  namePrefix: string;
  firstName: string;
  lastName: string;
  firstNameEN: string;
  lastNameEN: string;
  gender: string;
  birthDate: Date;

  createdBy: string | null;
  createdAt: string;
  updatedBy: string | null;
  updatedAt: string;
};

export type CustomerBranch = {
  customerId: string;
  contactName: string;
  wageRate: number;
  payDate: string;
  saleEmployee: string;
  jobDescription: string;
  jobPositionEN: string;
  jobPosition: string;
  businessTypeEN: string;
  businessType: string;
  employmentOffice: string;
  workplaceEN: string;
  workplace: string;
  authorizedCapital: string;
  registerDate: string;
  registerNameEN: string;
  registerName: string;
  legalPersonNo: string;
  citizenId: string;
  updatedByUserId: string;
  createdByUserId: string;
  statusOrder: number;
  telephoneNo: string;
  email: string;
  subDistrictId: string;
  districtId: string;
  provinceId: string;
  addressEN: string;
  address: string;
  code: string;
  id: string;

  status: Status;
  createdBy: string | null;
  createdAt: string;
  updatedBy: string | null;
  updatedAt: string;
  province: Province;
  district: District;
  subDistrict: SubDistrict;
  _count: {
    employee: number;
  };
};

export type CustomerBranchCreate = {
  code?: string;
  customerCode?: string;

  contactName: string;

  provinceId: string;
  districtId: string;
  subDistrictId: string;
  wageRate: number;
  payDate: Date | null;
  saleEmployee: string;
  jobDescription: string;
  jobPositionEN: string;
  jobPosition: string;
  businessTypeEN: string;
  businessType: string;
  employmentOffice: string;
  telephoneNo: string;
  email: string;
  addressEN: string;
  address: string;
  workplaceEN: string;
  workplace: string;
  status: Status | undefined;
  customerId: string;
  citizenId?: string;
  authorizedCapital?: string;
  registerDate?: Date | null;
  registerNameEN?: string;
  registerName?: string;
  legalPersonNo?: string;
  registerCompanyName: string;

  statusSave?: boolean;
  file?: File[];

  // id?: string;
  // code?: string;
  // provinceId?: string | null;
  // branchNo?: number;
  // address: string;
  // addressEN: string;
  // districtId?: string | null;
  // subDistrictId?: string | null;
  // zipCode: string;
  // email: string;
  // telephoneNo: string;
  // status?: Status;
  // name: string;
  // taxNo?: string | null;
  // nameEN: string;
  // legalPersonNo: string;
  // registerName: string;
  // registerDate: Date | null;
  // authorizedCapital: string;
  // employmentOffice: string;
  // bussinessType: string;
  // bussinessTypeEN: string;
  // jobPosition: string;
  // jobPositionEN: string;
  // jobDescription: string;
  // saleEmployee: string;
  // payDate: Date;
  // wageRate: number;
  // file?: File[];
  // statusSave?: boolean;
};

export type CustomerCreate = {
  code: string;
  customerBranch?: (CustomerBranchCreate & { id?: string })[];
  customerType: CustomerType;
  status?: Status;
  image: File | null;
  registeredBranchId: string;
  namePrefix: string;
  firstName: string;
  lastName: string;
  firstNameEN: string;
  lastNameEN: string;
  gender: string;
  birthDate: Date;
};

export type CustomerUpdate = {
  status?: Status;
  customerType?: CustomerType;
  customerBranch?: (CustomerBranchCreate & { id?: string })[];
  image?: File;
  registeredBranchId: string;

  namePrefix: string;

  firstName: string;
  lastName: string;
  firstNameEN: string;
  lastNameEN: string;
  gender: string;
  birthDate: Date;
};

export type BranchAttachmentCreate = {
  file: File[];
};

export type BranchAttachment = {
  name: string;
  url: string;
};

export type CustomerStats = {
  CORP: number;
  PERS: number;
};
