Merge pull request #625 from Safelite/feature/CSR-706
CSR-706 | Bug-fixing with save/load order
This commit is contained in:
commit
02be8f96b6
5 changed files with 17 additions and 2 deletions
|
|
@ -31,6 +31,7 @@ const storeActions = {
|
|||
INITIALIZE_SESSION: "initializeSession",
|
||||
GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser",
|
||||
CLEAR_VIN: "clearVin",
|
||||
RESET_SAVE_ORDER_PROMISE: "resetSaveOrderPromise",
|
||||
|
||||
// DEPENDENCY MUTATIONS
|
||||
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies",
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ const storeMutations = {
|
|||
UPDATE_STATE_WITH_ORDER_INFORMATION: "updateStateWithOrderInformation",
|
||||
UPDATE_SAVE_ORDER_PROMISE: "updateSaveOrderPromise",
|
||||
UPDATE_LAST_PAGE_VISITED: "updateLastPageVisited",
|
||||
RESET_SAVE_ORDER_PROMISE: "resetSaveOrderPromise",
|
||||
};
|
||||
|
||||
export { storeMutations };
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ export async function saveOrder() {
|
|||
and returns the response.
|
||||
*/
|
||||
async function loadOrder(referralNumber, referralDate, referralCorrelationId, accountNumber) {
|
||||
// await the saveOrderPromise in the store to make sure we're loading up to date information
|
||||
await store.getters.applicationUser.saveOrderPromise;
|
||||
const response = await baseMixin.methods.dispatchStoreAction(storeActions.LOAD_ORDER,
|
||||
{
|
||||
referralNumber: referralNumber.toString(),
|
||||
|
|
|
|||
|
|
@ -60,6 +60,9 @@ const routes = [
|
|||
|
||||
// On entering the funnel "fresh", read cookie information, decide what to do next.
|
||||
if (from.redirectedFrom === undefined) {
|
||||
// clear the saveOrderPromise - if it exists in the vuex store but a new instance was created
|
||||
// the saveOrderPromise will no longer point to a valid promise
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RESET_SAVE_ORDER_PROMISE);
|
||||
const loadOrderResponse = await loadOrderIfPresent();
|
||||
const pageToRedirectTo = await getPageToRouteExistingOrderTo(to, loadOrderResponse);
|
||||
|
||||
|
|
|
|||
|
|
@ -269,7 +269,9 @@ export const mutations = {
|
|||
resetState(state) {
|
||||
Object.assign(state, getDefaultState());
|
||||
},
|
||||
|
||||
resetSaveOrderPromise(state) {
|
||||
state.applicationUser.saveOrderPromise = null;
|
||||
},
|
||||
// Misc Mutations
|
||||
updateStateWithOrderInformation(state, orderInformation) {
|
||||
state.order.referralNumber = orderInformation.referralNumber;
|
||||
|
|
@ -457,6 +459,9 @@ export const actions = {
|
|||
resetState(context) {
|
||||
context.commit(storeMutations.RESET_STATE);
|
||||
},
|
||||
resetSaveOrderPromise(context) {
|
||||
context.commit(storeMutations.RESET_SAVE_ORDER_PROMISE);
|
||||
},
|
||||
|
||||
// Content API Actions
|
||||
getRouteInfo(context, { pageName }) {
|
||||
|
|
@ -701,7 +706,10 @@ export const actions = {
|
|||
accountNumber: accountNumber?.toString()
|
||||
},
|
||||
}).then((response) => {
|
||||
context.commit(storeMutations.RESET_STATE);
|
||||
// clear the state if the existing referral number does not equal what is returned from loadOrder
|
||||
if (context.state.order.referralNumber != response.data.referralNumber) {
|
||||
context.commit(storeMutations.RESET_STATE);
|
||||
}
|
||||
context.commit(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, response.data);
|
||||
return response;
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue