CSR-98 Read cookie values and remove as needed

This commit is contained in:
Katie 2022-03-11 12:22:35 -05:00
parent a679f2fd07
commit d1fb7db451
6 changed files with 80 additions and 44 deletions

View file

@ -19,6 +19,7 @@ const storeActions = {
RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies", RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies",
RESET_REGISTRATION_STATE_AND_DEPENDENCIES: "resetRegistrationAndDependencies", RESET_REGISTRATION_STATE_AND_DEPENDENCIES: "resetRegistrationAndDependencies",
RESET_PARTS_STATE_AND_DEPENDENCIES: "resetPartsAndDependencies", RESET_PARTS_STATE_AND_DEPENDENCIES: "resetPartsAndDependencies",
RESET_STATE: "resetState",
}; };
export { storeActions }; export { storeActions };

View file

@ -29,6 +29,7 @@ const storeMutations = {
RESET_DAMAGE_STATE: "resetDamageState", RESET_DAMAGE_STATE: "resetDamageState",
RESET_REGISTRATION_STATE: "resetRegistrationState", RESET_REGISTRATION_STATE: "resetRegistrationState",
RESET_PARTS_STATE: "resetPartsState", RESET_PARTS_STATE: "resetPartsState",
RESET_STATE: "resetState",
// OTHER MUTATIONS // OTHER MUTATIONS
UPDATE_PAGE_DATA: "updatePageData", UPDATE_PAGE_DATA: "updatePageData",

View file

@ -5,7 +5,6 @@ import { storeMutations } from "@/constants/store-mutations.js";
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
import { widgetNames } from "@/constants/widget-names.js"; import { widgetNames } from "@/constants/widget-names.js";
import { vehicleCategories } from "@/constants/vehicle-categories.js"; import { vehicleCategories } from "@/constants/vehicle-categories.js";
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
export default { export default {
data() { data() {
@ -28,14 +27,21 @@ export default {
store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, savedOrderInfo.referralNumber); store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, savedOrderInfo.referralNumber);
store.commit(storeMutations.UPDATE_REFERRAL_DATE, savedOrderInfo.referralDate); store.commit(storeMutations.UPDATE_REFERRAL_DATE, savedOrderInfo.referralDate);
store.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, savedOrderInfo.referralCorrelationId); store.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, savedOrderInfo.referralCorrelationId);
},
// console.log(router) getCookieValue(cookieName) {
// console.log(router.currentRoute.value.name) return document.cookie
// if (router.currentRoute.value.name) ?.split("; ")
// this.navigateToHeritageFunnel() ?.find(row => row.startsWith(`${cookieName}=`))
?.split("=")[1];
},
setCookieValue(cookieName, cookieValue) {
document.cookie = `${cookieName}=${cookieValue}`;
},
deleteCookie(cookieName) {
console.log("D")
document.cookie = `${cookieName}=; Max-Age=0; path=/; domain=${location.hostname}`;
}, },
navigateToHeritageFunnel() { navigateToHeritageFunnel() {
console.log("Get estimate!")
var referralCorrelationId = store.getters.referralCorrelationId; var referralCorrelationId = store.getters.referralCorrelationId;
router.navigate( router.navigate(
@ -43,7 +49,10 @@ export default {
router.currentRoute.value, router.currentRoute.value,
{ {
corid: referralCorrelationId, corid: referralCorrelationId,
src: "concept-funnel" src: "concept-funnel",
// TODO CSR-98 REMOVE THIS
cns: "all",
experiments: "ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true"
} }
); );
} }

View file

@ -50,6 +50,24 @@ const routes = [
path: "/", path: "/",
name: "root", name: "root",
async beforeEnter(to, from, next) { async beforeEnter(to, from, next) {
// 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");
}
// If we have no query string, or we don't have the FmgPage query string. // If we have no query string, or we don't have the FmgPage query string.
if (to.query.fmgPage === undefined) { if (to.query.fmgPage === undefined) {
await GoToFunnelStartOn404(next); await GoToFunnelStartOn404(next);
@ -57,7 +75,6 @@ const routes = [
try { try {
// If we already have our route, go to it. // If we already have our route, go to it.
if (router.hasRoute(to.query.fmgPage)) { if (router.hasRoute(to.query.fmgPage)) {
// Since our route is already in scope, we can grab the component from it and call the arePagePrerequisitesValid function. // Since our route is already in scope, we can grab the component from it and call the arePagePrerequisitesValid function.
let component = router.getRoutes().filter((x) => x.name === to.query.fmgPage)[0].components; let component = router.getRoutes().filter((x) => x.name === to.query.fmgPage)[0].components;
@ -152,8 +169,9 @@ function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {},
baseMixin.methods.savePageDataToStore(matchingScenarioMap.destinationFmgPageValue, optionalPageData); baseMixin.methods.savePageDataToStore(matchingScenarioMap.destinationFmgPageValue, optionalPageData);
// TODO CSR-98 don't hardcode this // TODO CSR-98 don't hardcode this
if (currentRoute.name == "vehicle-damage") if (currentRoute.name == "vehicle-damage") {
baseMixin.methods.navigateToHeritageFunnel() baseMixin.methods.navigateToHeritageFunnel();
}
else { else {
router.push({ router.push({
name: "root", name: "root",

View file

@ -85,15 +85,12 @@ const routingTable = [
}, },
{ {
scenario: navigationScenarios.SELECTED_PARTS, scenario: navigationScenarios.SELECTED_PARTS,
<<<<<<< HEAD
destinationFmgPageValue: fmgPageValues.QUOTE, destinationFmgPageValue: fmgPageValues.QUOTE,
}, },
{ {
scenario: navigationScenarios.CLICKED_FORWARD, scenario: navigationScenarios.CLICKED_FORWARD,
destinationUrl: externalUrls.HERITAGE_FUNNEL, // destinationUrl: externalUrls.HERITAGE_FUNNEL,
=======
destinationFmgPageValue: fmgPageValues.REVEAL, destinationFmgPageValue: fmgPageValues.REVEAL,
>>>>>>> develop
}, },
], ],
}, },

View file

@ -7,37 +7,41 @@ import globalMethods from "@/global-methods";
// Export State // Export State
export const state = { const getDefaultState = () => {
order: { return {
vehicle: { order: {
year: null, vehicle: {
make: null, year: null,
model: null, make: null,
style: null, model: null,
carId: null, style: null,
category: null, carId: null,
imageUrl: null, category: null,
imageVifNumber: null, imageUrl: null,
imageColor: null, imageVifNumber: null,
imageColor: null,
},
damage: {
isRepair: null,
numberOfChips: null,
glassToReplace: null,
},
lineItems:{
glassParts: null,
otherParts: null
},
referralNumber: null,
referralDate: null,
referralCorrelationId: null,
}, },
damage: { applicationUser: {
isRepair: null, eventBus: [],
numberOfChips: null, pageData: {}
glassToReplace: null,
}, },
lineItems:{ }
glassParts: null, };
otherParts: null
}, export const state = getDefaultState();
referralNumber: null,
referralDate: null,
referralCorrelationId: null,
},
applicationUser: {
eventBus: [],
pageData: {}
},
}
// Export Mutations // Export Mutations
export const mutations = { export const mutations = {
@ -136,6 +140,9 @@ export const mutations = {
resetPartsState(state) { resetPartsState(state) {
state.order.lineItems.glassParts = null; state.order.lineItems.glassParts = null;
state.order.lineItems.otherParts = null; state.order.lineItems.otherParts = null;
},
resetState(state) {
Object.assign(state, getDefaultState());
} }
} }
@ -249,6 +256,9 @@ export const actions = {
resetPartsAndDependencies(context) { resetPartsAndDependencies(context) {
context.commit(storeMutations.RESET_PARTS_STATE); context.commit(storeMutations.RESET_PARTS_STATE);
}, },
resetState(context) {
context.commit(storeMutations.RESET_STATE);
},
// Content API Actions // Content API Actions
getRouteInfo(context, { pageName }) { getRouteInfo(context, { pageName }) {