From 972e02a5b206c26e41b6765a7e7fcca9532eb139 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Thu, 23 Jun 2022 15:23:30 -0400 Subject: [PATCH 01/13] CSR-706 | Re-work synchronicity of saveOrder Allow multiple saveOrders to run synchronously Allow saveOrder to be awaited before navigating to heritage Allow saveOrder to run on routine navigation if an email address is present Add saveOrderPromise member to the store --- src/constants/store-mutations.js | 3 +- .../heritage-integration/order-helper.js | 41 +++++++++++++------ src/router/index.js | 6 +-- src/store/index.js | 9 ++-- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 1924b0063..bbd6fc818 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -46,7 +46,8 @@ const storeMutations = { // OTHER MUTATIONS UPDATE_PAGE_DATA: "updatePageData", UPDATE_STATE_WITH_ORDER_INFORMATION: "updateStateWithOrderInformation", - UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION: "updateServiceLocationWithVehicleRegistration" + UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION: "updateServiceLocationWithVehicleRegistration", + UPDATE_SAVE_ORDER_PROMISE: "updateSaveOrderPromise", }; export { storeMutations }; diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index 962550592..af672f7cd 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -1,6 +1,8 @@ import { storeActions } from "@/constants/store-actions.js"; import { getFunnelCookie, updateOrCreateFunnelCookie, deleteFunnelCookie } from "@/helpers/heritage-integration/cookie-helper.js"; import baseMixin from "@/mixins/base-mixin"; +import store from "@/store"; +import { storeMutations } from "@/constants/store-mutations"; /* Will call API and hydrate state with data from API if present. If there is no order present @@ -34,18 +36,20 @@ export async function loadOrderIfPresent() { update the cookie. */ export async function saveOrder() { - 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, { - referralNumber: savedOrderInfo.data.referralNumber.toString(), - referralCorrelationId: savedOrderInfo.data.referralCorrelationId, - referralDate: savedOrderInfo.data.referralDate, - accountNumber: savedOrderInfo.data.accountNumber.toString() - }, false); - - // Update the cookie with the referral information when saved. - updateOrCreateFunnelCookie(); + var saveOrderPromise; + if (store.getters.applicationUser.saveOrderPromise) { + // queue newest request after current saveOrderPromise resolves + saveOrderPromise = store.getters.applicationUser.saveOrderPromise.then(() => { + // get a new saveOrderPromise + return saveOrderHelper(); + }); + } else { + // create an initial saveOrderPromise + saveOrderPromise = saveOrderHelper(); + } + store.commit(storeMutations.UPDATE_SAVE_ORDER_PROMISE, saveOrderPromise); + // await here to allow for a caller to await and make the function synchronous + await saveOrderPromise; } @@ -65,4 +69,17 @@ async function loadOrder(referralNumber, referralDate, referralCorrelationId, ac }, false); return response; +} +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, { + referralNumber: savedOrderInfo.data.referralNumber.toString(), + referralCorrelationId: savedOrderInfo.data.referralCorrelationId, + referralDate: savedOrderInfo.data.referralDate, + accountNumber: savedOrderInfo.data.accountNumber.toString() + }, false); + + // Update the cookie with the referral information when saved. + updateOrCreateFunnelCookie(); } \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index 2b2d09859..b3cc73be1 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -177,9 +177,9 @@ async function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery // Append page data to the store for the NEXT page, if any. It will be an empty object if none is provided. baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData); - // if cookie and referralNumber/Date exists - if (getFunnelCookie()?.ReferralNumber && getFunnelCookie()?.ReferralDate) { - await saveOrder(); + // if cookie and referralNumber/Date exists OR an emailAddress has been saved + if ((getFunnelCookie()?.ReferralNumber && getFunnelCookie()?.ReferralDate) || store.getters.customer.emailAddress) { + saveOrder(); } router.push({ diff --git a/src/store/index.js b/src/store/index.js index 5730adf53..52b373aaa 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -62,7 +62,8 @@ const getDefaultState = () => { applicationUser: { eventBus: [], pageData: {}, - savedSessionTimeout: getDateForSavedSessionTimeout() + savedSessionTimeout: getDateForSavedSessionTimeout(), + saveOrderPromise: null, }, } }; @@ -166,7 +167,6 @@ export const mutations = { state.order.customer.emailAddress = customerEmailAddress; }, - // EVENT BUS MUTATIONS addEventToBus(state, event) { state.applicationUser.eventBus.push(event); @@ -269,7 +269,10 @@ export const mutations = { state.order.serviceLocation.city = state.order.vehicle.registration.city; 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 From 3b8b86fe7e365d04c5b9e859db167e1bb945645e Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Wed, 29 Jun 2022 09:05:02 -0400 Subject: [PATCH 02/13] CSR-700 | Save response from SaveOrder to VueX Store --- src/constants/store-actions.js | 2 +- src/constants/store-mutations.js | 2 ++ .../heritage-integration/order-helper.js | 12 ++++++++--- src/router/index.js | 2 +- src/store/index.js | 20 +++++++++++++++---- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 0ac79ac28..a172e79cc 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -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", diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index bbd6fc818..188094177 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -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", diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index af672f7cd..9722744f0 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -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. diff --git a/src/router/index.js b/src/router/index.js index e0b789f81..2d2019cd4 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -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(); } diff --git a/src/store/index.js b/src/store/index.js index 52b373aaa..c0e67a1e6 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -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); From 415200ea5ab50ba89684f5be227c1dbe24ad7b5a Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Wed, 29 Jun 2022 17:11:00 -0400 Subject: [PATCH 03/13] CSR-700 | Update Unit Tests --- .../navigation-helper.spec.js | 10 ++++-- .../heritage-integration/order-helper.spec.js | 31 ++++++++++++------- src/helpers/unit-test-helper.js | 6 ++-- src/store/store.spec.js | 15 +++++++-- 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index e212284b8..e78782d7c 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -308,8 +308,11 @@ describe("navigateToHeritageFunnel", () => { const mockReferralNumber = "2"; const mockCorrelationId = "55"; const mockReferralDate = "2022"; + const mockAccountNumber = "167132"; + const mockSaveQuoteId = "xxx-xxx-xxx"; + const mockCrmCustomerId = "xxx-xxx-xxx" - const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate); + const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, mockAccountNumber, mockSaveQuoteId, mockCrmCustomerId); const mockData = { actionList: [{ @@ -340,8 +343,11 @@ describe("navigateToHeritageFunnel", () => { const mockReferralNumber = "2"; const mockCorrelationId = "55"; const mockReferralDate = "2022"; + const mockAccountNumber = "167132"; + const mockSaveQuoteId = "xxx-xxx-xxx"; + const mockCrmCustomerId = "xxx-xxx-xxx" - const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate); + const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, mockAccountNumber, mockSaveQuoteId, mockCrmCustomerId); const mockData = { actionList: [{ diff --git a/src/helpers/heritage-integration/order-helper.spec.js b/src/helpers/heritage-integration/order-helper.spec.js index 7d769a8d8..c3a581e41 100644 --- a/src/helpers/heritage-integration/order-helper.spec.js +++ b/src/helpers/heritage-integration/order-helper.spec.js @@ -111,9 +111,11 @@ describe("saveOrder", () => { const mockReferralNumber = "2"; const mockCorrelationId = "55"; const mockReferralDate = "2022"; - const mockAccountNumber = "5"; + const mockAccountNumber = "167132"; + const mockSaveQuoteId = "xxx-xxx-xxx"; + const mockCrmCustomerId = "xxx-xxx-xxx" - const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, mockAccountNumber); + const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, mockAccountNumber, mockSaveQuoteId, mockCrmCustomerId); const mockData = { actionList: [ @@ -122,7 +124,7 @@ describe("saveOrder", () => { data: mockOrderInfo, }, { - actionName: storeActions.SET_REFERRAL_INFORMATION + actionName: storeActions.UPDATE_STORE_WITH_SAVE_ORDER_RESPONSE } ] } @@ -134,21 +136,26 @@ describe("saveOrder", () => { // Assert expect(mocks.baseMixin.methods.dispatchStoreAction).toHaveBeenCalledWith(storeActions.SAVE_ORDER); - expect(mocks.baseMixin.methods.dispatchStoreAction).toHaveBeenCalledWith(storeActions.SET_REFERRAL_INFORMATION, { + expect(mocks.baseMixin.methods.dispatchStoreAction).toHaveBeenCalledWith(storeActions.UPDATE_STORE_WITH_SAVE_ORDER_RESPONSE, { referralNumber: mockReferralNumber, referralDate: mockReferralDate, referralCorrelationId: mockCorrelationId, - accountNumber: mockAccountNumber + accountNumber: mockAccountNumber, + saveQuoteId: mockSaveQuoteId, + crmCustomerId: mockCrmCustomerId, }, false); }); test("saveOrder => should update DidHeritageFunnelUpdateLast cookie value to false", async () => { // Arrange - const testReferralNumber = 1566818; - const testReferralDate = "2022-03-15T10:56:24.597"; - const testReferralCorrelationId = "404d2b04-f86e-45c3-b373-127b6217b060"; + const mockReferralNumber = 1566818; + const mockReferralDate = "2022-03-15T10:56:24.597"; + const mockReferralCorrelationId = "404d2b04-f86e-45c3-b373-127b6217b060"; + const mockAccountNumber = "167132"; + const mockSaveQuoteId = "xxx-xxx-xxx"; + const mockCrmCustomerId = "xxx-xxx-xxx" - const mockOrderInfo = getMockOrderInfo(testReferralNumber, testReferralCorrelationId, testReferralDate); + const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockReferralCorrelationId, mockReferralDate, mockAccountNumber, mockSaveQuoteId, mockCrmCustomerId); const mockData = { actionList: [{ @@ -161,9 +168,9 @@ describe("saveOrder", () => { setupMocksForJsFiles(mockData); const testCookieValue = { - ReferralNumber: testReferralNumber, - ReferralDate: testReferralDate, - ReferralCorrelationId: testReferralCorrelationId, + ReferralNumber: mockReferralNumber, + ReferralDate: mockReferralDate, + ReferralCorrelationId: mockReferralCorrelationId, ShouldResetState: false, DidHeritageFunnelUpdateLast: true } diff --git a/src/helpers/unit-test-helper.js b/src/helpers/unit-test-helper.js index 592af9a5c..d4f38a64e 100644 --- a/src/helpers/unit-test-helper.js +++ b/src/helpers/unit-test-helper.js @@ -90,12 +90,14 @@ export function removeAllTestCookies() { }); } -export function getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, accountNumber = "0") { +export function getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, accountNumber = "0", saveQuoteId, crmCustomerId) { return { referralNumber: mockReferralNumber, referralCorrelationId: mockCorrelationId, referralDate: mockReferralDate, - accountNumber: accountNumber + accountNumber: accountNumber, + saveQuoteId: saveQuoteId, + crmCustomerId: crmCustomerId, } } diff --git a/src/store/store.spec.js b/src/store/store.spec.js index c70629296..78a6a8d1d 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -611,7 +611,7 @@ describe("Actions", () => { expect(commit).toBeCalledWith(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, {"referralNumber": 123}); }); - it("setReferralInformation, should call commit three times", () => { + it("updateStoreWithSaveOrderResponse, should call commit six times", () => { // Arrange const context = state; const commit = jest.fn(); @@ -619,12 +619,23 @@ describe("Actions", () => { context.commit = commit; // Act - actions.setReferralInformation(context, {referralNumber: "123", referralDate: new Date().toUTCString(), referralCorrelationId: "xxx-xxx-xxx"}); + actions.updateStoreWithSaveOrderResponse(context, + { + referralNumber: "123", + referralDate: new Date().toUTCString(), + referralCorrelationId: "xxx-xxx-xxx", + accountNumber: "167132", + saveQuoteId: "xxx-xxx-xxx", + crmCustomerId: "xxx-xxx-xxx", + }); // Assert expect(commit).toBeCalledWith(storeMutations.UPDATE_REFERRAL_NUMBER, "123"); expect(commit).toBeCalledWith(storeMutations.UPDATE_REFERRAL_DATE, new Date().toUTCString()); expect(commit).toBeCalledWith(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, "xxx-xxx-xxx"); + expect(commit).toBeCalledWith(storeMutations.UPDATE_PARENT_ACCT_NUMBER, "167132"); + expect(commit).toBeCalledWith(storeMutations.UPDATE_SAVE_QUOTE_ID, "xxx-xxx-xxx"); + expect(commit).toBeCalledWith(storeMutations.UPDATE_CRM_CUSTOMER_ID, "xxx-xxx-xxx"); }); it("logPageView action, should return nothing", async () => { From 9ac8b1a31a4080f3e046648db30c68e1395e7517 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Tue, 5 Jul 2022 09:35:32 -0400 Subject: [PATCH 04/13] CSR-706 | Add in newly required parameters --- src/constants/store-mutations.js | 1 + src/router/index.js | 5 ++++- src/store/index.js | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 188094177..97ad5c458 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -50,6 +50,7 @@ const storeMutations = { UPDATE_STATE_WITH_ORDER_INFORMATION: "updateStateWithOrderInformation", UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION: "updateServiceLocationWithVehicleRegistration", UPDATE_SAVE_ORDER_PROMISE: "updateSaveOrderPromise", + UPDATE_LAST_PAGE_VISITED: "updateLastPageVisited", }; export { storeMutations }; diff --git a/src/router/index.js b/src/router/index.js index 2d2019cd4..33825c015 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,7 @@ // Supporting files import { createWebHistory, createRouter } from "vue-router"; import { storeActions } from "@/constants/store-actions"; +import { storeMutations } from "../constants/store-mutations"; import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js"; import { routingTable } from "@/router/router-constants/routing-table.js"; import { globalEvents, globalEventTypes } from "@/constants/events"; @@ -113,7 +114,9 @@ const router = createRouter({ //---------------------------------------------------------- Router Functions ---------------------------------------------------------- -router.afterEach(async (to, from) => { +router.afterEach((to, from) => { + // Update lastPageVisited in the store + store.commit(storeMutations.UPDATE_LAST_PAGE_VISITED, to.name); // Push page view to GA analyticsMixin.methods.pushPageViewToGA(to.query[queryStrings.FMG_PAGE]); diff --git a/src/store/index.js b/src/store/index.js index c0e67a1e6..3894bff1e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -65,7 +65,8 @@ const getDefaultState = () => { savedSessionTimeout: getDateForSavedSessionTimeout(), saveOrderPromise: null, saveQuoteId: null, - crmCustomerId: null + crmCustomerId: null, + lastPageVisited: null, }, } }; @@ -179,6 +180,9 @@ export const mutations = { updateCrmCustomerId(state, crmCustomerId) { state.applicationUser.crmCustomerId = crmCustomerId; }, + updateLastPageVisited(state, lastPageVisited) { + state.applicationUser.lastPageVisited = lastPageVisited + }, // EVENT BUS MUTATIONS addEventToBus(state, event) { state.applicationUser.eventBus.push(event); @@ -580,6 +584,7 @@ export const actions = { const vehicle = context.getters.vehicle; const damage = context.getters.damage; const order = context.state.order; + const applicationUser = context.getters.applicationUser; return globalMethods.callHttpClient({ method: endpoints.SaveOrder.method, @@ -618,7 +623,12 @@ export const actions = { }, referralNumber: order.referralNumber?.toString(), // TODO It'd be nice to save these as strings in the first place referralDate: order.referralDate, - accountNumber: order.accountNumber?.toString() + accountNumber: order.accountNumber?.toString(), + existingPromoCode: null, + lastPage: applicationUser.lastPageVisited, + crmCustomerId: applicationUser.crmCustomerId, + saveQuoteId: applicationUser.saveQuoteId, + }, }); }, From 13d6f15d371c999eda5352d3c0de7efc4e9a707b Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Tue, 12 Jul 2022 14:37:55 -0400 Subject: [PATCH 05/13] CSR-108: complete part-questions page, changes to question-chain --- .../question-chain/question-chain.vue | 18 +- src/constants/endpoints.js | 4 + src/constants/store-actions.js | 5 +- src/constants/store-mutations.js | 1 + .../address-vehicles/address-vehicles.vue | 10 +- src/layouts/part-questions/part-questions.vue | 202 +++++++++++++++--- .../router-constants/navigation-scenarios.js | 2 + src/router/router-constants/routing-table.js | 10 +- src/store/index.js | 35 ++- 9 files changed, 246 insertions(+), 41 deletions(-) diff --git a/src/common-components/question-chain/question-chain.vue b/src/common-components/question-chain/question-chain.vue index 9e8b97674..a248259ab 100644 --- a/src/common-components/question-chain/question-chain.vue +++ b/src/common-components/question-chain/question-chain.vue @@ -8,7 +8,7 @@ :questionText="q.questionText" :answers="q.answers" :groupName="`${questionData.glassName}-${questionData.glassLocation}-${i}`" - v-model="selectedValuesArray" + v-model="selectedValue" :isRequired=true :validationRules="validationRules" :clearOnUnmount=false @@ -25,13 +25,14 @@ export default { data() { return { currentQuestionNum: 1, - questions: [{ "BlankObject": "NOT USED... placeholder for question #0"}], + questions: [{ "BlankObject": "NOT USED... placeholder for question #0 to simplify indexing"}], }; }, props: { questionData: Object, validationRules: String, modelValue: Array, + partIndex: Number, }, created() { this.questionData.partQuestions.map((q, i) => { @@ -61,12 +62,11 @@ export default { }); }, computed: { - selectedValuesArray: { + selectedValue: { get: function() { - return []; + return ""; }, - set: function(returnedAnswerArray) { - const returnedAnswer = returnedAnswerArray[returnedAnswerArray.length-1]; + set: function(returnedAnswer) { const isQuestionChainComplete = this.handleReturnedAnswer(returnedAnswer); if (isQuestionChainComplete) { @@ -102,6 +102,7 @@ export default { // set this question as "answered" this.questions[questionNum].answerSelected = questionAnswerText; + this.questions[questionNum].answerNumber = questionNum; // update to next question index this.currentQuestionNum = questionType === "nextQuestion" ? parseInt(questionAnswer) : parseInt(questionNum); // update count to display next question @@ -116,16 +117,17 @@ export default { answeredQuestions.push({ questionText: q.questionText, selectedAnswerText: q.answerSelected, - questionNum: questionNum, + questionNum: q.answerNumber, }); } }); return { answerResult: questionAnswer, answeredQuestions: answeredQuestions, + partIndex: this.partIndex, }; } - } + }, }, watch: { currentQuestion: { diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 7ff9e3cec..e7f856f40 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -55,6 +55,10 @@ const endpoints = { url: "/parts/api/v1/parts/parts-or-questions", method: "POST", }, + GetParts: { + url: "/parts/api/v1/parts/parts", + method: "POST", + }, SaveOrder: { url: "/order/api/v1/order/save", method: "POST", diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 573d90e1d..86df61063 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -20,6 +20,7 @@ const storeActions = { LOOKUP_VIN_BY_ADDRESS: "lookupVinByAddress", GET_PARTS_OR_QUESTIONS: "getPartsOrQuestions", + GET_PARTS: "getParts", SAVE_ORDER: "saveOrder", LOAD_ORDER: "loadOrder", SET_REFERRAL_INFORMATION: "setReferralInformation", @@ -31,7 +32,6 @@ const storeActions = { GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser", CLEAR_VIN: "clearVin", - // DEPENDENCY MUTATIONS RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies", RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies", @@ -51,7 +51,8 @@ const storeActions = { SAVE_REGISTRATION_LICENSE_PLATE_LOOKUP: "saveRegistrationLicensePlateLookup", SAVE_VIN: "saveVin", SAVE_REGISTRATION_ADDRESS_LOOKUP: "saveRegistrationAddressLookup", - SAVE_GLASS_PARTS: "saveGlassParts", + SAVE_GLASS_PARTS: "saveGlassParts", + SAVE_PART_QUESTION_ANSWERS: "savePartQuestionAnswers", }; export { storeActions }; diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index a1358233a..167e0710c 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -16,6 +16,7 @@ const storeMutations = { UPDATE_IS_REPAIR: "updateIsRepair", UPDATE_NUMBER_OF_CHIPS: "updateNumberOfChips", UPDATE_GLASS_TO_REPLACE: "updateGlassToReplace", + UPDATE_PART_QUESTION_ANSWERS: "updatePartQuestionAnswers", UPDATE_GLASS_PARTS: "updateGlassParts", UPDATE_REGISTRATION_LICENSE_PLATE : "updateRegistrationLicensePlate", diff --git a/src/layouts/address-vehicles/address-vehicles.vue b/src/layouts/address-vehicles/address-vehicles.vue index 7936ef83e..38dea789d 100644 --- a/src/layouts/address-vehicles/address-vehicles.vue +++ b/src/layouts/address-vehicles/address-vehicles.vue @@ -12,12 +12,12 @@ + v-bind:isDismissible="false" + /> -
- - - -
-

Part Questions Page Placeholder

- -
-
+
+
+ + + +
+ +
+ +
+ +
+
+
+ + diff --git a/src/router/router-constants/navigation-scenarios.js b/src/router/router-constants/navigation-scenarios.js index 7bf425efc..a9cf0b0ea 100644 --- a/src/router/router-constants/navigation-scenarios.js +++ b/src/router/router-constants/navigation-scenarios.js @@ -17,6 +17,8 @@ const navigationScenarios = { SELECTED_MANUAL_VIN: "SELECTED_MANUAL_VIN", SELECTED_LICENSE_PLATE: "SELECTED_LICENSE_PLATE", SELECTED_HOME_ADDRESS: "SELECTED_HOME_ADDRESS", + ANSWERED_QUESTIONS_WITH_SINGLE_PART: "ANSWERED_QUESTIONS_WITH_SINGLE_PART", + ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS: "ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS", }; export { navigationScenarios }; diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 78c5ac242..515465385 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -216,7 +216,15 @@ const routingTable = [ { scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.VIN_LOOKUP - } + }, + { + scenario: navigationScenarios.ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS, + destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS + }, + { + scenario: navigationScenarios.ANSWERED_QUESTIONS_WITH_SINGLE_PART, + destinationFmgPageValue: fmgPageValues.QUOTE, + }, ] }, ]; diff --git a/src/store/index.js b/src/store/index.js index 0d8689242..a7676a04e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -44,6 +44,7 @@ const getDefaultState = () => { isRepair: null, numberOfChips: null, glassToReplace: null, + partQuestionAnswers: null, }, lineItems: { glassParts: null, @@ -112,6 +113,9 @@ export const mutations = { updateGlassToReplace(state, glassToReplace) { state.order.damage.glassToReplace = glassToReplace; }, + updatePartQuestionAnswers(state, answersArray) { + state.order.damage.partQuestionAnswers = answersArray; + }, updateGlassParts(state, partsData) { state.order.lineItems.glassParts = partsData; }, @@ -555,7 +559,7 @@ export const actions = { }); }, - // Parts API Actions + // PartsOrQuestions API Actions getPartsOrQuestions(context) { const vehicle = context.getters.vehicle; const damage = context.getters.damage; @@ -578,6 +582,31 @@ export const actions = { }); }, + // Parts API Actions + getParts(context) { + const vehicle = context.getters.vehicle; + const damage = context.getters.damage; + const order = context.state.order; + + const carId = vehicle.carId; + const glassArray = damage.glassToReplace; + const resultsArray = damage.partQuestionAnswers; + const zipCode = order.serviceLocation.zipCode; + const vin = vehicle.vin; + + return globalMethods.callHttpClient({ + method: endpoints.GetParts.method, + endpoint: endpoints.GetParts.url, + payload: { + carId: carId, + glass: glassArray, + answerResults: resultsArray, + zip: zipCode, + vin: vin + }, + }); + }, + // Order API Actions saveOrder(context) { const vehicle = context.getters.vehicle; @@ -787,6 +816,10 @@ export const actions = { context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo); } }, + savePartQuestionAnswers(context, partQuestionAnswersArray) { + //Save new values + context.commit(storeMutations.UPDATE_PART_QUESTION_ANSWERS, partQuestionAnswersArray); + }, // Misc order actions saveServiceLocation(context, serviceLocationInfo) { From 43c95a81a36150f0a0516de912239f7bd813e3a4 Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Tue, 12 Jul 2022 15:43:11 -0400 Subject: [PATCH 06/13] CSR-108: minor CSS changes to match Figma --- src/common-components/button-question/button-question.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue index aa4aec2a1..2ea6d1c3a 100644 --- a/src/common-components/button-question/button-question.vue +++ b/src/common-components/button-question/button-question.vue @@ -2,7 +2,7 @@ diff --git a/src/layouts/vehicle-model/model-question/model-question.vue b/src/layouts/vehicle-model/model-question/model-question.vue index 3f4e3be7e..096f4d70c 100644 --- a/src/layouts/vehicle-model/model-question/model-question.vue +++ b/src/layouts/vehicle-model/model-question/model-question.vue @@ -8,7 +8,7 @@ groupName="ChooseVehicleModel" textPosition="text-start" v-model="selectedValue" - isRequired=true + isRequired /> diff --git a/src/layouts/vehicle-style/style-question/style-question.vue b/src/layouts/vehicle-style/style-question/style-question.vue index e04822cd6..4e6e90798 100644 --- a/src/layouts/vehicle-style/style-question/style-question.vue +++ b/src/layouts/vehicle-style/style-question/style-question.vue @@ -8,7 +8,7 @@ groupName="ChooseVehicleStyle" textPosition="text-start" v-model="selectedValue" - isRequired=true + isRequired /> diff --git a/src/layouts/vehicle-year/year-question/year-question.vue b/src/layouts/vehicle-year/year-question/year-question.vue index 5892c5dd9..8889a0fdc 100644 --- a/src/layouts/vehicle-year/year-question/year-question.vue +++ b/src/layouts/vehicle-year/year-question/year-question.vue @@ -8,7 +8,7 @@ groupName="ChooseVehicleYear" textPosition="text-start" v-model="selectedValue" - isRequired=true + isRequired /> From 37123df3f68d7dff90f0ba258033821e2a6389ea Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 13 Jul 2022 09:20:32 -0400 Subject: [PATCH 11/13] CSR-612 Cleanup --- src/common-components/question-chain/question-chain.vue | 2 +- .../address-vehicles-question/address-vehicles-question.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common-components/question-chain/question-chain.vue b/src/common-components/question-chain/question-chain.vue index c6a4f098d..6993bf170 100644 --- a/src/common-components/question-chain/question-chain.vue +++ b/src/common-components/question-chain/question-chain.vue @@ -9,7 +9,7 @@ :answers="q.answers" :groupName="`${questionData.glassName}-${questionData.glassLocation}-${i}`" v-model="selectedValuesArray" - :isRequired="true" + isRequired :validationRules="validationRules" :clearOnUnmount=false /> diff --git a/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.vue b/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.vue index 5b021f286..6f6df03ff 100644 --- a/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.vue +++ b/src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.vue @@ -6,7 +6,7 @@ :questionText="questionText" :answers="vehicles" v-model="selectedVehicleVinAsArray" - :isRequired="true" + isRequired :validation-rules="validationRules" /> Date: Wed, 13 Jul 2022 10:13:11 -0400 Subject: [PATCH 12/13] correct GA event logging in dev --- src/constants/analytics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants/analytics.js b/src/constants/analytics.js index a3f057150..d4ac3d2ea 100644 --- a/src/constants/analytics.js +++ b/src/constants/analytics.js @@ -5,7 +5,7 @@ const analyticsPageEvents = { // GA Constants const GaEvents = { - GENERIC_EVENT: 'ga_Event', + GENERIC_EVENT: 'event', PAGE_VIEW_EVENT : 'logPageview' }; From 8f750e8c1d95fac31bb51aa2d5ac2a0f1d6c5400 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Wed, 13 Jul 2022 10:16:24 -0400 Subject: [PATCH 13/13] CSR-706 | Fixing test --- src/store/index.js | 13 ------------- src/store/store.spec.js | 7 ++++++- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index f29fba5de..bac95e3cf 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -504,19 +504,6 @@ export const actions = { context.commit(storeMutations.UPDATE_CRM_CUSTOMER_ID, crmCustomerId); }, - logExperimentExposure(context, { userId, sessionKey, pageName, universeName }) { - return globalMethods.callHttpClient({ - method: endpoints.LogExperimentExposureIfAssigned.method, - endpoint: endpoints.LogExperimentExposureIfAssigned.url, - payload: { - userId: userId, - sessionKey: sessionKey, - pageName: pageName, - universeName: universeName - } - }); - }, - logPageView(context, { userId, sessionKey, pageName, sessionId, action, event, shouldUseSessionId }) { var payload = { userId: userId, diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 3cd3e768f..a9e37dea7 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -571,12 +571,17 @@ describe("Actions", () => { registration: {} }, damage: {}, + applicationUser: { + lastPageVisited: "test-page", + crmCustomerId: "xxx-xxx-xxx", + saveQuoteId: "xxx-xxx-xxx" + } }; context.state = { order: { serviceLocation: {}, customer: {} - } + }, }; globalMethods.callHttpClient.mockImplementation(() => {