From 37a6fe222cbea1dda8d58f925032c57814365d48 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Thu, 19 May 2022 14:37:34 -0400 Subject: [PATCH] Fixed service state persistence to heritage on vin-lookup and license-plate-lookup --- src/constants/store-mutations.js | 1 + .../license-plate-lookup.vue | 30 ++++++++++++++----- src/layouts/vin-lookup/vin-lookup.vue | 5 ++-- src/store/index.js | 3 ++ 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 179b484ef..e8349ef40 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -23,6 +23,7 @@ const storeMutations = { UPDATE_REGISTRATION_FIRST_NAME: "updateRegistrationFirstName", UPDATE_REGISTRATION_LAST_NAME: "updateRegistrationLastName", UPDATE_SERVICE_LOCATION_ZIP_CODE: "updateServiceLocationZipCode", + UPDATE_SERVICE_LOCATION_STATE: "updateServiceLocationState", UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress", // ORDER MUTATIONS diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue index 7ec79773b..e3e4d0bbc 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.vue +++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue @@ -223,20 +223,29 @@ export default { this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); }, async forwardButtonAction() { - const zipValidation = this.serviceZip ? - await this.validateZip(this.serviceZip) : - await this.validateZip(this.registrationZip); - if (!zipValidation.data.isServiceable) { + + //Call zip validation services + const registrationZipValidationPromise = this.validateZip(this.registrationZip); + const serviceZipValidationPromise = this.serviceZip ? this.validateZip(this.serviceZip) : null; + const registrationZipValidationResults = await registrationZipValidationPromise; + const serviceZipValidationResults = serviceZipValidationPromise !== null ? (await serviceZipValidationPromise) : registrationZipValidationResults; + + //Handle service zip validations + if (!serviceZipValidationResults.data.isServiceable) { this.$refs.funnelFooter.removeLoader(); this.isVinValid = true; this.isRegistrationZipServicable = false; this.isCarIdDifferent = false; this.zipToDisplay = this.serviceZip ? this.serviceZip : this.registrationZip; return; - } + } else if (!this.serviceZip) { + this.serviceZip = this.registrationZip; + } + + //Lookup vin const vinLookup = await this.lookupVin( this.licensePlate, - zipValidation.data.state + registrationZipValidationResults.data.state ).catch(() => { this.$refs.funnelFooter.removeLoader(); this.isVinValid = false; @@ -246,6 +255,7 @@ export default { this.isCarIdDifferent = vinLookup.data.vehicle.carId !== store.getters.vehicle.carId; + //Handle changing car if ( this.isCarIdDifferent && vinLookup.data.vehicle.carId !== this.previouslyEnteredCarId @@ -262,12 +272,15 @@ export default { return; } + //Save this.updateCustomerInfo( vinLookup.data.vin, vinLookup.data.vehicle, - zipValidation.data.state + registrationZipValidationResults.data.state, + serviceZipValidationResults.data.state ); + //Navigate this.navigateForward(); }, navigateForward() { @@ -294,7 +307,7 @@ export default { lookupVin(plate, state) { return baseMixin.methods.dispatchStoreAction(storeActions.LOOKUP_VIN_BY_PLATE,{ licensePlate: plate, licenseState: state }, false); }, - updateCustomerInfo(vin, vehicleInfo, registrationState) { + updateCustomerInfo(vin, vehicleInfo, registrationState, serviceState) { if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) { store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); } @@ -312,6 +325,7 @@ export default { store.commit(storeMutations.UPDATE_REGISTRATION_STATE, registrationState); store.commit(storeMutations.UPDATE_REGISTRATION_ZIP_CODE, this.registrationZip); store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, this.serviceZip); + store.commit(storeMutations.UPDATE_SERVICE_LOCATION_STATE, serviceState); store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email); }, }, diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 1f4f6c9ce..7037f2fbb 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -312,7 +312,7 @@ export default { this.isCarIdDifferent = true; return; } - this.updateStore(vehicleLookupResponse.data); + this.updateStore(vehicleLookupResponse.data, zipValidationResponse.data); this.navigateForward(); }, navigateForward(){ @@ -336,7 +336,7 @@ export default { { vin } ); }, - updateStore(carInfo) { + updateStore(carInfo, zipInfo) { if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){ store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); } @@ -351,6 +351,7 @@ export default { store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, carInfo.imageVifNumber); store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, carInfo.imageVifNumber); store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, this.zip); + store.commit(storeMutations.UPDATE_SERVICE_LOCATION_STATE, zipInfo.state); store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email); }, }, diff --git a/src/store/index.js b/src/store/index.js index ce6ca8dae..0d5a9e355 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -153,6 +153,9 @@ export const mutations = { updateServiceLocationZipCode(state, serviceLocationZip){ state.order.serviceLocation.zipCode = serviceLocationZip; }, + updateServiceLocationState(state, serviceLocationState){ + state.order.serviceLocation.state = serviceLocationState; + }, updateRegistrationFirstName(state, firstName){ state.order.vehicle.registration.firstName = firstName; },