CSR-98 Fix reset state
This commit is contained in:
parent
b98ec44714
commit
927f7c8a00
9 changed files with 19 additions and 17 deletions
|
|
@ -3,7 +3,8 @@ const applicationConfig = {
|
||||||
CONSUMER_APIGATEWAY_URL: process.env.VUE_APP_CONSUMER_API_GATEWAY,
|
CONSUMER_APIGATEWAY_URL: process.env.VUE_APP_CONSUMER_API_GATEWAY,
|
||||||
GOOGLE_PLACES_API_KEY: process.env.VUE_APP_GOOGLE_PLACES_API_KEY,
|
GOOGLE_PLACES_API_KEY: process.env.VUE_APP_GOOGLE_PLACES_API_KEY,
|
||||||
ANALYTICS_SESSION_TIMEOUT_MINUTES: 30,
|
ANALYTICS_SESSION_TIMEOUT_MINUTES: 30,
|
||||||
SAVED_SESSION_TIMEOUT_DAYS: 45
|
SAVED_SESSION_TIMEOUT_DAYS: 45,
|
||||||
|
COOKIE_PATH: "/"
|
||||||
};
|
};
|
||||||
|
|
||||||
export { applicationConfig };
|
export { applicationConfig };
|
||||||
|
|
@ -15,7 +15,6 @@ const storeActions = {
|
||||||
SAVE_ORDER: "saveOrder",
|
SAVE_ORDER: "saveOrder",
|
||||||
LOAD_ORDER: "loadOrder",
|
LOAD_ORDER: "loadOrder",
|
||||||
SET_REFERRAL_INFORMATION: "setReferralInformation",
|
SET_REFERRAL_INFORMATION: "setReferralInformation",
|
||||||
SET_LOAD_ORDER_DATA: "setLoadOrderData",
|
|
||||||
|
|
||||||
// DEPENDENCY MUTATIONS
|
// DEPENDENCY MUTATIONS
|
||||||
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies",
|
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies",
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ const storeMutations = {
|
||||||
|
|
||||||
// OTHER MUTATIONS
|
// OTHER MUTATIONS
|
||||||
UPDATE_PAGE_DATA: "updatePageData",
|
UPDATE_PAGE_DATA: "updatePageData",
|
||||||
SET_LOAD_FUNNEL_SESSION_INFO: "setLoadOrderInformation"
|
SET_LOAD_FUNNEL_SESSION_INFO: "updateStateWithOrderInformation"
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
import { cookieNames } from "@/constants/cookie-names";
|
import { cookieNames } from "@/constants/cookie-names";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
|
import { applicationConfig } from "@/constants/application-config";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Will update the cookie if present, or create a new one if not.
|
Will update the cookie if present, or create a new one if not.
|
||||||
*/
|
*/
|
||||||
export function updateOrCreateFunnelCookie() {
|
export function updateOrCreateFunnelCookie() {
|
||||||
// Create the cookie
|
// Create the cookie
|
||||||
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}={}; path=/; ${getCookieDomainValue()};`;
|
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}={}; path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()};`;
|
||||||
|
|
||||||
// Set up cookie with all the props.
|
// Set up cookie with all the props.
|
||||||
setFunnelCookieProperties({
|
setFunnelCookieProperties({
|
||||||
|
|
@ -18,7 +19,6 @@ export function updateOrCreateFunnelCookie() {
|
||||||
ReferralDate: store.getters.order.referralDate,
|
ReferralDate: store.getters.order.referralDate,
|
||||||
ReferralCorrelationId: store.getters.order.referralCorrelationId,
|
ReferralCorrelationId: store.getters.order.referralCorrelationId,
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -42,8 +42,7 @@ export function getFunnelCookie() {
|
||||||
Removes cookie from browser.
|
Removes cookie from browser.
|
||||||
*/
|
*/
|
||||||
export function deleteFunnelCookie() {
|
export function deleteFunnelCookie() {
|
||||||
console.log("hi there")
|
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=; Max-Age=0; path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()}`;
|
||||||
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=; Max-Age=0; path=/; ${getCookieDomainValue()}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -61,7 +60,7 @@ function setFunnelCookieProperties(properties) {
|
||||||
|
|
||||||
const cookieValueJson = JSON.stringify(cookie);
|
const cookieValueJson = JSON.stringify(cookie);
|
||||||
|
|
||||||
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=${cookieValueJson}; path=/; ${getCookieDomainValue()}`;
|
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=${cookieValueJson}; path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,10 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita
|
||||||
return 'vehicle-damage'
|
return 'vehicle-damage'
|
||||||
} else {
|
} else {
|
||||||
if (store.getters.vehicle.vin) {
|
if (store.getters.vehicle.vin) {
|
||||||
return 'vehicle-damage';
|
return 'heritage';
|
||||||
//return "vin-lookup"; (uncomment)
|
//return "vin-lookup"; (uncomment)
|
||||||
} else {
|
} else {
|
||||||
return 'vehicle-damage';
|
return 'heritage';
|
||||||
//return "estimate" (uncomment)
|
//return "estimate" (uncomment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -58,7 +58,6 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export async function navigateToHeritageFunnel() {
|
export async function navigateToHeritageFunnel() {
|
||||||
|
|
||||||
// Create the order (or save existing order) when navigating to Heritage Funnel.
|
// Create the order (or save existing order) when navigating to Heritage Funnel.
|
||||||
await saveOrder();
|
await saveOrder();
|
||||||
|
|
||||||
|
|
@ -67,6 +66,9 @@ export async function navigateToHeritageFunnel() {
|
||||||
{
|
{
|
||||||
corid: store.getters.order.referralCorrelationId,
|
corid: store.getters.order.referralCorrelationId,
|
||||||
src: "concept-funnel",
|
src: "concept-funnel",
|
||||||
|
// TODO CSR-28, remove this
|
||||||
|
cns: "all",
|
||||||
|
experiments: "RemoveServiceAreaPage=ServAreaRemoval_V7=NoShowPackages_CONTROL=true,ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -21,7 +21,6 @@ export async function loadOrderIfPresent() {
|
||||||
if (funnelCookie.ShouldResetState) {
|
if (funnelCookie.ShouldResetState) {
|
||||||
baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.RESET_STATE);
|
baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.RESET_STATE);
|
||||||
deleteFunnelCookie();
|
deleteFunnelCookie();
|
||||||
console.log("sup")
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,7 @@ const routes = [
|
||||||
await GoToFunnelStartOn404(next);
|
await GoToFunnelStartOn404(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process funnel cookie.
|
|
||||||
updateOrCreateFunnelCookie();
|
|
||||||
|
|
||||||
// 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) {
|
||||||
|
|
@ -64,6 +63,9 @@ const routes = [
|
||||||
to.query.fmgPage = pageToRedirectTo;
|
to.query.fmgPage = pageToRedirectTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Process funnel cookie.
|
||||||
|
updateOrCreateFunnelCookie();
|
||||||
|
|
||||||
// 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.
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ export const mutations = {
|
||||||
},
|
},
|
||||||
|
|
||||||
// Misc Mutations
|
// Misc Mutations
|
||||||
setLoadOrderInformation(state, orderInformation) {
|
updateStateWithOrderInformation(state, orderInformation) {
|
||||||
state.order.referralNumber = orderInformation.referralNumber;
|
state.order.referralNumber = orderInformation.referralNumber;
|
||||||
state.order.referralDate = orderInformation.referralDate;
|
state.order.referralDate = orderInformation.referralDate;
|
||||||
state.order.referralCorrelationId = orderInformation.referralCorrelationId;
|
state.order.referralCorrelationId = orderInformation.referralCorrelationId;
|
||||||
|
|
|
||||||
|
|
@ -200,12 +200,12 @@ describe("Mutations", () => {
|
||||||
expect(storeState.applicationUser.pageData['vehicle-year']).toEqual({});
|
expect(storeState.applicationUser.pageData['vehicle-year']).toEqual({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("setLoadOrderInformation, should set order information in state", () => {
|
it("updateStateWithOrderInformation, should set order information in state", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const storeState = state;
|
const storeState = state;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
mutations.setLoadOrderInformation(storeState, {
|
mutations.updateStateWithOrderInformation(storeState, {
|
||||||
referralNumber: 123,
|
referralNumber: 123,
|
||||||
referralDate: new Date().toUTCString(),
|
referralDate: new Date().toUTCString(),
|
||||||
referralCorrelationId: "xxx-xxx-xxx",
|
referralCorrelationId: "xxx-xxx-xxx",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue