Fixed service state persistence to heritage on vin-lookup and license-plate-lookup

This commit is contained in:
Mark Harris 2022-05-19 14:37:34 -04:00
parent 42263b42d2
commit 37a6fe222c
4 changed files with 29 additions and 10 deletions

View file

@ -23,6 +23,7 @@ const storeMutations = {
UPDATE_REGISTRATION_FIRST_NAME: "updateRegistrationFirstName", UPDATE_REGISTRATION_FIRST_NAME: "updateRegistrationFirstName",
UPDATE_REGISTRATION_LAST_NAME: "updateRegistrationLastName", UPDATE_REGISTRATION_LAST_NAME: "updateRegistrationLastName",
UPDATE_SERVICE_LOCATION_ZIP_CODE: "updateServiceLocationZipCode", UPDATE_SERVICE_LOCATION_ZIP_CODE: "updateServiceLocationZipCode",
UPDATE_SERVICE_LOCATION_STATE: "updateServiceLocationState",
UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress", UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress",
// ORDER MUTATIONS // ORDER MUTATIONS

View file

@ -223,20 +223,29 @@ export default {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
}, },
async forwardButtonAction() { async forwardButtonAction() {
const zipValidation = this.serviceZip ?
await this.validateZip(this.serviceZip) : //Call zip validation services
await this.validateZip(this.registrationZip); const registrationZipValidationPromise = this.validateZip(this.registrationZip);
if (!zipValidation.data.isServiceable) { 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.$refs.funnelFooter.removeLoader();
this.isVinValid = true; this.isVinValid = true;
this.isRegistrationZipServicable = false; this.isRegistrationZipServicable = false;
this.isCarIdDifferent = false; this.isCarIdDifferent = false;
this.zipToDisplay = this.serviceZip ? this.serviceZip : this.registrationZip; this.zipToDisplay = this.serviceZip ? this.serviceZip : this.registrationZip;
return; return;
} } else if (!this.serviceZip) {
this.serviceZip = this.registrationZip;
}
//Lookup vin
const vinLookup = await this.lookupVin( const vinLookup = await this.lookupVin(
this.licensePlate, this.licensePlate,
zipValidation.data.state registrationZipValidationResults.data.state
).catch(() => { ).catch(() => {
this.$refs.funnelFooter.removeLoader(); this.$refs.funnelFooter.removeLoader();
this.isVinValid = false; this.isVinValid = false;
@ -246,6 +255,7 @@ export default {
this.isCarIdDifferent = this.isCarIdDifferent =
vinLookup.data.vehicle.carId !== store.getters.vehicle.carId; vinLookup.data.vehicle.carId !== store.getters.vehicle.carId;
//Handle changing car
if ( if (
this.isCarIdDifferent && this.isCarIdDifferent &&
vinLookup.data.vehicle.carId !== this.previouslyEnteredCarId vinLookup.data.vehicle.carId !== this.previouslyEnteredCarId
@ -262,12 +272,15 @@ export default {
return; return;
} }
//Save
this.updateCustomerInfo( this.updateCustomerInfo(
vinLookup.data.vin, vinLookup.data.vin,
vinLookup.data.vehicle, vinLookup.data.vehicle,
zipValidation.data.state registrationZipValidationResults.data.state,
serviceZipValidationResults.data.state
); );
//Navigate
this.navigateForward(); this.navigateForward();
}, },
navigateForward() { navigateForward() {
@ -294,7 +307,7 @@ export default {
lookupVin(plate, state) { lookupVin(plate, state) {
return baseMixin.methods.dispatchStoreAction(storeActions.LOOKUP_VIN_BY_PLATE,{ licensePlate: plate, licenseState: state }, false); 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) { if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); 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_STATE, registrationState);
store.commit(storeMutations.UPDATE_REGISTRATION_ZIP_CODE, this.registrationZip); 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_ZIP_CODE, this.serviceZip);
store.commit(storeMutations.UPDATE_SERVICE_LOCATION_STATE, serviceState);
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email); store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email);
}, },
}, },

View file

@ -312,7 +312,7 @@ export default {
this.isCarIdDifferent = true; this.isCarIdDifferent = true;
return; return;
} }
this.updateStore(vehicleLookupResponse.data); this.updateStore(vehicleLookupResponse.data, zipValidationResponse.data);
this.navigateForward(); this.navigateForward();
}, },
navigateForward(){ navigateForward(){
@ -336,7 +336,7 @@ export default {
{ vin } { vin }
); );
}, },
updateStore(carInfo) { updateStore(carInfo, zipInfo) {
if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){ if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); 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_VIF_NUMBER, carInfo.imageVifNumber);
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, 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_ZIP_CODE, this.zip);
store.commit(storeMutations.UPDATE_SERVICE_LOCATION_STATE, zipInfo.state);
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email); store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email);
}, },
}, },

View file

@ -153,6 +153,9 @@ export const mutations = {
updateServiceLocationZipCode(state, serviceLocationZip){ updateServiceLocationZipCode(state, serviceLocationZip){
state.order.serviceLocation.zipCode = serviceLocationZip; state.order.serviceLocation.zipCode = serviceLocationZip;
}, },
updateServiceLocationState(state, serviceLocationState){
state.order.serviceLocation.state = serviceLocationState;
},
updateRegistrationFirstName(state, firstName){ updateRegistrationFirstName(state, firstName){
state.order.vehicle.registration.firstName = firstName; state.order.vehicle.registration.firstName = firstName;
}, },