diff --git a/src/constants/query-strings.js b/src/constants/query-strings.js index d2dbcf976..5ff1f636c 100644 --- a/src/constants/query-strings.js +++ b/src/constants/query-strings.js @@ -1,7 +1,7 @@ const queryStrings = { FMG_PAGE: "fmgPage", START_TYPE: "start_type", - ZIP_CODE: "zipCode", + ZIP_CODE: "zipcode", }; export { queryStrings }; diff --git a/src/layouts/estimate/estimate.vue b/src/layouts/estimate/estimate.vue index 722357e62..cfec5923d 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -134,7 +134,7 @@ export default { data() { return { selectedVinLookupMethod: null, - serviceZipCode: this.getZipFromStore() ?? this.$route.query.zipCode, + serviceZipCode: this.getZipFromStore() ?? this.$route.query.zipcode, emailAddress: this.getEmailFromStore(), displayInvalidZipAlert: false, displayNonServiceableZipAlert: false, @@ -147,9 +147,13 @@ export default { //Call APIs const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage); - const zip = Object.hasOwn(to.query, queryStrings.ZIP_CODE) ? to.query.zipCode : null; + const queryString = window.location.search; + const urlParams = new URLSearchParams(queryString); + const hasZip = urlParams.has(queryStrings.ZIP_CODE); + const zip = urlParams.get(queryStrings.ZIP_CODE); + var vinByAddressPromise; - if (zip) { + if (hasZip) { vinByAddressPromise = baseMixin.methods.dispatchStoreAction( storeActions.IS_VIN_BY_ADDRESS_PERMISSIBLE, zip, @@ -189,7 +193,7 @@ export default { } } - if (zip) { + if (zip && resultMap.vinByAddress === false) { var indexToRemove = resultMap.cmsContent.VinLookupMethod.Answers.findIndex( (answer) => answer.Name === "HomeAddress" ); diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue index ec54fd4f7..c97791937 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() ?? this.$route.query.zipCode, + registrationZipCode: this.getRegistrationZipFromStore() ?? this.$route.query.zipcode, email: this.getEmailFromStore(), serviceZipCode: this.getServiceZipFromStore(), displayNonServiceableZipAlert: false, diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 17e981bc8..e42187b12 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() ?? this.$route.query.zipCode, + 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 409ce0419..eb8e3947c 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -265,14 +265,23 @@ async function navigate( fmgPage: destinationFmgPageValue, }; + const queryString = window.location.search; + const urlParams = new URLSearchParams(queryString); + const lowerCaseParams = new URLSearchParams(); + for (const [name, value] of urlParams) { + lowerCaseParams.append(name.toLowerCase(), value); + } + const hasZip = lowerCaseParams.has(queryStrings.ZIP_CODE); + const zip = lowerCaseParams.get(queryStrings.ZIP_CODE); + if ( - Object.hasOwn(currentRoute.query, queryStrings.ZIP_CODE) && + hasZip && (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; + queryStringsObject[queryStrings.ZIP_CODE] = zip; } router.push({