CSR-1996: bug fixes and refactoring
This commit is contained in:
parent
ed2adf208d
commit
fce292bb20
3 changed files with 40 additions and 42 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<textboxQuestion
|
||||
v-model="selectedAccountNumber"
|
||||
v-model="selectedAccountName"
|
||||
customInputId="autocomplete"
|
||||
class="mb-4 mt-5"
|
||||
cmsWidgetName="InsuranceCoQuestionWidget"
|
||||
|
|
@ -12,12 +12,6 @@
|
|||
import textboxQuestion from "@/digital-components/textbox-question/textbox-question";
|
||||
|
||||
// Supporting files
|
||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
import { Form, defineRule } from "vee-validate";
|
||||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
||||
import $ from "jquery";
|
||||
|
||||
// MAPPNG
|
||||
|
|
@ -50,14 +44,10 @@ export default {
|
|||
computed: {
|
||||
selectedAccountNumber: {
|
||||
get: function () {
|
||||
if (this.selectedAccountName.length > 0) {
|
||||
return this.selectedAccountName;
|
||||
} else {
|
||||
return this.modelValue?.toString();
|
||||
}
|
||||
return this.modelValue?.toString();
|
||||
},
|
||||
set: function (newValue) {
|
||||
this.$emit("update:modelValue", newValue);
|
||||
this.$emit("update:modelValue", newValue); // send data up to v-model on parent, s/b account number
|
||||
},
|
||||
},
|
||||
searchableInsuranceCompanyList() {
|
||||
|
|
@ -79,15 +69,27 @@ export default {
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
getParentAccountNumber(parentAccountName) {
|
||||
const matchedItem = this.searchableInsuranceCompanyList?.filter((item) => {
|
||||
return item.accountName === parentAccountName;
|
||||
getParentAccountNumber(name) {
|
||||
const matchedItems = this.searchableInsuranceCompanyList?.filter((item) => {
|
||||
return item.accountName?.toString() === name.toString();
|
||||
});
|
||||
|
||||
if (matchedItem) {
|
||||
return matchedItem[0].parentAccountNumber;
|
||||
if (matchedItems.length > 0) {
|
||||
return matchedItems[0].parentAccountNumber;
|
||||
} else {
|
||||
console.error("Error locating " + parentAccountName);
|
||||
console.error("Error locating accountNumber");
|
||||
return;
|
||||
}
|
||||
},
|
||||
getParentAccountName(number) {
|
||||
const matchedItems = this.searchableInsuranceCompanyList?.filter((item) => {
|
||||
return item.parentAccountNumber?.toString() === number.toString();
|
||||
});
|
||||
|
||||
if (matchedItems.length > 0) {
|
||||
return matchedItems[0].accountName;
|
||||
} else {
|
||||
console.error("Error locating accountName");
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
|
@ -104,30 +106,23 @@ export default {
|
|||
});
|
||||
response(matches);
|
||||
},
|
||||
selectParentAccountNumber(parentAccountName) {
|
||||
selectInsuranceCompany(parentAccountName) {
|
||||
// this runs upon user selection within jQueryUI Autocomplete
|
||||
if (!this.searchableInsuranceCompanyList) {
|
||||
console.error("No insurance companies found");
|
||||
return;
|
||||
}
|
||||
|
||||
// const selectedItem = this.searchableInsuranceCompanyList.filter((item) => {
|
||||
// return item.accountName === parentAccountName;
|
||||
// });
|
||||
|
||||
this.selectedAccountNumber = this.getParentAccountNumber(parentAccountName);
|
||||
|
||||
// if (selectedItem) {
|
||||
// this.selectedAccountName = parentAccountName;
|
||||
// //this.selectedAccountNumber = selectedItem[0].parentAccountNumber;
|
||||
// console.log("this.selectedAccountNumber", selectedItem[0].parentAccountNumber);
|
||||
// console.log("this.getParentAccountNumber", this.getParentAccountNumber(parentAccountName));
|
||||
// } else {
|
||||
// console.error("Error locating " + parentAccountName);
|
||||
// }
|
||||
const parentAccountNumber = this.getParentAccountNumber(parentAccountName);
|
||||
this.selectedAccountNumber = parentAccountNumber;
|
||||
this.selectedAccountName = this.getParentAccountName(parentAccountNumber);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
const select = this.selectParentAccountNumber;
|
||||
if (this.modelValue.length > 0) {
|
||||
this.selectedAccountName = this.getParentAccountName(this.modelValue?.toString());
|
||||
}
|
||||
|
||||
const select = this.selectInsuranceCompany;
|
||||
setTimeout(() => {
|
||||
$("#autocomplete").autocomplete({
|
||||
source: this.findMatches,
|
||||
|
|
|
|||
|
|
@ -11,9 +11,11 @@
|
|||
<div class="col-md-6 col-xl-4">
|
||||
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" class="mt-4" />
|
||||
|
||||
<insurance-company-question
|
||||
v-model="parentAccountNumber"
|
||||
:originalList="originalList" />
|
||||
<div v-if="originalList.length > 0">
|
||||
<insurance-company-question
|
||||
v-model="parentAccountNumber"
|
||||
:originalList="originalList" />
|
||||
</div>
|
||||
|
||||
<navbar
|
||||
cmsWidgetName="FunnelFooterWidget"
|
||||
|
|
@ -84,7 +86,8 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
parentAccountNumberFromStore() {
|
||||
return store?.order?.payment?.parentAccountNumber;
|
||||
const accountNumber = store.getters.order?.payment?.parentAccountNumber.toString();
|
||||
return accountNumber;
|
||||
},
|
||||
arePagePrerequisitesValid() {
|
||||
return store.getters.order.payment.isInsurance === true;
|
||||
|
|
@ -99,7 +102,7 @@ export default {
|
|||
|
||||
await this.dispatchStoreAction(
|
||||
this.storeActions.SAVE_PARENT_ACCOUNT_NUMBER,
|
||||
this.parentAccountNumber,
|
||||
this.parentAccountNumber.toString(),
|
||||
false
|
||||
);
|
||||
navigateToHeritageFunnel({
|
||||
|
|
|
|||
|
|
@ -1808,7 +1808,7 @@ export const actions = {
|
|||
savedSessionId: savedSessionId?.toString(),
|
||||
referralNumber: referralNumber?.toString(),
|
||||
referralDate: referralDate?.toString(),
|
||||
parentAccountNumber: parentAccountNumber,
|
||||
parentAccountNumber: parentAccountNumber?.toString(),
|
||||
referralCorrelationId: referralCorrelationId,
|
||||
},
|
||||
logApiCall: true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue