CSR-658 nav directly to vehicle-damage when 1 style

This commit is contained in:
CarlNation 2022-08-08 15:54:21 -04:00
parent 7d391266e7
commit e4b2b702c6
3 changed files with 21 additions and 6 deletions

View file

@ -27,6 +27,15 @@ jest.mock("@/store", () => ({
vehicle: { vehicle: {
model: "TL", model: "TL",
}, },
applicationUser:{
pageData: {
"part-questions": null,
"vehicle-make": {},
"vehicle-model": {},
"vehicle-style": {},
"vehicle-damage": {}
}
}
}, },
})); }));

View file

@ -38,6 +38,8 @@ import { storeActions } from "@/constants/store-actions";
import store from "@/store"; import store from "@/store";
import { storeMutations } from "@/constants/store-mutations"; import { storeMutations } from "@/constants/store-mutations";
import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
import router from "@/router";
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
export default { export default {
name: "vehicle-style", name: "vehicle-style",
@ -70,11 +72,10 @@ export default {
const resultMap = await settleAllPromises(promiseResultMap); const resultMap = await settleAllPromises(promiseResultMap);
const visitedVehicleDamage = JSON.stringify(store.getters.applicationUser.pageData).indexOf(fmgPageValues.VEHICLE_DAMAGE) < 0 ? false : true; const visitedVehicleDamage = JSON.stringify(store.getters.applicationUser.pageData).indexOf(fmgPageValues.VEHICLE_DAMAGE) < 0 ? false : true;
// Call the "next" function to complete the transition to this page. // Call the "next" function to complete the transition to this page.
// If we have exactly one style // If we have exactly one style then navigate directly to vehicle-damage
if(resultMap.styleQuestionInitialData.length === 1 || !visitedVehicleDamage) { if(resultMap.styleQuestionInitialData.length === 1 && !visitedVehicleDamage) {
store.commit(storeMutations.UPDATE_STYLE, resultMap.styleQuestionInitialData[0]); store.commit(storeMutations.UPDATE_STYLE, resultMap.styleQuestionInitialData[0]);
await store.dispatch(storeActions.SET_VEHICLE, await store.dispatch(storeActions.SET_VEHICLE,
@ -85,9 +86,8 @@ export default {
style: store.getters.vehicle.style, style: store.getters.vehicle.style,
}); });
// ...GetNavigationMap(navigationScenarios.SELECTED_STYLE, to); //emulate selecting the vehicle style
//... router.overrideNavigation(navigationScenarios.SELECTED_STYLE, to, next);
next({name: 'root', query: Object.assign(to.query, { fmgPage: '....destinationFmgPageValue' })});
} else{ } else{
next( (vm) => { next( (vm) => {

View file

@ -155,6 +155,12 @@ router.navigateToExternalUrl = (url, optionalQuery = {}) => {
navigateToUrl(url, optionalQuery); navigateToUrl(url, optionalQuery);
} }
//Use this navigation when you need to call next() explicitly. beforeRouteEnter is a good example.
router.overrideNavigation = (scenario, currentRoute, next, optionalQuery = {}, optionalParams = {}, optionalPageData) => {
router.navigate(scenario, currentRoute, optionalQuery, optionalParams, optionalPageData);
next();
}
// PRIVATE FUNCTIONS // PRIVATE FUNCTIONS
// Navigate to the next route, depending on the scenario. // Navigate to the next route, depending on the scenario.