diff --git a/src/layouts/insurance-company/insurance-company.vue b/src/layouts/insurance-company/insurance-company.vue index 9d4682622..eb203ace2 100644 --- a/src/layouts/insurance-company/insurance-company.vue +++ b/src/layouts/insurance-company/insurance-company.vue @@ -48,7 +48,6 @@ import baseMixin from "@/mixins/base-mixin.js"; import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper"; import store from "@/store"; -import vinPagesMixin from "@/mixins/vin-pages-mixin"; import $ from "jquery"; // DEFINE VALIDATION RULES @@ -67,7 +66,6 @@ defineRule("vin-format", regex(/^[a-hA-Hj-nJ-NpPr-zR-Z0-9]{17}$/, errorMessages. export default { name: "insurance-company", - mixins: [vinPagesMixin], async beforeRouteEnter(to, from, next) { // Call APIs const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage); @@ -99,6 +97,7 @@ export default { data() { return { insuranceCompanyList: [], + selectedParentAccount: "", }; }, computed: { @@ -120,15 +119,37 @@ export default { this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); }, forwardButtonAction() { + this.dispatchStoreAction( + this.storeActions.SAVE_PARENT_ACCOUNT_NUMBER, + this.selectedParentAccount, + false + ); + navigateToHeritageFunnel({ shouldSaveSession: true, pageNameToLog: "insurance-company", loadingModal: this.$refs.loadingModal, }); }, + selectParentAccountNumber(parentAccountName) { + if (!this.insuranceCompanyList) { + console.error("No insurance companies found"); + return; + } + + var selectedItem = this.insuranceCompanyList.filter((item) => { + return item.accountName === parentAccountName; + }); + + if (selectedItem) { + this.selectedParentAccount = selectedItem[0].parentAccountNumber; + } else { + console.error("Error locating " + parentAccountName); + } + }, }, mounted() { - const select = this.handleAutocompleteSelect; + const select = this.selectParentAccountNumber; $("#autocomplete").autocomplete({ source: this.insuranceCompanyListTags, @@ -144,6 +165,9 @@ export default { w.html((i, html) => html.replace(re, "$1")); }, 5); }, + select: function (event, ui) { + select(ui.item.value); + }, }); }, watch: {