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_LAST_NAME: "updateRegistrationLastName",
UPDATE_SERVICE_LOCATION_ZIP_CODE: "updateServiceLocationZipCode",
UPDATE_SERVICE_LOCATION_STATE: "updateServiceLocationState",
UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress",
// ORDER MUTATIONS

View file

@ -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);
},
},

View file

@ -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);
},
},

View file

@ -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;
},