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

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

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

  createdBy: string | null;
  createdAt: string;
  updatedBy: string | null;
  updatedAt: string;
  branch: CustomerBranch[];

  _count: {
    employee: number;
  };
};

export type CustomerBranch = {
  customerCode?: string;
  wageRateText: 'string';
  wageRate: 0;
  payDateEN: 'string';
  payDate: 'string';
  jobDescription: 'string';
  jobPosition: 'string';
  businessType: 'string';
  agent: 'string';
  contactName: 'string';
  officeTel: 'string';
  contactTel: 'string';
  email: 'string';
  subDistrictId: 'string';
  districtId: 'string';
  provinceId: 'string';
  streetEN: 'string';
  street: 'string';
  mooEN: 'string';
  moo: 'string';
  soiEN: 'string';
  soi: 'string';
  addressEN: 'string';
  address: 'string';
  employmentOfficeEN: 'string';
  employmentOffice: 'string';
  homeCode: 'string';
  authorizedNameEN: 'string';
  authorizedName: 'string';
  authorizedCapital: 'string';
  registerDate: '2024-09-16T07:52:42.627Z';
  registerNameEN: 'string';
  registerName: 'string';
  legalPersonNo: 'string';
  citizenId: 'string';
  birthDate: '2024-09-16T07:52:42.627Z';
  gender: 'string';
  lastNameEN: 'string';
  lastName: 'string';
  firstNameEN: 'string';
  firstName: 'string';
  namePrefix: 'string';
  telephoneNo: 'string';
  codeCustomer: 'string';
  customerName: 'string';
  updatedByUserId: 'string';
  createdByUserId: 'string';
  code: 'string';
  statusOrder: 0;
  customerId: '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 = {
  customerCode?: string;
  customerId: string;
  legalPersonNo?: string;
  citizenId?: string;
  namePrefix?: string;
  firstName?: string;
  lastName?: string;
  firstNameEN?: string;
  lastNameEN?: string;
  telephoneNo?: string;
  gender?: string;
  birthDate?: string;
  businessType: string;
  jobPosition: string;
  jobDescription: string;
  payDate?: string;
  payDateEN?: string;
  wageRate: number;
  wageRateText: string;
  homeCode: string;
  employmentOffice: string;
  employmentOfficeEN?: string;
  address: string;
  addressEN?: string;
  street: string;
  streetEN?: string;
  moo?: string;
  mooEN?: string;
  soi?: string;
  soiEN?: string;
  provinceId: string;
  districtId: string;
  subDistrictId: string;
  contactName: string;
  email: string;
  contactTel?: string;
  officeTel?: string;
  agent?: string;
  status: Status;
  customerName?: string;
  registerName?: string;
  registerNameEN?: string;
  registerDate?: Date | null;
  authorizedCapital?: string;
  authorizedName?: string;
  authorizedNameEN?: string;
  code?: 'string';
  citizen?: CitizenPayload[];
  file?: {
    name?: string;
    group?: string;
    url?: string;
    file?: File;
    _meta?: Record<string, any>;
  }[];
};

export type CustomerCreate = {
  customerBranch?: (CustomerBranchCreate & {
    id?: string;
    branchCode?: string;
    codeCustomer?: string;
  })[];
  selectedImage?: string;
  status?: Status;
  customerType: CustomerType;
  registeredBranchId: string;
  image: File | null;
};

export type CustomerUpdate = {
  selectedImage?: string;
  status?: Status;
  customerType?: CustomerType;
  customerBranch?: (CustomerBranchCreate & {
    id?: string;
    branchCode?: string;
    codeCustomer?: 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;
};

export type CitizenPayload = {
  namePrefix?: string;
  firstName: string;
  firstNameEN?: string;
  middleName?: string;
  middleNameEN?: string;
  lastName: string;
  lastNameEN?: string;
  issueDate: Date;
  expireDate: Date;
  nationality: string;
  religion: string;
  gender: string;
  address?: string;
  addressEN?: string;
  soi?: string;
  soiEN?: string;
  moo?: string;
  mooEN?: string;
  street?: string;
  streetEN?: string;
  provinceId?: string;
  districtId?: string;
  subDistrictId?: string;
  file: File;
};
