Removed some unneeded references.
This commit is contained in:
parent
9e8fbcd791
commit
9465cb12d1
4 changed files with 1 additions and 152 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
import { externalUrls } from "@/router/router-constants/externalUrl-values";
|
import { externalUrls } from "@/router/router-constants/externalUrl-values";
|
||||||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
||||||
import { saveSession } from "@/helpers/heritage-integration/order-helper.js";
|
|
||||||
import { issPageValues } from "@/router/router-constants/issPage-values";
|
import { issPageValues } from "@/router/router-constants/issPage-values";
|
||||||
import { useMainStore } from "@/store";
|
import { useMainStore } from "@/store";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
|
|
@ -35,25 +34,6 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita
|
||||||
return latestPageRoute;
|
return latestPageRoute;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Used to navigate to the heritage funnel with the correct query string and url.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export async function navigateToHeritageFunnel(shouldSaveSession = true) {
|
|
||||||
// Create the order (or save existing order) when navigating to Heritage Funnel.
|
|
||||||
if (shouldSaveSession) {
|
|
||||||
await saveSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
const store = useMainStore();
|
|
||||||
|
|
||||||
router.navigateToExternalUrl(externalUrls.HERITAGE_FUNNEL, {
|
|
||||||
corid: store.order.referralCorrelationId,
|
|
||||||
src: "concept-funnel",
|
|
||||||
conceptsqid: store.applicationUser.savedSessionId,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Logic for getting the last "valid" page a user visited.
|
Logic for getting the last "valid" page a user visited.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import {
|
import {
|
||||||
getPageToRouteExistingOrderTo,
|
getPageToRouteExistingOrderTo
|
||||||
navigateToHeritageFunnel,
|
|
||||||
} from "@/helpers/heritage-integration/navigation-helper";
|
} from "@/helpers/heritage-integration/navigation-helper";
|
||||||
import * as orderHelper from "@/helpers/heritage-integration/order-helper";
|
import * as orderHelper from "@/helpers/heritage-integration/order-helper";
|
||||||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
||||||
|
|
|
||||||
|
|
@ -1,117 +0,0 @@
|
||||||
import { storeActions } from "@/constants/store-actions.js";
|
|
||||||
import {
|
|
||||||
getFunnelCookie,
|
|
||||||
updateOrCreateFunnelCookie,
|
|
||||||
deleteFunnelCookie,
|
|
||||||
} from "@/helpers/heritage-integration/cookie-helper.js";
|
|
||||||
import baseMixin from "@/mixins/base-mixin";
|
|
||||||
import { useMainStore } from "@/store";
|
|
||||||
import { storeMutations } from "@/constants/store-mutations";
|
|
||||||
|
|
||||||
/*
|
|
||||||
Will call API and hydrate state with data from API if present. If there is no order present
|
|
||||||
method will return null. If the cookie dictates the state should be reset
|
|
||||||
it will reset the state and go back to the start of the funnel.
|
|
||||||
|
|
||||||
*/
|
|
||||||
export async function loadSessionIfPresent() {
|
|
||||||
const funnelCookie = getFunnelCookie();
|
|
||||||
|
|
||||||
// Do nothing if there is no cookie, correlation id, or referral number.
|
|
||||||
if (
|
|
||||||
funnelCookie == null ||
|
|
||||||
funnelCookie.ReferralCorrelationId == null ||
|
|
||||||
!funnelCookie.ReferralNumber
|
|
||||||
) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset state if cookie says to.
|
|
||||||
if (funnelCookie.ShouldResetState) {
|
|
||||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE);
|
|
||||||
deleteFunnelCookie();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load referral if there is a cookie, and it doesn't indicate it needs a state reset.
|
|
||||||
return (
|
|
||||||
await loadSession(
|
|
||||||
funnelCookie.ReferralNumber,
|
|
||||||
funnelCookie.ReferralDate,
|
|
||||||
funnelCookie.ReferralCorrelationId,
|
|
||||||
funnelCookie.ReferralParentAccountNumber
|
|
||||||
)
|
|
||||||
).data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Will call API to save existing order, or create new one depending where it's called from.
|
|
||||||
This will also set Referral information in the store after saving, and then
|
|
||||||
update the cookie.
|
|
||||||
*/
|
|
||||||
export async function saveSession() {
|
|
||||||
var saveSessionPromise;
|
|
||||||
const store = useMainStore();
|
|
||||||
|
|
||||||
if (store.applicationUser.saveSessionPromise) {
|
|
||||||
// queue newest request after current saveSessionPromise resolves
|
|
||||||
saveSessionPromise = store.applicationUser.saveSessionPromise.then(() => {
|
|
||||||
// get a new saveSessionPromise
|
|
||||||
return saveSessionHelper();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// create an initial saveSessionPromise
|
|
||||||
saveSessionPromise = saveSessionHelper();
|
|
||||||
}
|
|
||||||
store.commit(storeMutations.UPDATE_SAVE_SESSION_PROMISE, saveSessionPromise);
|
|
||||||
// await here to allow for a caller to await and make the function synchronous
|
|
||||||
await saveSessionPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PRIVATE FUNCTIONS //
|
|
||||||
|
|
||||||
/*
|
|
||||||
Calls API to load session given the referral number, referralDate, and referralCorrelationId
|
|
||||||
and returns the response.
|
|
||||||
*/
|
|
||||||
async function loadSession(referralNumber, referralDate, referralCorrelationId, accountNumber) {
|
|
||||||
// await the saveSessionPromise in the store to make sure we're loading up to date information
|
|
||||||
const store = useMainStore();
|
|
||||||
|
|
||||||
await store.applicationUser.saveSessionPromise;
|
|
||||||
const response = await baseMixin.methods.dispatchStoreAction(
|
|
||||||
storeActions.LOAD_SESSION,
|
|
||||||
{
|
|
||||||
referralNumber: referralNumber.toString(),
|
|
||||||
referralDate: referralDate,
|
|
||||||
referralCorrelationId: referralCorrelationId,
|
|
||||||
accountNumber: accountNumber?.toString(),
|
|
||||||
},
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Encapsulates asynchronous Save Session logic inside a promise to allow for Save Session queuing
|
|
||||||
*/
|
|
||||||
async function saveSessionHelper() {
|
|
||||||
const savedSessionInfo = await baseMixin.methods.dispatchStoreAction(storeActions.SAVE_SESSION);
|
|
||||||
// Update the store with information received from the saveSession response
|
|
||||||
await baseMixin.methods.dispatchStoreAction(
|
|
||||||
storeActions.UPDATE_STORE_WITH_SAVE_SESSION_RESPONSE,
|
|
||||||
{
|
|
||||||
referralNumber: savedSessionInfo.data.referralNumber.toString(),
|
|
||||||
referralCorrelationId: savedSessionInfo.data.referralCorrelationId,
|
|
||||||
referralDate: savedSessionInfo.data.referralDate,
|
|
||||||
accountNumber: savedSessionInfo.data.accountNumber.toString(),
|
|
||||||
savedSessionId: savedSessionInfo.data.savedSessionId,
|
|
||||||
crmCustomerId: savedSessionInfo.data.crmCustomerId.toString(),
|
|
||||||
},
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
// Update the cookie with the referral information when saved.
|
|
||||||
updateOrCreateFunnelCookie();
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
import { createWebHistory, createRouter } from "vue-router";
|
import { createWebHistory, createRouter } from "vue-router";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
|
||||||
import { storeMutations } from "../constants/store-mutations";
|
|
||||||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader";
|
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader";
|
||||||
import {issPageValues} from '@/router/router-constants/issPage-values';
|
import {issPageValues} from '@/router/router-constants/issPage-values';
|
||||||
import { routingTable } from "@/router/router-constants/routing-table";
|
import { routingTable } from "@/router/router-constants/routing-table";
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
|
|
||||||
import { loadSessionIfPresent, saveSession } from "@/helpers/heritage-integration/order-helper";
|
|
||||||
import analyticsMixin from "@/mixins/analytics-mixin";
|
import analyticsMixin from "@/mixins/analytics-mixin";
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
|
|
@ -60,16 +57,6 @@ router.afterEach((to, from) => {
|
||||||
// Update lastPageVisited in the store
|
// Update lastPageVisited in the store
|
||||||
store.updateLastPageVisited(to.name);
|
store.updateLastPageVisited(to.name);
|
||||||
|
|
||||||
// If saving on navigation is requested, check for saved SessionId or EmailAddress to determine if saving is appropriate
|
|
||||||
if (eval(to.params.isSavingNavigation)) {
|
|
||||||
if (
|
|
||||||
store.applicationUser.savedSessionId ||
|
|
||||||
store.order.customer?.emailAddress
|
|
||||||
) {
|
|
||||||
saveSession();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Push page view to GA
|
// Push page view to GA
|
||||||
analyticsMixin.methods.pushPageViewToGA();
|
analyticsMixin.methods.pushPageViewToGA();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue