CSR-690 Add savedSessionTimeoutDate stuff back

This commit is contained in:
Katie 2022-08-05 08:36:23 -04:00
parent 9248a5b3b2
commit 74b86c80d2
3 changed files with 25 additions and 14 deletions

View file

@ -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,

View file

@ -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;
}
// return savedSessionTimeoutDate;
// }

View file

@ -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