From 6ce8bbec8a3b29ca7bf2d0b19cf87fdbd80dd3db Mon Sep 17 00:00:00 2001 From: Katie Date: Tue, 8 Mar 2022 17:24:10 -0500 Subject: [PATCH] CSR-98 Save on every page and redirect to heritage funnel on one --- src/constants/store-mutations.js | 5 +++ src/global-methods.js | 10 +++++- src/layouts/vehicle-damage/vehicle-damage.vue | 21 +++--------- src/mixins/base-mixin.js | 26 +++++++++++++++ src/router/index.js | 33 +++++++++++++------ src/router/router-constants/routing-table.js | 4 +++ src/store/index.js | 20 +++++++++-- vue.config.js | 2 +- vue.release.config.js | 1 + 9 files changed, 91 insertions(+), 31 deletions(-) diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index c07e88bf2..838018590 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -15,6 +15,11 @@ const storeMutations = { UPDATE_GLASS_TO_REPLACE: "updateGlassToReplace", UPDATE_PARTS: "updateParts", + // ORDER MUTATIONS + UPDATE_REFERRAL_NUMBER: "updateReferralNumber", + UPDATE_REFERRAL_DATE: "updateReferralDate", + UPDATE_REFERRAL_CORRELATION_ID: "updateReferralCorrelationId", + // EVENT BUS MUTATIONS ADD_EVENT_TO_BUS: "addEventToBus", REMOVE_EVENT_FROM_BUS: "removeEventFromBus", diff --git a/src/global-methods.js b/src/global-methods.js index 788d4c2e4..7d82a2590 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -5,7 +5,15 @@ import httpStatusCodes from "http-status-codes"; export default { callHttpClient({ method, endpoint, payload }) { return new Promise((resolve, reject) => { - const apiGatewayUrl = applicationConfig.CONSUMER_APIGATEWAY_URL; + // TODO CSR-98 TEMP FOR TESTING + var apiGatewayUrl = applicationConfig.CONSUMER_APIGATEWAY_URL; + + if (endpoint.includes("order")) { + apiGatewayUrl = "https://localhost:44346"; + } + + + // const apiGatewayUrl = applicationConfig.CONSUMER_APIGATEWAY_URL; const payloadAndAnalyticsData = Object.assign({}, payload, { AppName: "FixMyGlass", }); diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index a5de80389..5a9eca92f 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -25,7 +25,7 @@ v-model="selectedRearReplaceOptions" groupName="BackGlassReplaceOptionsQuestion" /> - + @@ -49,6 +49,7 @@ import baseMixin from "@/mixins/base-mixin"; import { damageLocationsParts } from "@/constants/damage-locations-parts.js"; import { damageLocationsCms } from "@/constants/damage-locations-cms.js"; + export default { name: "vehicle-damage", async beforeRouteEnter(to, from, next) { @@ -129,6 +130,7 @@ export default { this.$route ); }, + async forwardButtonAction() { var windshieldChipCount = this.selectedWindshieldOptions.selectedWindshieldChipCount && this.isWindshieldDamageLocation ? this.selectedWindshieldOptions.selectedWindshieldChipCount[0] : null; @@ -143,26 +145,11 @@ export default { var partsData = await baseMixin.methods.dispatchNonBlockingStoreAction(this.storeActions.GET_PARTS_OR_QUESTIONS, { carId: store.getters.vehicle.carId, glassArray: this.selectedGlassToReplace()}, false); - - /******** START CSR-98 ********/ - var savedOrderInfo = await baseMixin.methods.dispatchNonBlockingStoreAction(this.storeActions.SAVE_ORDER); - console.log(savedOrderInfo) - /******** END CSR-98 ********/ this.navigateForward(partsData); }, + navigateForward(partsData){ - /******** START CSR-98 ********/ - console.log("Get estimate!") - - // this.$router.navigate( - // this.navigationScenarios.CLICKED_FORWARD, - // this.$route - // ); - /******** END CSR-98 ********/ - - - //found problem questions if (partsData.data.partsOrQuestions.some(pq => pq.partQuestions != null && pq.partQuestions.length > 0)){ this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_DAMAGE_WITH_PART_QUESTIONS, this.$route, {}, {}, partsData.data); diff --git a/src/mixins/base-mixin.js b/src/mixins/base-mixin.js index d46841b6a..47407c81f 100644 --- a/src/mixins/base-mixin.js +++ b/src/mixins/base-mixin.js @@ -1,9 +1,11 @@ import store from "@/store"; +import router from "@/router"; import { storeActions } from "@/constants/store-actions.js"; import { storeMutations } from "@/constants/store-mutations.js"; import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; import { widgetNames } from "@/constants/widget-names.js"; import { vehicleCategories } from "@/constants/vehicle-categories.js"; +import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; export default { data() { @@ -20,6 +22,30 @@ export default { }, savePageDataToStore(page, data){ store.commit(storeMutations.UPDATE_PAGE_DATA, { page: page, data: data }); + }, + async saveOrder() { + var savedOrderInfo = (await this.dispatchNonBlockingStoreAction(storeActions.SAVE_ORDER)).data; + store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, savedOrderInfo.referralNumber); + store.commit(storeMutations.UPDATE_REFERRAL_DATE, savedOrderInfo.referralDate); + store.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, savedOrderInfo.referralCorrelationId); + + // console.log(router) + // console.log(router.currentRoute.value.name) + // if (router.currentRoute.value.name) + // this.navigateToHeritageFunnel() + }, + navigateToHeritageFunnel() { + console.log("Get estimate!") + var referralCorrelationId = store.getters.referralCorrelationId; + + router.navigate( + navigationScenarios.CLICKED_FORWARD, + router.currentRoute.value, + { + corid: referralCorrelationId, + src: "concept-funnel" + } + ); } }, computed: { diff --git a/src/router/index.js b/src/router/index.js index 0d98f6698..c792a9bc1 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -132,6 +132,9 @@ function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {}, return; } + // here?? CSR-98 + baseMixin.methods.saveOrder(); + // Match our maps up and navigate if we have a destination. const matchingScenarioMap = getNavigationMap(scenario, currentRoute); @@ -148,15 +151,20 @@ 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(matchingScenarioMap.destinationFmgPageValue, optionalPageData); - router.push({ - name: "root", - query: Object.assign(optionalQuery, { - fmgPage: matchingScenarioMap.destinationFmgPageValue, - }), - params: optionalParams, - }); + // TODO CSR-98 don't hardcode this + if (currentRoute.name == "vehicle-damage") + baseMixin.methods.navigateToHeritageFunnel() + else { + router.push({ + name: "root", + query: Object.assign(optionalQuery, { + fmgPage: matchingScenarioMap.destinationFmgPageValue, + }), + params: optionalParams, + }); + } } else if (matchingScenarioMap.destinationUrl !== undefined) { - navigateToUrl(matchingScenarioMap.destinationUrl); + navigateToUrl(matchingScenarioMap.destinationUrl, optionalQuery); } } @@ -177,9 +185,14 @@ function getNavigationMap(scenario, currentRoute) { //---------------------------------------------------------- Private Functions ---------------------------------------------------------- // Navigate to an external url. -function navigateToUrl(url) { +function navigateToUrl(url, optionalQuery) { // possibly show some loading screen in the future here. - window.location.assign(url); + var externalUrl = new URL(url); + + for (const queryKey in optionalQuery) { + externalUrl.searchParams.append(queryKey, optionalQuery[queryKey]); + } + window.location.assign(externalUrl); } // Get route information by page name. diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 2712c53d2..a6773cd62 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -87,6 +87,10 @@ const routingTable = [ scenario: navigationScenarios.SELECTED_PARTS, destinationFmgPageValue: fmgPageValues.QUOTE, }, + { + scenario: navigationScenarios.CLICKED_FORWARD, + destinationUrl: externalUrls.HERITAGE_FUNNEL, + }, ], }, ]; diff --git a/src/store/index.js b/src/store/index.js index cbab3a84a..2ade585cc 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -29,8 +29,9 @@ export const state = { glassParts: null, otherParts: null }, - referralSeqNum: null, - correlationId: null, + referralNumber: null, + referralDate: null, + referralCorrelationId: null, }, applicationUser: { eventBus: [], @@ -83,6 +84,15 @@ export const mutations = { updatePageData(state, pageData){ state.applicationUser.pageData[pageData.page] = pageData.data; }, + updateReferralCorrelationId(state, referralCorrelationId) { + state.order.referralCorrelationId = referralCorrelationId; + }, + updateReferralNumber(state, referralNumber) { + state.order.referralNumber = referralNumber; + }, + updateReferralDate(state, referralDate) { + state.order.referralDate = referralDate; + }, // EVENT BUS MUTATIONS addEventToBus(state, event) { @@ -144,6 +154,9 @@ export const getters = { eventBus: (state) => state.applicationUser.eventBus, damage: (state) => state.order.damage, lineItems: (state) => state.order.lineItems, + referralNumber: (state) => state.order.referralNumber, + referralDate: (state) => state.order.referralDate, + referralCorrelationId: (state) => state.order.referralCorrelationId, pageData: (state) => (page) => { return state.applicationUser.pageData[page]; } @@ -300,6 +313,9 @@ export const actions = { style: vehicle.style, }, numberOfChips: damage.numberOfChips, + glassToReplace: damage.glassToReplace, + referralNumber: context.getters.referralNumber, + referralDate: context.getters.referralDate }, }); }, diff --git a/vue.config.js b/vue.config.js index 144c143bb..704ca0907 100644 --- a/vue.config.js +++ b/vue.config.js @@ -23,5 +23,5 @@ module.exports = { }, configureWebpack: { devtool: 'source-map' - } + }, }; diff --git a/vue.release.config.js b/vue.release.config.js index 43fffb47f..3c281dc78 100644 --- a/vue.release.config.js +++ b/vue.release.config.js @@ -1,4 +1,5 @@ process.env.VUE_APP_CONSUMER_API_GATEWAY = "__VUE_APP_CONSUMER_API_GATEWAY__"; +process.env.VUE_APP_HERITAGE_FUNNEL = "__VUE_APP_HERITAGE_FUNNEL__"; module.exports = { outputDir: "dist/fmg",