pushing changes csr-439

This commit is contained in:
Donielle Austin 2022-06-24 13:44:03 -04:00
parent 123666dd9e
commit b76811ded0
14 changed files with 154 additions and 207 deletions

View file

@ -32,9 +32,20 @@ const storeActions = {
RESET_PARTS_STATE_AND_DEPENDENCIES: "resetPartsAndDependencies",
RESET_STATE: "resetState",
//RESET STATE
RESET_SAVE_VEHICLE_YEAR: "saveVehicleYear",
RESET_SAVE_VEHICLE_MAKE :"saveVehicleMake"
//RESET COMPONENT STATE
SAVE_VEHICLE_YEAR: "saveVehicleYear",
SAVE_VEHICLE_MAKE:"saveVehicleMake",
SAVE_VEHICLE_MODEL:"saveVehicleModel",
SAVE_VEHICLE_STYLE: "saveVehicleStyle",
SAVE_VEHICLE_DAMAGE: "saveVehicleDamage",
SAVE_VIN_LOOKUP: "saveVinLookup",
SAVE_SERVICE_LOCATION: "saveServiceLocation",
SAVE_EMAIL: "saveEmail",
SAVE_REGISTRATION_LICENSE_PLATE_LOOKUP: "saveRegistrationLicensePlateLookup",
SAVE_VIN: "saveVin",
SAVE_REGISTRATION_ADDRESS_LOOKUP: "saveRegistrationAddressLookup",
SAVE_PARTS_QUESTION_ANSWERS: "savePartQuestionAnswers",
SAVE_GLASS_PARTS: "saveGlassParts",
};
export { storeActions };

View file

@ -56,7 +56,6 @@ export async function navigateToHeritageFunnel() {
export async function navigateAfterSaveToHeritageFunnel(currentRoute) {
const currentComponent = currentRoute.matched[0].components;
currentComponent.default.methods.resetDependentState();
// Create the order (or save existing order) when navigating to Heritage Funnel.
await saveOrder();

View file

@ -288,7 +288,7 @@ export default {
// if a different vehicle is found than the one entered and the selected glass
// is not available for that vehicle
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
this.$router.navigateAfterSave(
this.$router.navigate(
// then navigate back to "vehicle-damage", and display vehicle changed alert
// on that page
this.navigationScenarios.CONTINUING_WITH_DIFFERENT_GLASS,
@ -313,7 +313,7 @@ export default {
navigateAfterSaveToHeritageFunnel(this.$route);
} else {
// if there are no matches or there are multiple matches, navigate to "address-vehicles" page
this.$router.navigateAfterSave(this.navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, this.$route, {}, {}, carsFound);
this.$router.navigate(this.navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, this.$route, {}, {}, carsFound);
}
}

View file

@ -180,7 +180,7 @@ export default {
},
navigateForward() {
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
this.$router.navigateAfterSave(
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD,
this.$route,
{},
@ -202,6 +202,7 @@ export default {
resetDependentState() { // needed because navigateAfterSaveToHeritageFunnel calls it
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
},
//this.$store.dispatch(storeActions.SAVE_VIN, vin,vehicle),
updateCustomerInfo(vin, vehicle) {
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);

View file

@ -288,7 +288,7 @@ export default {
},
navigateForward() {
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
this.$router.navigateAfterSave(
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD,
this.$route,
{},

View file

@ -301,11 +301,11 @@ export default {
// If vin already exists, navigate directly to vin-lookup
if(store.getters.vehicle.vin) {
this.$router.navigateAfterSave(this.navigationScenarios.CLICKED_FORWARD_WITH_VIN, this.$route);
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITH_VIN, this.$route);
return;
}
else {
this.$router.navigateAfterSave(this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN, this.$route);
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN, this.$route);
return;
}
},

View file

@ -82,30 +82,12 @@ export default {
}
return false;
},
resetDependentState: function(){
store.dispatch(storeActions.RESET_SAVE_VEHICLE_MAKE);
}
/* resetDependentState() {
// Set
store.commit(storeMutations.UPDATE_MODEL, null);
store.commit(storeMutations.UPDATE_STYLE, null);
store.commit(storeMutations.UPDATE_CAR_ID, null);
store.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
store.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null);
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
// Invokes
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
store.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
}, */
},
watch: {
selectedMake(make) {
this.$store.commit(this.storeMutations.UPDATE_MAKE, make);
this.$router.navigateAfterSave(
this.$store.dispatch(storeActions.SAVE_VEHICLE_MAKE, make);
this.$router.navigate(
this.navigationScenarios.SELECTED_MAKE,
this.$route
);

View file

@ -83,26 +83,12 @@ export default {
}
return false;
},
resetDependentState() {
// Set
store.commit(storeMutations.UPDATE_STYLE, null);
store.commit(storeMutations.UPDATE_CAR_ID, null);
store.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
store.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null);
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
// Invokes
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
store.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
},
},
watch: {
selectedModel(model) {
this.$store.commit(this.storeMutations.UPDATE_MODEL, model);
this.$router.navigateAfterSave(
this.$store.dispatch(storeActions.SAVE_VEHICLE_MODEL, model);
this.$router.navigate(
this.navigationScenarios.SELECTED_MODEL,
this.$route
);

View file

@ -180,7 +180,7 @@ export default {
store.commit(storeMutations.UPDATE_PARTS, matchedParts);
// Navigate to the next page.
this.$router.navigateAfterSave(
this.$router.navigate(
this.navigationScenarios.SELECTED_PARTS,
this.$route
);

View file

@ -94,22 +94,13 @@ export default {
}
return false;
},
resetDependentState() {
// Invokes
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
store.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
store.commit(storeMutations.UPDATE_IS_REPAIR, null);
store.commit(storeMutations.UPDATE_NUMBER_OF_CHIPS, null);
store.commit(storeMutations.UPDATE_GLASS_TO_REPLACE, []);
store.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
},
},
watch: {
selectedStyle(style) {
this.$store.commit(this.storeMutations.UPDATE_STYLE, style);
this.$store.dispatch(storeActions.SAVE_VEHICLE_STYLE, style);
this.setVehicle().then(() => {
this.$router.navigateAfterSave(
this.$router.navigate(
this.navigationScenarios.SELECTED_STYLE,
this.$route
);

View file

@ -89,8 +89,8 @@ export default {
watch: {
selectedYear(year) {
const parsedYear = parseInt(year);
this.$store.commit(this.storeMutations.UPDATE_YEAR, parsedYear);
this.$router.navigateAfterSave(
this.$store.dispatch(storeActions.SAVE_VEHICLE_YEAR, parsedYear);
this.$router.navigate(
this.navigationScenarios.SELECTED_YEAR,
this.$route
);
@ -100,25 +100,6 @@ export default {
arePagePrerequisitesValid() {
return true;
},
resetDependentState: function(){
store.dispatch(storeActions.RESET_SAVE_VEHICLE_YEAR);
}
/* resetDependentState() {
// Set
store.commit(storeMutations.UPDATE_MAKE, null);
store.commit(storeMutations.UPDATE_MODEL, null);
store.commit(storeMutations.UPDATE_STYLE, null);
store.commit(storeMutations.UPDATE_CAR_ID, null);
store.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
store.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null);
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
// Invokes
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
store.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
}, */
},
components: {
yearQuestion,

View file

@ -319,7 +319,7 @@ export default {
},
navigateForward(){
if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){
this.$router.navigateAfterSave(this.navigationScenarios.CLICKED_FORWARD, this.$route, {}, { displayVehicleChangeAlert: true }, {});
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route, {}, { displayVehicleChangeAlert: true }, {});
return;
} else {
this.$refs.loadingModal.showModal();

View file

@ -139,12 +139,9 @@ router.afterEach(async (to, from) => {
});
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => {
navigate(scenario, currentRoute, false, optionalQuery, optionalParams, optionalPageData);
navigate(scenario, currentRoute, optionalQuery, optionalParams, optionalPageData);
}
router.navigateAfterSave = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => {
navigate(scenario, currentRoute, true, optionalQuery, optionalParams, optionalPageData);
}
router.navigateToExternalUrl = (url, optionalQuery = {}) => {
navigateToUrl(url, optionalQuery);
@ -153,7 +150,7 @@ router.navigateToExternalUrl = (url, optionalQuery = {}) => {
// PRIVATE FUNCTIONS
// Navigate to the next route, depending on the scenario.
async function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) {
async function navigate(scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) {
if (!scenario) {
console.error("No scenario provided. Please review the routing table.");
return;
@ -169,10 +166,6 @@ async function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery
// If we need to do invalidation
const currentComponent = currentRoute.matched[0].components;
if (invalidateOnSave) {
resetDependentState(currentComponent);
}
// Append page data to the store for the NEXT page, if any. It will be an empty object if none is provided.
baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData);
@ -270,9 +263,4 @@ function arePagePrerequisitesValid(component) {
return component.default.methods.arePagePrerequisitesValid();
}
// Reset dependant state on route change.
function resetDependentState(component) {
return component.default.methods.resetDependentState();
}
export default router;

View file

@ -4,6 +4,7 @@ import { storeMutations } from "@/constants/store-mutations";
import { getDateForSavedSessionTimeout } from "@/helpers/heritage-integration/session-helper";
import createPersistedState from "vuex-persistedstate";
import globalMethods from "@/global-methods";
import { storeActions } from "../constants/store-actions";
// Export State
const getDefaultState = () => {
@ -620,39 +621,128 @@ export const actions = {
});
},
saveVehicleYear(){
//NEED TO COMPARE OLDVALUE TO NEW VALUE
console.log(state.order.vehicle.year);
if(state.order.vehicle.year!=null){
storeMutations.updateMake = null;
storeMutations.updateModel = null;
storeMutations.updateStyle = null;
storeMutations.updateCarId = null;
storeMutations.updateVehicleCategory = null;
storeMutations.updateVehicleVin = null;
storeMutations.updateVehicleImageUrl = null;
storeMutations.updateVehicleImageVifNumber = null;
storeMutations.updateVehicleImageColor = null;
storeMutations.resetDamageAndDependencies;
storeMutations.resetRegistrationAndDependencies;
console.log("save vehicle year!");
}
saveVehicleYear(context, year){
//If different year, reset state dependencies
if(state.order.vehicle.year!==year){
context.commit(storeMutations.UPDATE_YEAR, null);
context.commit(storeMutations.UPDATE_MAKE, null);
context.commit(storeMutations.UPDATE_MODEL, null);
context.commit(storeMutations.UPDATE_STYLE, null);
context.commit(storeMutations.UPDATE_CAR_ID, null);
context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
context.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
}
//Update vehicle year
state.order.vehicle.year = year;
},
saveVehicleMake(){
if(state.order.vehicle.year!=null && state.order.vehicle.make!=null){
storeMutations.updateModel = null;
storeMutations.updateStyle = null;
storeMutations.updateCarId = null;
storeMutations.updateVehicleCategory = null;
storeMutations.updateVehicleVin = null;
storeMutations.updateVehicleImageUrl = null;
storeMutations.updateVehicleImageVifNumber = null;
storeMutations.updateVehicleImageColor = null;
storeMutations.resetDamageAndDependencies;
storeMutations.resetRegistrationAndDependencies;
console.log("save vehicle make!");
saveVehicleMake(context, make){
//If new make, reset state dependencies
if(state.order.vehicle.make !== make){
context.commit(storeMutations.UPDATE_MODEL, null);
context.commit(storeMutations.UPDATE_STYLE, null);
context.commit(storeMutations.UPDATE_CAR_ID, null);
context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
context.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
// Invokes
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
}
//Update vehicle make
state.order.vehicle.make = make;
},
saveVehicleModel(context, model){
//If new model, reset state dependencies
if (state.order.vehicle.make !== model) {
context.commit(storeMutations.UPDATE_STYLE, null);
context.commit(storeMutations.UPDATE_CAR_ID, null);
context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
context.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
}
//Update vehicle model
state.order.vehicle.model = model;
},
saveVehicleStyle(context, style){
//If new style, reset state dependencies
if(state.order.vehicle.style !== style){
context.commit(storeMutations.UPDATE_CAR_ID, null);
context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
context.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
}
//Update vehicle style
state.order.vehicle.style = style;
},
saveVehicleDamage(context){
context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
},
saveVinLookup(context){
//if cardId is different AND selected glass part is not available reset damage and dependeices
if(context.isCarIdDifferent && !context.isSelectedGlassAvailableForVehicle){
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
}
context.dispatch(storeMutations.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
},
saveServiceLocation(context){
// to be implemented
},
saveEmail(context){
// to be implemented
},
saveRegistrationLicensePlateLookup(context){
//if cardId is different AND selected glass part is not available reset damage and dependeices
if(context.isCarIdDifferent && !context.isSelectedGlassAvailableForVehicle){
context.dispatch(storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
}
context.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
context.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
context.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
context.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
},
saveVin(context){
//if cardId is different AND selected glass part is not available reset damage and dependeices
if(context.isCarIdDifferent && !context.isSelectedGlassAvailableForVehicle){
context.dispatch(storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
}
},
saveRegistrationAddressLookup(context){
if(context.isCarIdDifferent && !context.isSelectedGlassAvailableForVehicle){
storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES;
}
context.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
context.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
context.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
context.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
},
savePartQuestionAnswers(context){
// to be implemented later
},
saveGlassParts(context){
// to be implemented later
}
}
export default createStore({
@ -668,87 +758,5 @@ export default createStore({
actions,
});
/* export const mutationActions ={
saveVehicleMake(){
storeMutations.updateModel = null;
storeMutations.updateStyle = null;
storeMutations.updateCarId = null;
storeMutations.updateVehicleCategory = null;
storeMutations.updateVehicleVin = null;
storeMutations.updateVehicleImageUrl = null;
storeMutations.updateVehicleImageVifNumber = null;
storeMutations.updateVehicleImageColor = null;
storeMutations.resetDamageAndDependencies;
storeMutations.resetRegistrationAndDependencies;
},
saveVehicleModel(){
storeMutations.updateStyle = null;
storeMutations.updateCarId = null;
storeMutations.updateVehicleCategory = null;
storeMutations.updateVehicleVin = null;
storeMutations.updateVehicleImageUrl = null;
storeMutations.updateVehicleImageVifNumber = null;
storeMutations.updateVehicleImageColor = null;
storeMutations.resetDamageAndDependencies;
storeMutations.resetRegistrationAndDependencies;
},
saveVehicleStyle(){
storeMutations.updateCarId = null;
storeMutations.updateVehicleCategory = null;
storeMutations.updateVehicleVin = null;
storeMutations.updateVehicleImageUrl = null;
storeMutations.updateVehicleImageVifNumber = null;
storeMutations.updateVehicleImageColor = null;
storeMutations.resetDamageAndDependencies;
storeMutations.resetRegistrationAndDependencies;
},
saveVehicleDamage(){
storeMutations.resetPartsAndDependencies;
},
saveVinLookup(carId){
if(state.carId!=carId && state.payload.glass==false){
storeMutations.resetDamageAndDependencies;
}
storeMutations.resetRegistrationAndDependencies;
},
saveServiceLocation(){
},
saveEmail(){
},
saveRegistrationLicensePlateLookup(carId){
if(state.carId!=carId && state.payload.glass==false){
storeMutations.resetDamageAndDependencies;
}
storeMutations.registrationAddress = null;
storeMutations.registrationCity = null;
storeMutations.registration.firstName = null;
storeMutations.registration.lastName = null;
},
saveVin(carId){
if(state.carId!=carId && state.payload.glass==false){
storeMutations.resetDamageAndDependencies;
}
},
saveRegistrationAddressLookup(carId){
if(state.carId!=carId && state.payload.glass==false){
storeMutations.resetDamageAndDependencies;
}
storeMutations.registrationAddress = null;
storeMutations.registrationCity = null;
storeMutations.registration.firstName = null;
storeMutations.registration.lastName = null;
},
savePartQuestionAnswers(){
},
saveGlassParts(){
}
} */
// Private Functions
//Track state values
const oldValue = state;