diff --git a/src/helpers/heritage-integration/cookie-helper.js b/src/helpers/heritage-integration/cookie-helper.js index 4af74bb80..f466bb9b8 100644 --- a/src/helpers/heritage-integration/cookie-helper.js +++ b/src/helpers/heritage-integration/cookie-helper.js @@ -1,7 +1,7 @@ import { cookieNames } from "@/constants/cookie-names"; import store from "@/store"; import { applicationConfig } from "@/constants/application-config"; -import { getDateForSavedSessionTimeout } from "@/helpers/heritage-integration/session-helper"; +// import { getDateForSavedSessionTimeout } from "@/helpers/heritage-integration/session-helper"; /* Will update the cookie if present, or create a new one if not. @@ -16,7 +16,7 @@ export function updateOrCreateFunnelCookie() { // Set up cookie with all the props. setFunnelCookieProperties({ LastTouched: new Date().toUTCString(), - SavedSessionTimeoutDate: getDateForSavedSessionTimeout(), + SavedSessionTimeoutDate: store.getters.applicationUser.savedSessionTimeout, DidHeritageFunnelUpdateLast: false, ShouldResetState: false, ReferralNumber: store.getters.order.referralNumber, diff --git a/src/helpers/heritage-integration/session-helper.js b/src/helpers/heritage-integration/session-helper.js index cf58846f0..a5118a21d 100644 --- a/src/helpers/heritage-integration/session-helper.js +++ b/src/helpers/heritage-integration/session-helper.js @@ -28,7 +28,7 @@ export function isAnalyticsSessionStillActive() { */ export function isSavedSessionStillActive() { if (getFunnelCookie() !== null) { - const savedSessionTimeStamp = new Date(getSavedSessionTimeoutDate()); + const savedSessionTimeStamp = new Date(getFunnelCookie().SavedSessionTimeoutDate); const isSavedSessionTimedOut = (new Date(new Date().toUTCString()) > savedSessionTimeStamp); return !isSavedSessionTimedOut; @@ -46,15 +46,15 @@ export function getDateForSavedSessionTimeout() { } /** Function to get saved session timeout date based on values in the cookie */ -function getSavedSessionTimeoutDate() { - let lastTouched = new Date(getFunnelCookie()?.LastTouched); - lastTouched = lastTouched ? lastTouched : new Date().toUTCString(); - let savedSessionTimeoutDate = lastTouched; - savedSessionTimeoutDate.setDate(savedSessionTimeoutDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS); +// function getSavedSessionTimeoutDate() { +// let lastTouched = new Date(getFunnelCookie()?.LastTouched); +// lastTouched = lastTouched ? lastTouched : new Date().toUTCString(); +// let savedSessionTimeoutDate = lastTouched; +// savedSessionTimeoutDate.setDate(savedSessionTimeoutDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS); - // const test = lastTouched - // ? lastTouched.setDate(lastTouched.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS) - // : getDateForSavedSessionTimeout(); +// // const test = lastTouched +// // ? lastTouched.setDate(lastTouched.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS) +// // : getDateForSavedSessionTimeout(); - return savedSessionTimeoutDate; -} \ No newline at end of file +// return savedSessionTimeoutDate; +// } \ No newline at end of file diff --git a/src/store/index.js b/src/store/index.js index 28d231316..7db358c1e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -65,7 +65,7 @@ const getDefaultState = () => { applicationUser: { eventBus: [], pageData: {}, - // savedSessionTimeout: getDateForSavedSessionTimeout(), + savedSessionTimeout: getDateForSavedSessionTimeout(), saveOrderPromise: null, savedSessionId: null, crmCustomerId: null, @@ -271,6 +271,9 @@ export const mutations = { state.order.lineItems.glassParts = null; state.order.damage.partQuestionAnswers = null; state.applicationUser.pageData[fmgPageValues.PART_QUESTIONS] = null; + state.applicationUser.pageData[fmgPageValues.VEHICLE_PARTS] = null; + state.applicationUser.pageData[fmgPageValues.MOLDING_QUESTIONS] = null; + state.applicationUser.pageData[fmgPageValues.CAPABILITY_QUESTIONS] = null; }, resetState(state) { Object.assign(state, getDefaultState()); @@ -746,6 +749,7 @@ export const actions = { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); //Save new values context.commit(storeMutations.UPDATE_YEAR, year); @@ -766,6 +770,7 @@ export const actions = { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); //Save new values context.commit(storeMutations.UPDATE_MAKE, make); @@ -785,6 +790,7 @@ export const actions = { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); //Save new values context.commit(storeMutations.UPDATE_MODEL, model); @@ -802,6 +808,7 @@ export const actions = { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); //Save new values context.commit(storeMutations.UPDATE_STYLE, style); @@ -832,6 +839,7 @@ export const actions = { //Reset dependent state when changing if (vehicleInfo.vin !== context.state.order.vehicle.vin) { context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); @@ -850,6 +858,7 @@ export const actions = { if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); } //Save new values @@ -865,6 +874,7 @@ export const actions = { if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); } //Save new values @@ -890,6 +900,7 @@ export const actions = { if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); } //Save new values