CSR-1086 Recover from old saved sessions and errors

This commit is contained in:
CarlNation 2023-01-17 10:19:54 -05:00
parent b8696a37d9
commit b3edba964d
2 changed files with 25 additions and 15 deletions

View file

@ -44,7 +44,7 @@ export async function loadSessionIfPresent(isConceptInsurance) {
funnelCookie.ReferralCorrelationId, funnelCookie.ReferralCorrelationId,
isConceptInsurance isConceptInsurance
) )
).data; )?.data;
} }
/* /*

View file

@ -10,6 +10,7 @@ import { experimentTriggers } from "@/constants/experiments";
import { damageLocationsSelected } from "@/constants/damage-locations-selected"; import { damageLocationsSelected } from "@/constants/damage-locations-selected";
import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
import router from "@/router"; import router from "@/router";
import { deleteFunnelCookie } from "@/helpers/heritage-integration/cookie-helper.js";
// Export State // Export State
const getDefaultState = () => { const getDefaultState = () => {
@ -1059,23 +1060,32 @@ export const actions = {
referralCorrelationId: referralCorrelationId, referralCorrelationId: referralCorrelationId,
}, },
}) })
.then((response) => { .then(
// Flatten location and name properties (response) => {
response.data.order.damage?.glassToReplace?.map((glass) => { // Flatten location and name properties
glass.glassLocation = glass.location; response.data.order.damage?.glassToReplace?.map((glass) => {
glass.glassName = glass.name; glass.glassLocation = glass.location;
delete glass.location; glass.glassName = glass.name;
delete glass.name; delete glass.location;
return glass; delete glass.name;
}); return glass;
});
// clear the state if the existing EON does not equal what is returned from loadSession // clear the state if the existing EON does not equal what is returned from loadSession
if (context.state.order.eon && context.state.order.eon != response.data.eon) { if (context.state.order.eon && context.state.order.eon != response.data.eon) {
context.commit(storeMutations.RESET_STATE);
}
context.commit(
storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION,
response.data
);
return response;
},
(error) => {
deleteFunnelCookie();
context.commit(storeMutations.RESET_STATE); context.commit(storeMutations.RESET_STATE);
} }
context.commit(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, response.data); );
return response;
});
}, },
// Business domain actions // Business domain actions