diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index a1d9ad6d..041ad137 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -1,7 +1,6 @@ import { queryStrings } from "@/constants/query-strings"; import { externalUrls } from "@/router/router-constants/externalUrl-values"; 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 { useMainStore } from "@/store"; import router from "@/router"; @@ -35,25 +34,6 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita 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. */ diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index 33c2c715..3d8a6192 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -1,6 +1,5 @@ import { - getPageToRouteExistingOrderTo, - navigateToHeritageFunnel, + getPageToRouteExistingOrderTo } from "@/helpers/heritage-integration/navigation-helper"; import * as orderHelper from "@/helpers/heritage-integration/order-helper"; import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js"; diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js deleted file mode 100644 index 3509f7e8..00000000 --- a/src/helpers/heritage-integration/order-helper.js +++ /dev/null @@ -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(); -} diff --git a/src/router/index.js b/src/router/index.js index d120bee9..9ecd061f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,12 +1,9 @@ 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 {issPageValues} from '@/router/router-constants/issPage-values'; import { routingTable } from "@/router/router-constants/routing-table"; import { useMainStore } from '@/store'; -import { loadSessionIfPresent, saveSession } from "@/helpers/heritage-integration/order-helper"; import analyticsMixin from "@/mixins/analytics-mixin"; const routes = [ @@ -60,16 +57,6 @@ router.afterEach((to, from) => { // Update lastPageVisited in the store 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 analyticsMixin.methods.pushPageViewToGA();