Merge remote-tracking branch 'origin/feature/CSR-98' into feature/CSR-99
This commit is contained in:
commit
2faf1f51e2
4 changed files with 47 additions and 20 deletions
|
|
@ -8,18 +8,19 @@ import baseMixin from "../mixins/base-mixin";
|
|||
|
||||
// Read info from heritage funnel and reset state or load referral
|
||||
export function handleInfoFromHeritageFunnel() {
|
||||
var orderInfoJson = getHeritageCookieValue();
|
||||
var orderInfo = orderInfoJson == null ? null : JSON.parse(orderInfoJson);
|
||||
var orderInfo = getHeritageCookieValue();
|
||||
|
||||
if (orderInfo?.ShouldResetState) {
|
||||
store.dispatch(storeActions.RESET_STATE);
|
||||
deleteHeritageCookie();
|
||||
}
|
||||
else if (orderInfo != null) {
|
||||
// should load referral here
|
||||
}
|
||||
else if (orderInfo?.DidHeritageFunnelUpdateLast) {
|
||||
// Load referral here
|
||||
|
||||
// Delete cookie once state is loaded or reset
|
||||
deleteHeritageCookie();
|
||||
// setHeritageCookieProperties({
|
||||
// ShouldResetState: false
|
||||
// })
|
||||
}
|
||||
}
|
||||
|
||||
export function navigateToHeritageFunnel() {
|
||||
|
|
@ -33,7 +34,7 @@ export function navigateToHeritageFunnel() {
|
|||
src: "concept-funnel",
|
||||
// TODO CSR-98 REMOVE THIS
|
||||
cns: "all",
|
||||
experiments: "ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true"
|
||||
experiments: "RemoveServiceAreaPage=ServAreaRemoval_V7=ServAreaNoRemove_V7_TEST=true,ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true"
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -43,15 +44,45 @@ export async function saveOrder() {
|
|||
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);
|
||||
|
||||
setHeritageCookieProperties({
|
||||
DidHeritageFunnelUpdateLast: false
|
||||
})
|
||||
}
|
||||
|
||||
export function getHeritageCookieValue() {
|
||||
return document.cookie
|
||||
/* Start cookie related functions */
|
||||
function getHeritageCookieValue() {
|
||||
var cookieJson = document.cookie
|
||||
?.split("; ")
|
||||
?.find(row => row.startsWith(`${cookieNames.ORDER_INFO}=`))
|
||||
?.split("=")[1];
|
||||
|
||||
return cookieJson == null ? null : JSON.parse(cookieJson);
|
||||
}
|
||||
|
||||
export function deleteHeritageCookie() {
|
||||
function deleteHeritageCookie() {
|
||||
document.cookie = `${cookieNames.ORDER_INFO}=; Max-Age=0; path=/; domain=${location.hostname}`;
|
||||
}
|
||||
}
|
||||
|
||||
function setHeritageCookieValue(cookieValue) {
|
||||
let cookieValueJson = cookieValue;
|
||||
if (typeof cookieValue == "object")
|
||||
cookieValueJson = JSON.stringify(cookieValue);
|
||||
|
||||
document.cookie = `${cookieNames.ORDER_INFO}=${cookieValueJson}; path=/`;
|
||||
}
|
||||
|
||||
function setHeritageCookieProperties(properties) {
|
||||
if (typeof properties == "object") {
|
||||
let cookie = getHeritageCookieValue();
|
||||
|
||||
if (cookie != null) {
|
||||
Object.keys(properties).forEach(key => {
|
||||
cookie[key] = properties[key];
|
||||
});
|
||||
|
||||
setHeritageCookieValue(cookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* End cookie related functions */
|
||||
|
|
@ -49,7 +49,6 @@ export function getMountOptions(mockData) {
|
|||
mocks.$router = mockData.router;
|
||||
mocks.$route = mockData.route;
|
||||
|
||||
|
||||
const global = {
|
||||
mocks: mocks,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -101,9 +101,6 @@ function getMixInInstance({ isDispatchSuccess = true }) {
|
|||
baseMixIn.methods.$route = route;
|
||||
baseMixIn.methods.storeActions = storeActions;
|
||||
baseMixIn.methods.widgetNames = widgetNames;
|
||||
baseMixin.document = {
|
||||
cookie: ""
|
||||
}
|
||||
|
||||
store.dispatch = storeDispatch;
|
||||
store.commit = jest.fn();
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ const routes = [
|
|||
path: "/",
|
||||
name: "root",
|
||||
async beforeEnter(to, from, next) {
|
||||
// TODO CSR-98 Also triggers on refresh... should it though?
|
||||
// Entering the concept funnel
|
||||
// On entering the concept funnel
|
||||
if (from.redirectedFrom === undefined) {
|
||||
// Read cookie information, decide what to do next
|
||||
handleInfoFromHeritageFunnel();
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ router.navigateAfterSave = (scenario, currentRoute, optionalQuery = {}, optional
|
|||
// PRIVATE FUNCTIONS
|
||||
|
||||
// Navigate to the next route, depending on the scenario.
|
||||
function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) {
|
||||
async function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) {
|
||||
if (!scenario) {
|
||||
console.error("No scenario provided. Please review the routing table.");
|
||||
return;
|
||||
|
|
@ -170,7 +170,7 @@ function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {},
|
|||
});
|
||||
} else if (matchingScenarioMap.destinationUrl !== undefined) {
|
||||
if (matchingScenarioMap.shouldNavigateToHeritageFunnel) {
|
||||
saveOrder();
|
||||
await saveOrder();
|
||||
}
|
||||
|
||||
navigateToUrl(matchingScenarioMap.destinationUrl, optionalQuery);
|
||||
|
|
|
|||
Loading…
Reference in a new issue