CSR-700 | Save response from SaveOrder to VueX Store
This commit is contained in:
parent
e51dc1a8d0
commit
3b8b86fe7e
5 changed files with 29 additions and 9 deletions
|
|
@ -16,7 +16,7 @@ const storeActions = {
|
|||
GET_PARTS_OR_QUESTIONS: "getPartsOrQuestions",
|
||||
SAVE_ORDER: "saveOrder",
|
||||
LOAD_ORDER: "loadOrder",
|
||||
SET_REFERRAL_INFORMATION: "setReferralInformation",
|
||||
UPDATE_STORE_WITH_SAVE_ORDER_RESPONSE: "updateStoreWithSaveOrderResponse",
|
||||
VALIDATE_ZIP: "validateZip",
|
||||
LOG_EXPERIMENT_EXPOSURE: "logExperimentExposure",
|
||||
LOG_PAGE_VIEW: "logPageView",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ const storeMutations = {
|
|||
UPDATE_REFERRAL_DATE: "updateReferralDate",
|
||||
UPDATE_REFERRAL_CORRELATION_ID: "updateReferralCorrelationId",
|
||||
UPDATE_PARENT_ACCT_NUMBER: "updateParentAcctNumber",
|
||||
UPDATE_SAVE_QUOTE_ID: "updateSaveQuoteId",
|
||||
UPDATE_CRM_CUSTOMER_ID: "updateCrmCustomerId",
|
||||
|
||||
// EVENT BUS MUTATIONS
|
||||
ADD_EVENT_TO_BUS: "addEventToBus",
|
||||
|
|
|
|||
|
|
@ -70,14 +70,20 @@ async function loadOrder(referralNumber, referralDate, referralCorrelationId, ac
|
|||
|
||||
return response;
|
||||
}
|
||||
|
||||
/*
|
||||
Encapsulates asynchronous Save Order logic inside a promise to allow for Save Order queuing
|
||||
*/
|
||||
async function saveOrderHelper() {
|
||||
const savedOrderInfo = await baseMixin.methods.dispatchStoreAction(storeActions.SAVE_ORDER);
|
||||
// Save the referral information back from the store.
|
||||
await baseMixin.methods.dispatchStoreAction(storeActions.SET_REFERRAL_INFORMATION, {
|
||||
// Update the store with information received from the saveOrder response
|
||||
await baseMixin.methods.dispatchStoreAction(storeActions.UPDATE_STORE_WITH_SAVE_ORDER_RESPONSE, {
|
||||
referralNumber: savedOrderInfo.data.referralNumber.toString(),
|
||||
referralCorrelationId: savedOrderInfo.data.referralCorrelationId,
|
||||
referralDate: savedOrderInfo.data.referralDate,
|
||||
accountNumber: savedOrderInfo.data.accountNumber.toString()
|
||||
accountNumber: savedOrderInfo.data.accountNumber.toString(),
|
||||
saveQuoteId: savedOrderInfo.data.saveQuoteId,
|
||||
crmCustomerId: savedOrderInfo.data.crmCustomerId.toString(),
|
||||
}, false);
|
||||
|
||||
// Update the cookie with the referral information when saved.
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ async function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery
|
|||
baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData);
|
||||
|
||||
// if cookie and referralNumber/Date exists OR an emailAddress has been saved
|
||||
if ((getFunnelCookie()?.ReferralNumber && getFunnelCookie()?.ReferralDate) || store.getters.customer.emailAddress) {
|
||||
if ((getFunnelCookie()?.ReferralNumber && getFunnelCookie()?.ReferralDate) || store.getters.order.customer?.emailAddress) {
|
||||
saveOrder();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ const getDefaultState = () => {
|
|||
pageData: {},
|
||||
savedSessionTimeout: getDateForSavedSessionTimeout(),
|
||||
saveOrderPromise: null,
|
||||
saveQuoteId: null,
|
||||
crmCustomerId: null
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
@ -167,6 +169,16 @@ export const mutations = {
|
|||
state.order.customer.emailAddress = customerEmailAddress;
|
||||
},
|
||||
|
||||
// applicationUser MUTATIONS
|
||||
updateSaveOrderPromise(state, saveOrderPromise){
|
||||
state.applicationUser.saveOrderPromise = saveOrderPromise;
|
||||
},
|
||||
updateSaveQuoteId(state, saveQuoteId) {
|
||||
state.applicationUser.saveQuoteId = saveQuoteId;
|
||||
},
|
||||
updateCrmCustomerId(state, crmCustomerId) {
|
||||
state.applicationUser.crmCustomerId = crmCustomerId;
|
||||
},
|
||||
// EVENT BUS MUTATIONS
|
||||
addEventToBus(state, event) {
|
||||
state.applicationUser.eventBus.push(event);
|
||||
|
|
@ -270,9 +282,6 @@ export const mutations = {
|
|||
state.order.serviceLocation.state = state.order.vehicle.registration.state;
|
||||
state.order.serviceLocation.zipCode = state.order.vehicle.registration.zipCode;
|
||||
},
|
||||
updateSaveOrderPromise(state, saveOrderPromise){
|
||||
state.applicationUser.saveOrderPromise = saveOrderPromise;
|
||||
},
|
||||
}
|
||||
|
||||
// Export Getters
|
||||
|
|
@ -447,10 +456,13 @@ export const actions = {
|
|||
},
|
||||
|
||||
// Misc Actions
|
||||
setReferralInformation(context, { referralNumber, referralDate, referralCorrelationId }) {
|
||||
updateStoreWithSaveOrderResponse(context, { referralNumber, referralDate, referralCorrelationId, accountNumber, saveQuoteId, crmCustomerId }) {
|
||||
context.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber);
|
||||
context.commit(storeMutations.UPDATE_REFERRAL_DATE, referralDate);
|
||||
context.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, referralCorrelationId);
|
||||
context.commit(storeMutations.UPDATE_PARENT_ACCT_NUMBER, accountNumber);
|
||||
context.commit(storeMutations.UPDATE_SAVE_QUOTE_ID, saveQuoteId);
|
||||
context.commit(storeMutations.UPDATE_CRM_CUSTOMER_ID, crmCustomerId);
|
||||
},
|
||||
updateServiceLocationWithVehicleRegistration(context) {
|
||||
context.commit(storeMutations.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION);
|
||||
|
|
|
|||
Loading…
Reference in a new issue