From d68f0389c44ae91c75f03886cadd0b5f4a6c8cce Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Tue, 5 Jul 2022 16:32:58 -0400 Subject: [PATCH] Made mutations conditional --- src/store/index.js | 64 ++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index c03421fa8..4fd62f46e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -661,10 +661,10 @@ export const actions = { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - } - //Save new values - context.commit(storeMutations.UPDATE_YEAR, year); + //Save new values + context.commit(storeMutations.UPDATE_YEAR, year); + } }, saveVehicleMake(context, make) { @@ -681,10 +681,10 @@ export const actions = { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - } - //Save new values - context.commit(storeMutations.UPDATE_MAKE, make); + //Save new values + context.commit(storeMutations.UPDATE_MAKE, make); + } }, saveVehicleModel(context, model) { @@ -700,10 +700,10 @@ export const actions = { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - } - //Save new values - context.commit(storeMutations.UPDATE_MODEL, model); + //Save new values + context.commit(storeMutations.UPDATE_MODEL, model); + } }, saveVehicleStyle(context, style) { @@ -718,10 +718,10 @@ export const actions = { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - } - //Save new values - context.commit(storeMutations.UPDATE_STYLE, style); + //Save new values + context.commit(storeMutations.UPDATE_STYLE, style); + } }, saveVehicleDamage(context, { isWindshieldRepair, selectedGlassToReplace, selectedWindshieldChipCount }) { @@ -752,14 +752,13 @@ export const actions = { if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); } + + //Save new values + context.dispatch(storeActions.SAVE_EMAIL, customerEmail); + context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo); + context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo); + context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo); } - - //Save new values - context.dispatch(storeActions.SAVE_EMAIL, customerEmail); - context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo); - - context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo); - context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo); }, saveRegistrationLicensePlateLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail }) { //Reset dependent state when changing @@ -770,14 +769,13 @@ export const actions = { if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); } + + //Save new values + context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo); + context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo); + context.dispatch(storeActions.SAVE_EMAIL, customerEmail); + context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo); } - - //Save new values - context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo); - context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo); - - context.dispatch(storeActions.SAVE_EMAIL, customerEmail); - context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo); }, saveRegistrationAddressLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail }) { //Reset dependent state when changing @@ -788,14 +786,13 @@ export const actions = { if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); } + + //Save new values + context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo); + context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo); + context.dispatch(storeActions.SAVE_EMAIL, customerEmail); + context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo); } - - //Save new values - context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo); - context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo); - - context.dispatch(storeActions.SAVE_EMAIL, customerEmail); - context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo); }, // Misc order actions @@ -813,6 +810,7 @@ export const actions = { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); } + //Save new values context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo); } },