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-make/make-question/make-question.vue b/src/layouts/vehicle-make/make-question/make-question.vue index c84c1cdbf..d0046fe30 100644 --- a/src/layouts/vehicle-make/make-question/make-question.vue +++ b/src/layouts/vehicle-make/make-question/make-question.vue @@ -8,7 +8,7 @@ groupName="ChooseVehicleMake" textPosition="text-start" v-model="selectedValue" - isRequired=true + isRequired /> 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 /> diff --git a/src/router/index.js b/src/router/index.js index c6ce3bd28..8b9328db0 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]); @@ -152,9 +155,9 @@ async function navigate(scenario, currentRoute, optionalQuery = {}, optionalPara // 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.order.customer?.emailAddress) { + saveOrder(); } router.push({ 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..bac95e3cf 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, @@ -63,7 +64,11 @@ const getDefaultState = () => { applicationUser: { eventBus: [], pageData: {}, - savedSessionTimeout: getDateForSavedSessionTimeout() + savedSessionTimeout: getDateForSavedSessionTimeout(), + saveOrderPromise: null, + saveQuoteId: null, + crmCustomerId: null, + lastPageVisited: null, }, } }; @@ -112,6 +117,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; }, @@ -196,6 +204,19 @@ export const mutations = { state.order.serviceLocation.zipCode = serviceLocationInfo.zipCode; }, + // applicationUser MUTATIONS + updateSaveOrderPromise(state, saveOrderPromise){ + state.applicationUser.saveOrderPromise = saveOrderPromise; + }, + updateSaveQuoteId(state, saveQuoteId) { + state.applicationUser.saveQuoteId = saveQuoteId; + }, + 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); @@ -472,6 +493,17 @@ export const actions = { } }); }, + + // Misc Actions + 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); + }, + logPageView(context, { userId, sessionKey, pageName, sessionId, action, event, shouldUseSessionId }) { var payload = { userId: userId, @@ -555,7 +587,7 @@ export const actions = { }); }, - // Parts API Actions + // PartsOrQuestions API Actions getPartsOrQuestions(context) { const vehicle = context.getters.vehicle; const damage = context.getters.damage; @@ -578,11 +610,37 @@ 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; const damage = context.getters.damage; const order = context.state.order; + const applicationUser = context.getters.applicationUser; return globalMethods.callHttpClient({ method: endpoints.SaveOrder.method, @@ -621,7 +679,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, + }, }); }, @@ -787,6 +850,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) { diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 960a6d784..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(() => { @@ -611,7 +616,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 +624,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 () => { diff --git a/src/ux-components/list-button/list-button.vue b/src/ux-components/list-button/list-button.vue index 861619093..0c347de52 100644 --- a/src/ux-components/list-button/list-button.vue +++ b/src/ux-components/list-button/list-button.vue @@ -6,8 +6,7 @@ @keyup.up="handleKeyupArrow()" @keyup.down="handleKeyupArrow()" @keyup.left="handleKeyupArrow()" - @keyup.right="handleKeyupArrow()" - > + @keyup.right="handleKeyupArrow()">