From 9ac8b1a31a4080f3e046648db30c68e1395e7517 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Tue, 5 Jul 2022 09:35:32 -0400 Subject: [PATCH] CSR-706 | Add in newly required parameters --- src/constants/store-mutations.js | 1 + src/router/index.js | 5 ++++- src/store/index.js | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 188094177..97ad5c458 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -50,6 +50,7 @@ const storeMutations = { UPDATE_STATE_WITH_ORDER_INFORMATION: "updateStateWithOrderInformation", UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION: "updateServiceLocationWithVehicleRegistration", UPDATE_SAVE_ORDER_PROMISE: "updateSaveOrderPromise", + UPDATE_LAST_PAGE_VISITED: "updateLastPageVisited", }; export { storeMutations }; diff --git a/src/router/index.js b/src/router/index.js index 2d2019cd4..33825c015 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,7 @@ // Supporting files 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.js"; import { routingTable } from "@/router/router-constants/routing-table.js"; import { globalEvents, globalEventTypes } from "@/constants/events"; @@ -113,7 +114,9 @@ const router = createRouter({ //---------------------------------------------------------- Router Functions ---------------------------------------------------------- -router.afterEach(async (to, from) => { +router.afterEach((to, from) => { + // Update lastPageVisited in the store + store.commit(storeMutations.UPDATE_LAST_PAGE_VISITED, to.name); // Push page view to GA analyticsMixin.methods.pushPageViewToGA(to.query[queryStrings.FMG_PAGE]); diff --git a/src/store/index.js b/src/store/index.js index c0e67a1e6..3894bff1e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -65,7 +65,8 @@ const getDefaultState = () => { savedSessionTimeout: getDateForSavedSessionTimeout(), saveOrderPromise: null, saveQuoteId: null, - crmCustomerId: null + crmCustomerId: null, + lastPageVisited: null, }, } }; @@ -179,6 +180,9 @@ export const mutations = { updateCrmCustomerId(state, crmCustomerId) { state.applicationUser.crmCustomerId = crmCustomerId; }, + updateLastPageVisited(state, lastPageVisited) { + state.applicationUser.lastPageVisited = lastPageVisited + }, // EVENT BUS MUTATIONS addEventToBus(state, event) { state.applicationUser.eventBus.push(event); @@ -580,6 +584,7 @@ export const actions = { const vehicle = context.getters.vehicle; const damage = context.getters.damage; const order = context.state.order; + const applicationUser = context.getters.applicationUser; return globalMethods.callHttpClient({ method: endpoints.SaveOrder.method, @@ -618,7 +623,12 @@ export const actions = { }, referralNumber: order.referralNumber?.toString(), // TODO It'd be nice to save these as strings in the first place referralDate: order.referralDate, - accountNumber: order.accountNumber?.toString() + accountNumber: order.accountNumber?.toString(), + existingPromoCode: null, + lastPage: applicationUser.lastPageVisited, + crmCustomerId: applicationUser.crmCustomerId, + saveQuoteId: applicationUser.saveQuoteId, + }, }); },