Merge branch 'develop' into feature/CSR-110

This commit is contained in:
Adam Caouette 2022-07-26 09:13:20 -04:00
commit 7badd9f18e
8 changed files with 337 additions and 262 deletions

View file

@ -31,6 +31,7 @@ const storeActions = {
INITIALIZE_SESSION: "initializeSession", INITIALIZE_SESSION: "initializeSession",
GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser", GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser",
CLEAR_VIN: "clearVin", CLEAR_VIN: "clearVin",
RESET_SAVE_ORDER_PROMISE: "resetSaveOrderPromise",
// DEPENDENCY MUTATIONS // DEPENDENCY MUTATIONS
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies", RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies",

View file

@ -58,6 +58,7 @@ const storeMutations = {
UPDATE_STATE_WITH_ORDER_INFORMATION: "updateStateWithOrderInformation", UPDATE_STATE_WITH_ORDER_INFORMATION: "updateStateWithOrderInformation",
UPDATE_SAVE_ORDER_PROMISE: "updateSaveOrderPromise", UPDATE_SAVE_ORDER_PROMISE: "updateSaveOrderPromise",
UPDATE_LAST_PAGE_VISITED: "updateLastPageVisited", UPDATE_LAST_PAGE_VISITED: "updateLastPageVisited",
RESET_SAVE_ORDER_PROMISE: "resetSaveOrderPromise",
}; };
export { storeMutations }; export { storeMutations };

View file

@ -60,6 +60,8 @@ export async function saveOrder() {
and returns the response. and returns the response.
*/ */
async function loadOrder(referralNumber, referralDate, referralCorrelationId, accountNumber) { async function loadOrder(referralNumber, referralDate, referralCorrelationId, accountNumber) {
// await the saveOrderPromise in the store to make sure we're loading up to date information
await store.getters.applicationUser.saveOrderPromise;
const response = await baseMixin.methods.dispatchStoreAction(storeActions.LOAD_ORDER, const response = await baseMixin.methods.dispatchStoreAction(storeActions.LOAD_ORDER,
{ {
referralNumber: referralNumber.toString(), referralNumber: referralNumber.toString(),

15
src/layouts/test-one.vue Normal file
View file

@ -0,0 +1,15 @@
<template>
Test1
</template>
<script>
export default {
name: "test1",
methods: {
arePagePrerequisitesValid() {
return true;
}
}
}
</script>

15
src/layouts/test-two.vue Normal file
View file

@ -0,0 +1,15 @@
<template>
Test2
</template>
<script>
export default {
name: "test2",
methods: {
arePagePrerequisitesValid() {
return true;
}
}
}
</script>

View file

@ -19,7 +19,24 @@ import eventBus from "@/helpers/event-bus/event-bus";
import store from "@/store"; import store from "@/store";
import analyticsMixin from "@/mixins/analytics-mixin"; import analyticsMixin from "@/mixins/analytics-mixin";
import TestOne from "@/layouts/test-one";
import TestTwo from "@/layouts/test-two";
const routes = [ const routes = [
{
path: "/test1",
name: "test1",
components: {
default: TestOne
}
},
{
path: "/test2",
name: "test2",
components: {
default: TestTwo
}
},
{ {
path: "/", path: "/",
name: "root", name: "root",
@ -43,6 +60,9 @@ const routes = [
// On entering the funnel "fresh", read cookie information, decide what to do next. // On entering the funnel "fresh", read cookie information, decide what to do next.
if (from.redirectedFrom === undefined) { if (from.redirectedFrom === undefined) {
// clear the saveOrderPromise - if it exists in the vuex store but a new instance was created
// the saveOrderPromise will no longer point to a valid promise
baseMixin.methods.dispatchStoreAction(storeActions.RESET_SAVE_ORDER_PROMISE);
const loadOrderResponse = await loadOrderIfPresent(); const loadOrderResponse = await loadOrderIfPresent();
const pageToRedirectTo = await getPageToRouteExistingOrderTo(to, loadOrderResponse); const pageToRedirectTo = await getPageToRouteExistingOrderTo(to, loadOrderResponse);
@ -53,7 +73,6 @@ const routes = [
return next(false); return next(false);
} }
// Assign our fmgPage so it will load normally like the other pages. // Assign our fmgPage so it will load normally like the other pages.
to.query.fmgPage = pageToRedirectTo; to.query.fmgPage = pageToRedirectTo;
} }
@ -180,15 +199,16 @@ async function navigate(scenario, currentRoute, optionalQuery = {}, optionalPara
// Get navigation map depending on the scenario and the current 'page' you're on. // Get navigation map depending on the scenario and the current 'page' you're on.
function getNavigationMap(scenario, currentRoute) { function getNavigationMap(scenario, currentRoute) {
const fmgPageValue = currentRoute.query.fmgPage; const fmgPageValue = currentRoute.query.fmgPage;
const matchedQueryValue = routingTable const matchedQueryValue = routingTable(store)
.filter( .filter(
(item) => (item) =>
item.fmgPageValue === fmgPageValue && item.fmgPageValue === fmgPageValue &&
item.maps.filter((map) => map.scenario === scenario).length > 0 item.maps.filter((map) => map.scenario === scenario).length > 0
) )
.map((m) => m.maps.filter((map) => map.scenario === scenario)); .map((m) => m.maps.filter((map) => map.scenario === scenario))[0]
.filter(x => x.filter === true || x.filter === undefined);
return matchedQueryValue[0][0]; return matchedQueryValue[0];
} }
//---------------------------------------------------------- Private Functions ---------------------------------------------------------- //---------------------------------------------------------- Private Functions ----------------------------------------------------------

View file

@ -1,10 +1,22 @@
import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
const routingTable = [ // Get store from router/index.js instead of importing it here to get updated values
const routingTable = function(store) {
return [
{ {
fmgPageValue: fmgPageValues.VEHICLE_YEAR, fmgPageValue: fmgPageValues.VEHICLE_YEAR,
maps: [ maps: [
{
scenario: navigationScenarios.SELECTED_YEAR,
destinationFmgPageValue: "test1",
filter: store.getters.vehicle.year === 2010
},
{
scenario: navigationScenarios.SELECTED_YEAR,
destinationFmgPageValue: "test2",
filter: store.getters.vehicle.year < 1954
},
{ {
scenario: navigationScenarios.SELECTED_YEAR, scenario: navigationScenarios.SELECTED_YEAR,
destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE, destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE,
@ -79,8 +91,8 @@ const routingTable = [
destinationFmgPageValue: fmgPageValues.QUOTE, destinationFmgPageValue: fmgPageValues.QUOTE,
}, },
{ {
scenario: navigationScenarios.HAS_MOLDING_QUESTIONS, scenario: navigationScenarios.CLICKED_FORWARD,
destinationFmgPageValue: fmgPageValues.MOLDING_QUESTIONS destinationFmgPageValue: fmgPageValues.REVEAL,
}, },
], ],
}, },
@ -257,5 +269,6 @@ const routingTable = [
] ]
}, },
]; ];
}
export { routingTable }; export { routingTable };

View file

@ -269,7 +269,9 @@ export const mutations = {
resetState(state) { resetState(state) {
Object.assign(state, getDefaultState()); Object.assign(state, getDefaultState());
}, },
resetSaveOrderPromise(state) {
state.applicationUser.saveOrderPromise = null;
},
// Misc Mutations // Misc Mutations
updateStateWithOrderInformation(state, orderInformation) { updateStateWithOrderInformation(state, orderInformation) {
state.order.referralNumber = orderInformation.referralNumber; state.order.referralNumber = orderInformation.referralNumber;
@ -457,6 +459,9 @@ export const actions = {
resetState(context) { resetState(context) {
context.commit(storeMutations.RESET_STATE); context.commit(storeMutations.RESET_STATE);
}, },
resetSaveOrderPromise(context) {
context.commit(storeMutations.RESET_SAVE_ORDER_PROMISE);
},
// Content API Actions // Content API Actions
getRouteInfo(context, { pageName }) { getRouteInfo(context, { pageName }) {
@ -701,7 +706,10 @@ export const actions = {
accountNumber: accountNumber?.toString() accountNumber: accountNumber?.toString()
}, },
}).then((response) => { }).then((response) => {
// clear the state if the existing referral number does not equal what is returned from loadOrder
if (context.state.order.referralNumber != response.data.referralNumber) {
context.commit(storeMutations.RESET_STATE); context.commit(storeMutations.RESET_STATE);
}
context.commit(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, response.data); context.commit(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, response.data);
return response; return response;
}); });