From 9260e78f2f8d739ffd4abb7e1e8573ace7223ada Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 10 Jun 2025 12:23:56 -0400 Subject: [PATCH] Commit zipcode to store at start of funnel so it persists --- src/layouts/estimate/estimate.vue | 4 +--- .../license-plate-lookup.vue | 5 +---- src/layouts/service-zip/service-zip.vue | 3 +-- src/layouts/vehicle/vehicle.vue | 6 +----- src/layouts/vin-lookup/vin-lookup.vue | 4 +--- src/router/methods/route-logic/vehicle.js | 21 +++++++++++++++++++ 6 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/layouts/estimate/estimate.vue b/src/layouts/estimate/estimate.vue index 2818d2ecb..fe32d7b98 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -99,9 +99,7 @@ export default { lowerCaseParams.append(name.toLowerCase(), value); } - const zip = - peekQueryFromStash(queryStrings.ZIP_CODE) ?? - store.getters.order.serviceLocation.zipCode; + const zip = store.getters.order.serviceLocation.zipCode; var vinByAddressPromise; if (zip) { diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue index cab786b4a..441ef36d3 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.vue +++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue @@ -118,8 +118,6 @@ import baseMixin from "@/mixins/base-mixin.js"; import store from "@/store"; import vinPagesMixin from "@/mixins/vin-pages-mixin"; import { routeData } from "@/router/constants/routes"; -import { consumeQueryFromStash } from "@/router/methods/helpers/querystring-stash"; -import { queryStrings } from "@/constants/query-strings"; // DEFINE VALIDATION RULES defineRule("license-plate-required", required(errorMessages.LICENSE_PLATE_REQUIRED)); @@ -164,8 +162,7 @@ export default { data() { return { licensePlate: this.getLicensePlateFromStore(), - registrationZipCode: - this.getRegistrationZipFromStore() ?? consumeQueryFromStash(queryStrings.ZIP_CODE), + registrationZipCode: this.getRegistrationZipFromStore(), emailOrSms: this.getEmailOrSmsFromStore(), serviceZipCode: this.getServiceZipFromStore(), carId: this.getCarIdfromStore(), diff --git a/src/layouts/service-zip/service-zip.vue b/src/layouts/service-zip/service-zip.vue index 819fa4273..df1cb4e65 100644 --- a/src/layouts/service-zip/service-zip.vue +++ b/src/layouts/service-zip/service-zip.vue @@ -96,7 +96,6 @@ import { saveSession } from "@/helpers/heritage-integration/order-helper.js"; import baseMixin from "@/mixins/base-mixin.js"; import { queryStrings } from "@/constants/query-strings"; import { routeData } from "@/router/constants/routes"; -import { consumeQueryFromStash } from "@/router/methods/helpers/querystring-stash"; // Define Validation Rules defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED)); @@ -116,7 +115,7 @@ export default { mixins: [vinPagesMixin], data() { return { - serviceZipCode: this.getZipFromStore() ?? consumeQueryFromStash(queryStrings.ZIP_CODE), + serviceZipCode: this.getZipFromStore(), emailOrSms: this.getEmailOrSmsFromStore(), carId: this.getCarIdfromStore(), isHeavyTruck: this.getIsVehicleHeavyTruckServiceableFromStore(), diff --git a/src/layouts/vehicle/vehicle.vue b/src/layouts/vehicle/vehicle.vue index 8a6e13500..0820c0c5a 100644 --- a/src/layouts/vehicle/vehicle.vue +++ b/src/layouts/vehicle/vehicle.vue @@ -110,10 +110,6 @@ import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper"; import { applicationConfig } from "../../constants/application-config"; import { queryStrings } from "@/constants/query-strings"; import { getQuerystringParameter } from "@/helpers/querystring-helper"; -import { - consumeQueryFromStash, - peekQueryFromStash, -} from "@/router/methods/helpers/querystring-stash"; import { debugLog } from "@/helpers/debug-log-helper"; //define validation rules @@ -138,7 +134,7 @@ export default { imageUrl: this.getImagefromStore(), imageVifNumber: this.getImageVifNumberfromStore(), imageVifColor: this.getImageVifColorfromStore(), - serviceZipCode: this.getZipFromStore() ?? peekQueryFromStash(queryStrings.ZIP_CODE), + serviceZipCode: this.getZipFromStore(), yearOptions: [], makeOptions: [], modelOptions: [], diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 05f6fdbd7..23020cfd6 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -159,8 +159,6 @@ import baseMixin from "@/mixins/base-mixin.js"; import store from "@/store"; import vinPagesMixin from "@/mixins/vin-pages-mixin"; import { routeData } from "@/router/constants/routes"; -import { consumeQueryFromStash } from "@/router/methods/helpers/querystring-stash"; -import { queryStrings } from "@/constants/query-strings"; // DEFINE VALIDATION RULES defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED)); @@ -204,7 +202,7 @@ export default { data() { return { vin: this.getVinFromStore(), - serviceZipCode: this.getZipFromStore() ?? consumeQueryFromStash(queryStrings.ZIP_CODE), + serviceZipCode: this.getZipFromStore(), emailOrSms: this.getEmailOrSmsFromStore(), carId: this.getCarIdfromStore(), isHeavyTruck: this.getIsVehicleHeavyTruckServiceableFromStore(), diff --git a/src/router/methods/route-logic/vehicle.js b/src/router/methods/route-logic/vehicle.js index e1da282d0..20162461a 100644 --- a/src/router/methods/route-logic/vehicle.js +++ b/src/router/methods/route-logic/vehicle.js @@ -4,6 +4,10 @@ import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper"; import { routeData } from "@/router/constants/routes"; import { isVerifiedInsurance } from "@/router/methods/helpers/requires-verified-redirect"; import store from "@/store"; +import { queryStrings } from "@/constants/query-strings"; +import baseMixin from "@/mixins/base-mixin"; +import { storeActions } from "@/constants/store-actions"; +import { consumeQueryFromStash } from "@/router/methods/helpers/querystring-stash"; export async function vehicleBeforeEnter(to, from) { // If cookie indicates that vehicle has changed during insurance flow, reset parts info. @@ -12,6 +16,23 @@ export async function vehicleBeforeEnter(to, from) { store.commit(storeMutations.RESET_GLASS_PARTS_STATE); } + // If there is a zip querystring, consume & commit it here. + const newZipFromQuerystring = consumeQueryFromStash(queryStrings.ZIP_CODE); + if (newZipFromQuerystring) { + const zipData = await baseMixin.methods.getZipCodeData( + newZipFromQuerystring, + routeData.VEHICLE.name + ); + + if (zipData.isValid) { + store.dispatch(storeActions.SAVE_SERVICE_ZIP_CODE_INFO, { + zipCode: newZipFromQuerystring, + state: zipData.state.state, + zipCodeCtu: zipData.zipCodeCtu, + }); + } + } + if (isVerifiedInsurance()) { return { name: routeData.VEHICLE_DAMAGE.name,