CSR-98 Add variable for cookieName OrderInfo
This commit is contained in:
parent
585938d1ec
commit
399624af8d
7 changed files with 56 additions and 35 deletions
6
src/constants/cookie-names.js
Normal file
6
src/constants/cookie-names.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
const cookieNames = {
|
||||
ORDER_INFO: "OrderInfo"
|
||||
};
|
||||
|
||||
export { cookieNames };
|
||||
|
||||
|
|
@ -294,6 +294,12 @@ export default {
|
|||
},
|
||||
|
||||
navigateForward(partsData){
|
||||
// CSR-98 TEMP
|
||||
if (store.getters.vehicle.year == 2010) {
|
||||
this.navigateToHeritageFunnel();
|
||||
return;
|
||||
}
|
||||
|
||||
//found problem questions
|
||||
if (partsData.data.partsOrQuestions.some(pq => pq.partQuestions != null && pq.partQuestions.length > 0)){
|
||||
this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_DAMAGE_WITH_PART_QUESTIONS, this.$route, {}, {}, partsData.data);
|
||||
|
|
|
|||
|
|
@ -38,14 +38,13 @@ export default {
|
|||
document.cookie = `${cookieName}=${cookieValue}`;
|
||||
},
|
||||
deleteCookie(cookieName) {
|
||||
console.log("D")
|
||||
document.cookie = `${cookieName}=; Max-Age=0; path=/; domain=${location.hostname}`;
|
||||
},
|
||||
navigateToHeritageFunnel() {
|
||||
var referralCorrelationId = store.getters.referralCorrelationId;
|
||||
|
||||
router.navigate(
|
||||
navigationScenarios.CLICKED_FORWARD,
|
||||
navigationScenarios.MOVE_TO_HERITAGE_FUNNEL,
|
||||
router.currentRoute.value,
|
||||
{
|
||||
corid: referralCorrelationId,
|
||||
|
|
|
|||
|
|
@ -79,6 +79,8 @@ describe("baseMixin.js", () => {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
function getMixInInstance({ isDispatchSuccess = true }) {
|
||||
// Mock Store
|
||||
const storeDispatch = jest.fn();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { routingTable } from "@/router/router-constants/routing-table.js";
|
|||
import { globalEvents, globalEventTypes } from "@/constants/events";
|
||||
import eventBus from "@/helpers/event-bus/event-bus";
|
||||
import store from "@/store";
|
||||
import { cookieNames } from "@/constants/cookie-names";
|
||||
|
||||
// Components
|
||||
import ComponentTest from "@/layouts/component-test/component-test.vue";
|
||||
|
|
@ -53,19 +54,7 @@ const routes = [
|
|||
// TODO CSR-98 Also triggers on refresh... should it though?
|
||||
// Entering the concept funnel
|
||||
if (from.redirectedFrom === undefined) {
|
||||
// TODO CSR-98 Don't hardcode cookie name "OrderInfo"
|
||||
var orderInfoJson = baseMixin.methods.getCookieValue("OrderInfo");
|
||||
var orderInfo = orderInfoJson == null ? null : JSON.parse(orderInfoJson);
|
||||
|
||||
if (orderInfo?.ShouldResetState) {
|
||||
store.dispatch(storeActions.RESET_STATE);
|
||||
}
|
||||
else {
|
||||
// should load referral here
|
||||
}
|
||||
|
||||
// Delete cookie once state is loaded or reset
|
||||
baseMixin.methods.deleteCookie("OrderInfo");
|
||||
handleInfoFromHeritageFunnel();
|
||||
}
|
||||
|
||||
// If we have no query string, or we don't have the FmgPage query string.
|
||||
|
|
@ -149,13 +138,14 @@ function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {},
|
|||
return;
|
||||
}
|
||||
|
||||
// here?? CSR-98
|
||||
baseMixin.methods.saveOrder();
|
||||
// // here?? CSR-98
|
||||
// baseMixin.methods.saveOrder();
|
||||
|
||||
// Match our maps up and navigate if we have a destination.
|
||||
const matchingScenarioMap = getNavigationMap(scenario, currentRoute);
|
||||
const destinationFmgPageValue = matchingScenarioMap.destinationFmgPageValue;
|
||||
|
||||
if (matchingScenarioMap.destinationFmgPageValue !== undefined) {
|
||||
if (destinationFmgPageValue !== undefined) {
|
||||
// We're always pushing the same path, just changing query strings. Make sure our optional query strings get combined with our fmgPage one.
|
||||
|
||||
// If we need to do invalidation
|
||||
|
|
@ -166,22 +156,22 @@ function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {},
|
|||
}
|
||||
|
||||
// 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(matchingScenarioMap.destinationFmgPageValue, optionalPageData);
|
||||
baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData);
|
||||
|
||||
// TODO CSR-98 don't hardcode this
|
||||
if (currentRoute.name == "vehicle-damage") {
|
||||
baseMixin.methods.navigateToHeritageFunnel();
|
||||
}
|
||||
else {
|
||||
router.push({
|
||||
name: "root",
|
||||
query: Object.assign(optionalQuery, {
|
||||
fmgPage: matchingScenarioMap.destinationFmgPageValue,
|
||||
}),
|
||||
params: optionalParams,
|
||||
});
|
||||
}
|
||||
baseMixin.methods.saveOrder();
|
||||
|
||||
router.push({
|
||||
name: "root",
|
||||
query: Object.assign(optionalQuery, {
|
||||
fmgPage: destinationFmgPageValue,
|
||||
}),
|
||||
params: optionalParams,
|
||||
});
|
||||
} else if (matchingScenarioMap.destinationUrl !== undefined) {
|
||||
if (matchingScenarioMap.shouldNavigateToHeritageFunnel) {
|
||||
baseMixin.methods.saveOrder();
|
||||
}
|
||||
|
||||
navigateToUrl(matchingScenarioMap.destinationUrl, optionalQuery);
|
||||
}
|
||||
}
|
||||
|
|
@ -210,6 +200,7 @@ function navigateToUrl(url, optionalQuery) {
|
|||
for (const queryKey in optionalQuery) {
|
||||
externalUrl.searchParams.append(queryKey, optionalQuery[queryKey]);
|
||||
}
|
||||
|
||||
window.location.assign(externalUrl);
|
||||
}
|
||||
|
||||
|
|
@ -267,4 +258,20 @@ function resetDependentState(component) {
|
|||
return component.default.methods.resetDependentState();
|
||||
}
|
||||
|
||||
// Read info from heritage funnel and reset state or load referral
|
||||
function handleInfoFromHeritageFunnel() {
|
||||
var orderInfoJson = baseMixin.methods.getCookieValue(cookieNames.ORDER_INFO);
|
||||
var orderInfo = orderInfoJson == null ? null : JSON.parse(orderInfoJson);
|
||||
|
||||
if (orderInfo?.ShouldResetState) {
|
||||
store.dispatch(storeActions.RESET_STATE);
|
||||
}
|
||||
else if (orderInfo != null) {
|
||||
// should load referral here
|
||||
}
|
||||
|
||||
// Delete cookie once state is loaded or reset
|
||||
baseMixin.methods.deleteCookie(cookieNames.ORDER_INFO);
|
||||
}
|
||||
|
||||
export default router;
|
||||
|
|
@ -8,7 +8,8 @@ const navigationScenarios = {
|
|||
SELECTED_PARTS: "SELECTED_PARTS",
|
||||
SELECTED_DAMAGE_WITH_SINGLE_PART: "SELECTED_DAMAGE_WITH_SINGLE_PART",
|
||||
SELECTED_DAMAGE_WITH_MULTIPLE_PARTS: "SELECTED_DAMAGE_WITH_MULTIPLE_PARTS",
|
||||
SELECTED_DAMAGE_WITH_PART_QUESTIONS: "SELECTED_DAMAGE_WITH_PART_QUESTIONS"
|
||||
SELECTED_DAMAGE_WITH_PART_QUESTIONS: "SELECTED_DAMAGE_WITH_PART_QUESTIONS",
|
||||
MOVE_TO_HERITAGE_FUNNEL: "MOVE_TO_HERITAGE_FUNNEL",
|
||||
};
|
||||
|
||||
export { navigationScenarios };
|
||||
|
|
|
|||
|
|
@ -59,8 +59,9 @@ const routingTable = [
|
|||
destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE,
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.CLICKED_FORWARD,
|
||||
scenario: navigationScenarios.MOVE_TO_HERITAGE_FUNNEL,
|
||||
destinationUrl: externalUrls.HERITAGE_FUNNEL,
|
||||
shouldNavigateToHeritageFunnel: true
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.SELECTED_DAMAGE_WITH_SINGLE_PART,
|
||||
|
|
@ -89,7 +90,6 @@ const routingTable = [
|
|||
},
|
||||
{
|
||||
scenario: navigationScenarios.CLICKED_FORWARD,
|
||||
// destinationUrl: externalUrls.HERITAGE_FUNNEL,
|
||||
destinationFmgPageValue: fmgPageValues.REVEAL,
|
||||
},
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in a new issue