Merge pull request #1816 from Safelite/CSR-1996-fix-persist-data

Csr 1996 fix persist data
This commit is contained in:
bmauger 2024-04-05 14:50:26 -04:00 committed by GitHub
commit 77f375e3ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 46 additions and 32 deletions

View file

@ -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,6 +69,30 @@ export default {
},
},
methods: {
getParentAccountNumber(name) {
const matchedItems = this.searchableInsuranceCompanyList?.filter((item) => {
return item.accountName?.toString() === name.toString();
});
if (matchedItems.length > 0) {
return matchedItems[0].parentAccountNumber;
} else {
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;
}
},
findMatches(request, response) {
const matches = [];
const term = request?.term?.toUpperCase();
@ -92,26 +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;
});
if (selectedItem) {
this.selectedAccountName = parentAccountName;
this.selectedAccountNumber = selectedItem[0].parentAccountNumber;
} 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,

View file

@ -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({

View file

@ -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,