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 { cookieNames } from "@/constants/cookie-names";
import store from "@/store"; import store from "@/store";
import { applicationConfig } from "@/constants/application-config"; 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. 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. // Set up cookie with all the props.
setFunnelCookieProperties({ setFunnelCookieProperties({
LastTouched: new Date().toUTCString(), LastTouched: new Date().toUTCString(),
SavedSessionTimeoutDate: getDateForSavedSessionTimeout(), SavedSessionTimeoutDate: store.getters.applicationUser.savedSessionTimeout,
DidHeritageFunnelUpdateLast: false, DidHeritageFunnelUpdateLast: false,
ShouldResetState: false, ShouldResetState: false,
ReferralNumber: store.getters.order.referralNumber, ReferralNumber: store.getters.order.referralNumber,

View file

@ -28,7 +28,7 @@ export function isAnalyticsSessionStillActive() {
*/ */
export function isSavedSessionStillActive() { export function isSavedSessionStillActive() {
if (getFunnelCookie() !== null) { if (getFunnelCookie() !== null) {
const savedSessionTimeStamp = new Date(getSavedSessionTimeoutDate()); const savedSessionTimeStamp = new Date(getFunnelCookie().SavedSessionTimeoutDate);
const isSavedSessionTimedOut = (new Date(new Date().toUTCString()) > savedSessionTimeStamp); const isSavedSessionTimedOut = (new Date(new Date().toUTCString()) > savedSessionTimeStamp);
return !isSavedSessionTimedOut; return !isSavedSessionTimedOut;
@ -46,15 +46,15 @@ export function getDateForSavedSessionTimeout() {
} }
/** Function to get saved session timeout date based on values in the cookie */ /** Function to get saved session timeout date based on values in the cookie */
function getSavedSessionTimeoutDate() { // function getSavedSessionTimeoutDate() {
let lastTouched = new Date(getFunnelCookie()?.LastTouched); // let lastTouched = new Date(getFunnelCookie()?.LastTouched);
lastTouched = lastTouched ? lastTouched : new Date().toUTCString(); // lastTouched = lastTouched ? lastTouched : new Date().toUTCString();
let savedSessionTimeoutDate = lastTouched; // let savedSessionTimeoutDate = lastTouched;
savedSessionTimeoutDate.setDate(savedSessionTimeoutDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS); // savedSessionTimeoutDate.setDate(savedSessionTimeoutDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS);
// const test = lastTouched // // const test = lastTouched
// ? lastTouched.setDate(lastTouched.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS) // // ? lastTouched.setDate(lastTouched.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS)
// : getDateForSavedSessionTimeout(); // // : getDateForSavedSessionTimeout();
return savedSessionTimeoutDate; // return savedSessionTimeoutDate;
} // }

View file

@ -65,7 +65,7 @@ const getDefaultState = () => {
applicationUser: { applicationUser: {
eventBus: [], eventBus: [],
pageData: {}, pageData: {},
// savedSessionTimeout: getDateForSavedSessionTimeout(), savedSessionTimeout: getDateForSavedSessionTimeout(),
saveOrderPromise: null, saveOrderPromise: null,
savedSessionId: null, savedSessionId: null,
crmCustomerId: null, crmCustomerId: null,
@ -271,6 +271,9 @@ export const mutations = {
state.order.lineItems.glassParts = null; state.order.lineItems.glassParts = null;
state.order.damage.partQuestionAnswers = null; state.order.damage.partQuestionAnswers = null;
state.applicationUser.pageData[fmgPageValues.PART_QUESTIONS] = 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) { resetState(state) {
Object.assign(state, getDefaultState()); Object.assign(state, getDefaultState());
@ -746,6 +749,7 @@ export const actions = {
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
//Save new values //Save new values
context.commit(storeMutations.UPDATE_YEAR, year); 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_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
//Save new values //Save new values
context.commit(storeMutations.UPDATE_MAKE, make); 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_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
//Save new values //Save new values
context.commit(storeMutations.UPDATE_MODEL, model); 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_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
//Save new values //Save new values
context.commit(storeMutations.UPDATE_STYLE, style); context.commit(storeMutations.UPDATE_STYLE, style);
@ -832,6 +839,7 @@ export const actions = {
//Reset dependent state when changing //Reset dependent state when changing
if (vehicleInfo.vin !== context.state.order.vehicle.vin) { if (vehicleInfo.vin !== context.state.order.vehicle.vin) {
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
if (!isSelectedGlassAvailableForVehicle) { if (!isSelectedGlassAvailableForVehicle) {
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
@ -850,6 +858,7 @@ export const actions = {
if (!isSelectedGlassAvailableForVehicle) { if (!isSelectedGlassAvailableForVehicle) {
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
} }
//Save new values //Save new values
@ -865,6 +874,7 @@ export const actions = {
if (!isSelectedGlassAvailableForVehicle) { if (!isSelectedGlassAvailableForVehicle) {
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
} }
//Save new values //Save new values
@ -890,6 +900,7 @@ export const actions = {
if (!isSelectedGlassAvailableForVehicle) { if (!isSelectedGlassAvailableForVehicle) {
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
} }
//Save new values //Save new values