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 e92fae541..b9fa11f81 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -130,7 +130,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 9f3b8c349..da529662f 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/vehicle-parts/vehicle-parts.vue b/src/layouts/vehicle-parts/vehicle-parts.vue index 56ac2ed15..cf27b3e24 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.vue +++ b/src/layouts/vehicle-parts/vehicle-parts.vue @@ -149,10 +149,10 @@ export default { methods: { arePagePrerequisitesValid() { // Check if isRepair is populated and if the pageData we need is here (Parts data) + const vehiclePartsFromPageData = store.getters.pageData(fmgPageValues.VEHICLE_PARTS); return ( store.getters.damage.isRepair != null && - store.getters.pageData(fmgPageValues.VEHICLE_PARTS) && - Object.keys(store.getters.pageData(fmgPageValues.VEHICLE_PARTS)).length !== 0 + vehiclePartsFromPageData?.partsOrQuestions?.some((part) => part?.glassName) ); }, async forwardButtonAction() { 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 11d7ac2ca..8a1dff06f 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -173,7 +173,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 a183e5895..2392ad05e 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) {