diff --git a/src/constants/query-strings.js b/src/constants/query-strings.js index f75e526d6..d2dbcf976 100644 --- a/src/constants/query-strings.js +++ b/src/constants/query-strings.js @@ -1,6 +1,7 @@ const queryStrings = { FMG_PAGE: "fmgPage", START_TYPE: "start_type", + ZIP_CODE: "zipCode", }; export { queryStrings }; diff --git a/src/layouts/estimate/estimate.spec.js b/src/layouts/estimate/estimate.spec.js index c4b92830a..4a0a3f434 100644 --- a/src/layouts/estimate/estimate.spec.js +++ b/src/layouts/estimate/estimate.spec.js @@ -258,6 +258,9 @@ function setupMocks({ navigateWithSaving: jest.fn(), navigateWithoutSaving: jest.fn(), }, + route: { + query: {}, + }, }, }) { //Mock CMS Content diff --git a/src/layouts/estimate/estimate.vue b/src/layouts/estimate/estimate.vue index dd16a479f..4eafab25e 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -132,7 +132,7 @@ export default { data() { return { selectedVinLookupMethod: null, - serviceZipCode: this.getZipFromStore(), + serviceZipCode: this.getZipFromStore() ?? this.$route.query.zipCode, emailAddress: this.getEmailFromStore(), displayInvalidZipAlert: false, displayNonServiceableZipAlert: false, diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.spec.js b/src/layouts/license-plate-lookup/license-plate-lookup.spec.js index d83f49643..b23f5c101 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.spec.js +++ b/src/layouts/license-plate-lookup/license-plate-lookup.spec.js @@ -660,6 +660,9 @@ function setupMocks({ navigateWithoutSaving: jest.fn(), navigateWithSaving: jest.fn(), }, + route: { + query: {}, + }, store: { getters: { vehicle: { diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue index 159d89260..ec54fd4f7 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.vue +++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue @@ -152,7 +152,7 @@ export default { data() { return { licensePlate: this.getLicensePlateFromStore(), - registrationZipCode: this.getRegistrationZipFromStore(), + registrationZipCode: this.getRegistrationZipFromStore() ?? this.$route.query.zipCode, email: this.getEmailFromStore(), serviceZipCode: this.getServiceZipFromStore(), displayNonServiceableZipAlert: false, diff --git a/src/layouts/vin-lookup/vin-lookup.spec.js b/src/layouts/vin-lookup/vin-lookup.spec.js index aca1b99c2..fc15d3667 100644 --- a/src/layouts/vin-lookup/vin-lookup.spec.js +++ b/src/layouts/vin-lookup/vin-lookup.spec.js @@ -254,6 +254,7 @@ function setupMocks({ customMountOptions }) { mountOptions.global.mocks["$store"] = store; mountOptions.global.mixins = [mockMixin]; mountOptions["attachTo"] = document.body; // append wrapper to document.body to test DOM methods + mountOptions.route = { query: {} }; const wrapper = shallowMount(vinLookup, mountOptions); mockOutStubFunctions(wrapper); diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 990fd0658..17e981bc8 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -176,7 +176,7 @@ export default { data() { return { vin: this.getVinFromStore(), - serviceZipCode: this.getZipFromStore(), + serviceZipCode: this.getZipFromStore() ?? this.$route.query.zipCode, emailAddress: this.getEmailFromStore(), isCarIdDifferent: false, customAlertData: {}, diff --git a/src/router/index.js b/src/router/index.js index 30fc8583b..409ce0419 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -260,11 +260,24 @@ async function navigate( optionalParams.isSavingNavigation = isSavingNavigation; + // add querystring params to the route. if they are already in the store then no need to add them + var queryStringsObject = { + fmgPage: destinationFmgPageValue, + }; + + if ( + Object.hasOwn(currentRoute.query, queryStrings.ZIP_CODE) && + (store.getters.order.serviceLocation.zipCode === undefined || + store.getters.order.serviceLocation.zipCode == null) && + (store.getters.order.vehicle.registration.zipCode === undefined || + store.getters.order.vehicle.registration.zipCode == null) + ) { + queryStringsObject[queryStrings.ZIP_CODE] = currentRoute.query.zipCode; + } + router.push({ name: "root", - query: Object.assign(optionalQuery, { - fmgPage: destinationFmgPageValue, - }), + query: Object.assign(optionalQuery, queryStringsObject), params: optionalParams, }); } else if (matchingScenarioMap.destinationUrl !== undefined) {