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_REGISTRATION_STATE_AND_DEPENDENCIES: "resetRegistrationAndDependencies",
RESET_PARTS_STATE_AND_DEPENDENCIES: "resetPartsAndDependencies",
RESET_STATE: "resetState",
};
export { storeActions };

View file

@ -29,6 +29,7 @@ const storeMutations = {
RESET_DAMAGE_STATE: "resetDamageState",
RESET_REGISTRATION_STATE: "resetRegistrationState",
RESET_PARTS_STATE: "resetPartsState",
RESET_STATE: "resetState",
// OTHER MUTATIONS
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 { widgetNames } from "@/constants/widget-names.js";
import { vehicleCategories } from "@/constants/vehicle-categories.js";
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
export default {
data() {
@ -28,14 +27,21 @@ export default {
store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, savedOrderInfo.referralNumber);
store.commit(storeMutations.UPDATE_REFERRAL_DATE, savedOrderInfo.referralDate);
store.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, savedOrderInfo.referralCorrelationId);
// console.log(router)
// console.log(router.currentRoute.value.name)
// if (router.currentRoute.value.name)
// this.navigateToHeritageFunnel()
},
getCookieValue(cookieName) {
return document.cookie
?.split("; ")
?.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() {
console.log("Get estimate!")
var referralCorrelationId = store.getters.referralCorrelationId;
router.navigate(
@ -43,7 +49,10 @@ export default {
router.currentRoute.value,
{
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: "/",
name: "root",
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 (to.query.fmgPage === undefined) {
await GoToFunnelStartOn404(next);
@ -57,7 +75,6 @@ const routes = [
try {
// If we already have our route, go to it.
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.
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);
// TODO CSR-98 don't hardcode this
if (currentRoute.name == "vehicle-damage")
baseMixin.methods.navigateToHeritageFunnel()
if (currentRoute.name == "vehicle-damage") {
baseMixin.methods.navigateToHeritageFunnel();
}
else {
router.push({
name: "root",

View file

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

View file

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