CSR-1996: bug fixes and refactoring

This commit is contained in:
Adam Caouette 2024-04-03 18:11:33 -04:00
parent ed2adf208d
commit fce292bb20
3 changed files with 40 additions and 42 deletions

View file

@ -1,6 +1,6 @@
<template> <template>
<textboxQuestion <textboxQuestion
v-model="selectedAccountNumber" v-model="selectedAccountName"
customInputId="autocomplete" customInputId="autocomplete"
class="mb-4 mt-5" class="mb-4 mt-5"
cmsWidgetName="InsuranceCoQuestionWidget" cmsWidgetName="InsuranceCoQuestionWidget"
@ -12,12 +12,6 @@
import textboxQuestion from "@/digital-components/textbox-question/textbox-question"; import textboxQuestion from "@/digital-components/textbox-question/textbox-question";
// Supporting files // 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"; import $ from "jquery";
// MAPPNG // MAPPNG
@ -50,14 +44,10 @@ export default {
computed: { computed: {
selectedAccountNumber: { selectedAccountNumber: {
get: function () { get: function () {
if (this.selectedAccountName.length > 0) { return this.modelValue?.toString();
return this.selectedAccountName;
} else {
return this.modelValue?.toString();
}
}, },
set: function (newValue) { 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() { searchableInsuranceCompanyList() {
@ -79,15 +69,27 @@ export default {
}, },
}, },
methods: { methods: {
getParentAccountNumber(parentAccountName) { getParentAccountNumber(name) {
const matchedItem = this.searchableInsuranceCompanyList?.filter((item) => { const matchedItems = this.searchableInsuranceCompanyList?.filter((item) => {
return item.accountName === parentAccountName; return item.accountName?.toString() === name.toString();
}); });
if (matchedItem) { if (matchedItems.length > 0) {
return matchedItem[0].parentAccountNumber; return matchedItems[0].parentAccountNumber;
} else { } 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; return;
} }
}, },
@ -104,30 +106,23 @@ export default {
}); });
response(matches); response(matches);
}, },
selectParentAccountNumber(parentAccountName) { selectInsuranceCompany(parentAccountName) {
// this runs upon user selection within jQueryUI Autocomplete
if (!this.searchableInsuranceCompanyList) { if (!this.searchableInsuranceCompanyList) {
console.error("No insurance companies found"); console.error("No insurance companies found");
return; return;
} }
const parentAccountNumber = this.getParentAccountNumber(parentAccountName);
// const selectedItem = this.searchableInsuranceCompanyList.filter((item) => { this.selectedAccountNumber = parentAccountNumber;
// return item.accountName === parentAccountName; this.selectedAccountName = this.getParentAccountName(parentAccountNumber);
// });
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);
// }
}, },
}, },
mounted() { mounted() {
const select = this.selectParentAccountNumber; if (this.modelValue.length > 0) {
this.selectedAccountName = this.getParentAccountName(this.modelValue?.toString());
}
const select = this.selectInsuranceCompany;
setTimeout(() => { setTimeout(() => {
$("#autocomplete").autocomplete({ $("#autocomplete").autocomplete({
source: this.findMatches, source: this.findMatches,

View file

@ -11,9 +11,11 @@
<div class="col-md-6 col-xl-4"> <div class="col-md-6 col-xl-4">
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" class="mt-4" /> <funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" class="mt-4" />
<insurance-company-question <div v-if="originalList.length > 0">
v-model="parentAccountNumber" <insurance-company-question
:originalList="originalList" /> v-model="parentAccountNumber"
:originalList="originalList" />
</div>
<navbar <navbar
cmsWidgetName="FunnelFooterWidget" cmsWidgetName="FunnelFooterWidget"
@ -84,7 +86,8 @@ export default {
}, },
methods: { methods: {
parentAccountNumberFromStore() { parentAccountNumberFromStore() {
return store?.order?.payment?.parentAccountNumber; const accountNumber = store.getters.order?.payment?.parentAccountNumber.toString();
return accountNumber;
}, },
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
return store.getters.order.payment.isInsurance === true; return store.getters.order.payment.isInsurance === true;
@ -99,7 +102,7 @@ export default {
await this.dispatchStoreAction( await this.dispatchStoreAction(
this.storeActions.SAVE_PARENT_ACCOUNT_NUMBER, this.storeActions.SAVE_PARENT_ACCOUNT_NUMBER,
this.parentAccountNumber, this.parentAccountNumber.toString(),
false false
); );
navigateToHeritageFunnel({ navigateToHeritageFunnel({

View file

@ -1808,7 +1808,7 @@ export const actions = {
savedSessionId: savedSessionId?.toString(), savedSessionId: savedSessionId?.toString(),
referralNumber: referralNumber?.toString(), referralNumber: referralNumber?.toString(),
referralDate: referralDate?.toString(), referralDate: referralDate?.toString(),
parentAccountNumber: parentAccountNumber, parentAccountNumber: parentAccountNumber?.toString(),
referralCorrelationId: referralCorrelationId, referralCorrelationId: referralCorrelationId,
}, },
logApiCall: true, logApiCall: true,