export function createEmployeeBankFormFields() {
  return {
    bankAccountName: '',
    bankName: '',
    bankAccountNo: ''
  }
}

export function mapEmployeeBankFormFields(employee) {
  return {
    bankAccountName: employee?.bankAccountName || '',
    bankName: employee?.bankName || '',
    bankAccountNo: employee?.bankAccountNo || ''
  }
}

export function getEmployeeBankSearchFields(employee) {
  return [
    employee?.bankAccountName,
    employee?.bankName,
    employee?.bankAccountNo
  ]
}

export function appendEmployeeBankUpdatePayload(payload, form, current, normalizeNullableText) {
  const nextBankAccountName = normalizeNullableText(form.bankAccountName)
  if (nextBankAccountName !== (current.bankAccountName || null)) {
    payload.bank_account_name = nextBankAccountName
  }

  const nextBankName = normalizeNullableText(form.bankName)
  if (nextBankName !== (current.bankName || null)) {
    payload.bank_name = nextBankName
  }

  const nextBankAccountNo = normalizeNullableText(form.bankAccountNo)
  if (nextBankAccountNo !== (current.bankAccountNo || null)) {
    payload.bank_account_no = nextBankAccountNo
  }
}
