From 893544d709e4127279f1e1136535a1d63696bcf5 Mon Sep 17 00:00:00 2001 From: Oh Date: Tue, 1 Mar 2022 12:18:56 -0500 Subject: [PATCH 01/64] CSR-98 Try basic routing --- src/layouts/vehicle-damage/vehicle-damage.vue | 9 ++++++++- src/router/router-constants/navigation-scenarios.js | 1 + src/router/router-constants/routing-table.js | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index aa888e14a..203e46abb 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" /> - + @@ -137,6 +137,13 @@ export default { this.$route ); }, + forwardButtonAction() { + console.log("Get estimate!") + this.$router.navigate( + this.navigationScenarios.CLICKED_FORWARD, + this.$route + ); + } }, components: { funnelHeader, diff --git a/src/router/router-constants/navigation-scenarios.js b/src/router/router-constants/navigation-scenarios.js index 48e36996b..338998d0d 100644 --- a/src/router/router-constants/navigation-scenarios.js +++ b/src/router/router-constants/navigation-scenarios.js @@ -4,6 +4,7 @@ const navigationScenarios = { SELECTED_MAKE: "SELECTED_MAKE", SELECTED_STYLE: "SELECTED_STYLE", CLICKED_BACK: "CLICKED_BACK", + CLICKED_FORWARD: "CLICKED_FORWARD" }; export { navigationScenarios }; diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 88c47563c..600def25d 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -57,6 +57,10 @@ const routingTable = [ scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE, }, + { + scenario: navigationScenarios.CLICKED_FORWARD, + destinationUrl: "http://localhost:38000/default.aspx", + }, ], }, ]; From 6ce8bbec8a3b29ca7bf2d0b19cf87fdbd80dd3db Mon Sep 17 00:00:00 2001 From: Katie Date: Tue, 8 Mar 2022 17:24:10 -0500 Subject: [PATCH 02/64] 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", From 2f12273f57ec85f8e5482851151a1ef5ab9532f7 Mon Sep 17 00:00:00 2001 From: FrankRua Date: Wed, 9 Mar 2022 14:03:36 -0500 Subject: [PATCH 03/64] Parameter on navigate --- src/router/index.js | 5 +++-- src/router/router-constants/router-parameter-keys.js | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index be434e9d8..3d182ba37 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,10 +1,11 @@ // Supporting files import { createWebHistory, createRouter } from "vue-router"; import { storeActions } from "@/constants/store-actions"; -import baseMixin from "@/mixins/base-mixin"; import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js"; import { routingTable } from "@/router/router-constants/routing-table.js"; import { globalEvents, globalEventTypes } from "@/constants/events"; +import { routerParameterKeys } from '@/router/router-constants/router-parameter-keys' +import baseMixin from "@/mixins/base-mixin"; import eventBus from "@/helpers/event-bus/event-bus"; import store from "@/store"; @@ -153,7 +154,7 @@ function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {}, query: Object.assign(optionalQuery, { fmgPage: matchingScenarioMap.destinationFmgPageValue, }), - params: optionalParams, + params: Object.assign(optionalParams, {[routerParameterKeys.FROM_ROUTER_NAVIGATE]: true}) }); } else if (matchingScenarioMap.destinationUrl !== undefined) { navigateToUrl(matchingScenarioMap.destinationUrl); diff --git a/src/router/router-constants/router-parameter-keys.js b/src/router/router-constants/router-parameter-keys.js index 0c75eb738..7ace86f37 100644 --- a/src/router/router-constants/router-parameter-keys.js +++ b/src/router/router-constants/router-parameter-keys.js @@ -1,3 +1,5 @@ -const routerParameterKeys = { }; +const routerParameterKeys = { + FROM_ROUTER_NAVIGATE: 'fromRouterNavigate', + }; export { routerParameterKeys }; \ No newline at end of file From d1fb7db451ffef37b840c62c06aebc7c37b86b7b Mon Sep 17 00:00:00 2001 From: Katie Date: Fri, 11 Mar 2022 12:22:35 -0500 Subject: [PATCH 04/64] CSR-98 Read cookie values and remove as needed --- src/constants/store-actions.js | 1 + src/constants/store-mutations.js | 1 + src/mixins/base-mixin.js | 25 ++++--- src/router/index.js | 24 ++++++- src/router/router-constants/routing-table.js | 5 +- src/store/index.js | 68 +++++++++++--------- 6 files changed, 80 insertions(+), 44 deletions(-) diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index e5d57cdf1..84ecf77e6 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -19,6 +19,7 @@ const storeActions = { RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies", RESET_REGISTRATION_STATE_AND_DEPENDENCIES: "resetRegistrationAndDependencies", RESET_PARTS_STATE_AND_DEPENDENCIES: "resetPartsAndDependencies", + RESET_STATE: "resetState", }; export { storeActions }; diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 838018590..d6ee3b321 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -29,6 +29,7 @@ const storeMutations = { RESET_DAMAGE_STATE: "resetDamageState", RESET_REGISTRATION_STATE: "resetRegistrationState", RESET_PARTS_STATE: "resetPartsState", + RESET_STATE: "resetState", // OTHER MUTATIONS UPDATE_PAGE_DATA: "updatePageData", diff --git a/src/mixins/base-mixin.js b/src/mixins/base-mixin.js index 47407c81f..5543c681c 100644 --- a/src/mixins/base-mixin.js +++ b/src/mixins/base-mixin.js @@ -5,7 +5,6 @@ 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() { @@ -28,14 +27,21 @@ export default { 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() + }, + getCookieValue(cookieName) { + return document.cookie + ?.split("; ") + ?.find(row => row.startsWith(`${cookieName}=`)) + ?.split("=")[1]; + }, + setCookieValue(cookieName, cookieValue) { + document.cookie = `${cookieName}=${cookieValue}`; + }, + deleteCookie(cookieName) { + console.log("D") + document.cookie = `${cookieName}=; Max-Age=0; path=/; domain=${location.hostname}`; }, navigateToHeritageFunnel() { - console.log("Get estimate!") var referralCorrelationId = store.getters.referralCorrelationId; router.navigate( @@ -43,7 +49,10 @@ export default { router.currentRoute.value, { corid: referralCorrelationId, - src: "concept-funnel" + src: "concept-funnel", + // TODO CSR-98 REMOVE THIS + cns: "all", + experiments: "ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true" } ); } diff --git a/src/router/index.js b/src/router/index.js index 33b7190ad..ba1725bd3 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -50,6 +50,24 @@ const routes = [ path: "/", name: "root", async beforeEnter(to, from, next) { + // TODO CSR-98 Also triggers on refresh... should it though? + // Entering the concept funnel + if (from.redirectedFrom === undefined) { + // TODO CSR-98 Don't hardcode cookie name "OrderInfo" + var orderInfoJson = baseMixin.methods.getCookieValue("OrderInfo"); + var orderInfo = orderInfoJson == null ? null : JSON.parse(orderInfoJson); + + if (orderInfo?.ShouldResetState) { + store.dispatch(storeActions.RESET_STATE); + } + else { + // should load referral here + } + + // Delete cookie once state is loaded or reset + baseMixin.methods.deleteCookie("OrderInfo"); + } + // If we have no query string, or we don't have the FmgPage query string. if (to.query.fmgPage === undefined) { await GoToFunnelStartOn404(next); @@ -57,7 +75,6 @@ const routes = [ try { // If we already have our route, go to it. if (router.hasRoute(to.query.fmgPage)) { - // Since our route is already in scope, we can grab the component from it and call the arePagePrerequisitesValid function. let component = router.getRoutes().filter((x) => x.name === to.query.fmgPage)[0].components; @@ -152,8 +169,9 @@ function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {}, baseMixin.methods.savePageDataToStore(matchingScenarioMap.destinationFmgPageValue, optionalPageData); // TODO CSR-98 don't hardcode this - if (currentRoute.name == "vehicle-damage") - baseMixin.methods.navigateToHeritageFunnel() + if (currentRoute.name == "vehicle-damage") { + baseMixin.methods.navigateToHeritageFunnel(); + } else { router.push({ name: "root", diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 766f4f95a..e4c657a1d 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -85,15 +85,12 @@ const routingTable = [ }, { scenario: navigationScenarios.SELECTED_PARTS, -<<<<<<< HEAD destinationFmgPageValue: fmgPageValues.QUOTE, }, { scenario: navigationScenarios.CLICKED_FORWARD, - destinationUrl: externalUrls.HERITAGE_FUNNEL, -======= + // destinationUrl: externalUrls.HERITAGE_FUNNEL, destinationFmgPageValue: fmgPageValues.REVEAL, ->>>>>>> develop }, ], }, diff --git a/src/store/index.js b/src/store/index.js index 6097d5896..8e5e801c5 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -7,37 +7,41 @@ import globalMethods from "@/global-methods"; // Export State -export const state = { - order: { - vehicle: { - year: null, - make: null, - model: null, - style: null, - carId: null, - category: null, - imageUrl: null, - imageVifNumber: null, - imageColor: null, +const getDefaultState = () => { + return { + order: { + vehicle: { + year: null, + make: null, + model: null, + style: null, + carId: null, + category: null, + imageUrl: null, + imageVifNumber: null, + imageColor: null, + }, + damage: { + isRepair: null, + numberOfChips: null, + glassToReplace: null, + }, + lineItems:{ + glassParts: null, + otherParts: null + }, + referralNumber: null, + referralDate: null, + referralCorrelationId: null, }, - damage: { - isRepair: null, - numberOfChips: null, - glassToReplace: null, + applicationUser: { + eventBus: [], + pageData: {} }, - lineItems:{ - glassParts: null, - otherParts: null - }, - referralNumber: null, - referralDate: null, - referralCorrelationId: null, - }, - applicationUser: { - eventBus: [], - pageData: {} - }, -} + } +}; + +export const state = getDefaultState(); // Export Mutations export const mutations = { @@ -136,6 +140,9 @@ export const mutations = { resetPartsState(state) { state.order.lineItems.glassParts = null; state.order.lineItems.otherParts = null; + }, + resetState(state) { + Object.assign(state, getDefaultState()); } } @@ -249,6 +256,9 @@ export const actions = { resetPartsAndDependencies(context) { context.commit(storeMutations.RESET_PARTS_STATE); }, + resetState(context) { + context.commit(storeMutations.RESET_STATE); + }, // Content API Actions getRouteInfo(context, { pageName }) { From 399624af8d97436f2982af6163dc63c549046033 Mon Sep 17 00:00:00 2001 From: Katie Date: Tue, 15 Mar 2022 15:17:38 -0400 Subject: [PATCH 05/64] CSR-98 Add variable for cookieName OrderInfo --- src/constants/cookie-names.js | 6 ++ src/layouts/vehicle-damage/vehicle-damage.vue | 6 ++ src/mixins/base-mixin.js | 3 +- src/mixins/base-mixin.spec.js | 2 + src/router/index.js | 67 ++++++++++--------- .../router-constants/navigation-scenarios.js | 3 +- src/router/router-constants/routing-table.js | 4 +- 7 files changed, 56 insertions(+), 35 deletions(-) create mode 100644 src/constants/cookie-names.js diff --git a/src/constants/cookie-names.js b/src/constants/cookie-names.js new file mode 100644 index 000000000..33a76ae43 --- /dev/null +++ b/src/constants/cookie-names.js @@ -0,0 +1,6 @@ +const cookieNames = { + ORDER_INFO: "OrderInfo" +}; + +export { cookieNames }; + \ No newline at end of file diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index df457d24c..aeb4e8ac6 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -294,6 +294,12 @@ export default { }, navigateForward(partsData){ + // CSR-98 TEMP + if (store.getters.vehicle.year == 2010) { + this.navigateToHeritageFunnel(); + return; + } + //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 5543c681c..8fdd6dd8d 100644 --- a/src/mixins/base-mixin.js +++ b/src/mixins/base-mixin.js @@ -38,14 +38,13 @@ export default { document.cookie = `${cookieName}=${cookieValue}`; }, deleteCookie(cookieName) { - console.log("D") document.cookie = `${cookieName}=; Max-Age=0; path=/; domain=${location.hostname}`; }, navigateToHeritageFunnel() { var referralCorrelationId = store.getters.referralCorrelationId; router.navigate( - navigationScenarios.CLICKED_FORWARD, + navigationScenarios.MOVE_TO_HERITAGE_FUNNEL, router.currentRoute.value, { corid: referralCorrelationId, diff --git a/src/mixins/base-mixin.spec.js b/src/mixins/base-mixin.spec.js index da684af1b..e1599a319 100644 --- a/src/mixins/base-mixin.spec.js +++ b/src/mixins/base-mixin.spec.js @@ -79,6 +79,8 @@ describe("baseMixin.js", () => { }); }); + + function getMixInInstance({ isDispatchSuccess = true }) { // Mock Store const storeDispatch = jest.fn(); diff --git a/src/router/index.js b/src/router/index.js index ba1725bd3..8d9876a74 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -7,6 +7,7 @@ import { routingTable } from "@/router/router-constants/routing-table.js"; import { globalEvents, globalEventTypes } from "@/constants/events"; import eventBus from "@/helpers/event-bus/event-bus"; import store from "@/store"; +import { cookieNames } from "@/constants/cookie-names"; // Components import ComponentTest from "@/layouts/component-test/component-test.vue"; @@ -53,19 +54,7 @@ const routes = [ // TODO CSR-98 Also triggers on refresh... should it though? // Entering the concept funnel if (from.redirectedFrom === undefined) { - // TODO CSR-98 Don't hardcode cookie name "OrderInfo" - var orderInfoJson = baseMixin.methods.getCookieValue("OrderInfo"); - var orderInfo = orderInfoJson == null ? null : JSON.parse(orderInfoJson); - - if (orderInfo?.ShouldResetState) { - store.dispatch(storeActions.RESET_STATE); - } - else { - // should load referral here - } - - // Delete cookie once state is loaded or reset - baseMixin.methods.deleteCookie("OrderInfo"); + handleInfoFromHeritageFunnel(); } // If we have no query string, or we don't have the FmgPage query string. @@ -149,13 +138,14 @@ function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {}, return; } - // here?? CSR-98 - baseMixin.methods.saveOrder(); + // // here?? CSR-98 + // baseMixin.methods.saveOrder(); // Match our maps up and navigate if we have a destination. const matchingScenarioMap = getNavigationMap(scenario, currentRoute); + const destinationFmgPageValue = matchingScenarioMap.destinationFmgPageValue; - if (matchingScenarioMap.destinationFmgPageValue !== undefined) { + if (destinationFmgPageValue !== undefined) { // We're always pushing the same path, just changing query strings. Make sure our optional query strings get combined with our fmgPage one. // If we need to do invalidation @@ -166,22 +156,22 @@ 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); + baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData); - // 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, - }); - } + baseMixin.methods.saveOrder(); + + router.push({ + name: "root", + query: Object.assign(optionalQuery, { + fmgPage: destinationFmgPageValue, + }), + params: optionalParams, + }); } else if (matchingScenarioMap.destinationUrl !== undefined) { + if (matchingScenarioMap.shouldNavigateToHeritageFunnel) { + baseMixin.methods.saveOrder(); + } + navigateToUrl(matchingScenarioMap.destinationUrl, optionalQuery); } } @@ -210,6 +200,7 @@ function navigateToUrl(url, optionalQuery) { for (const queryKey in optionalQuery) { externalUrl.searchParams.append(queryKey, optionalQuery[queryKey]); } + window.location.assign(externalUrl); } @@ -267,4 +258,20 @@ function resetDependentState(component) { return component.default.methods.resetDependentState(); } +// Read info from heritage funnel and reset state or load referral +function handleInfoFromHeritageFunnel() { + var orderInfoJson = baseMixin.methods.getCookieValue(cookieNames.ORDER_INFO); + var orderInfo = orderInfoJson == null ? null : JSON.parse(orderInfoJson); + + if (orderInfo?.ShouldResetState) { + store.dispatch(storeActions.RESET_STATE); + } + else if (orderInfo != null) { + // should load referral here + } + + // Delete cookie once state is loaded or reset + baseMixin.methods.deleteCookie(cookieNames.ORDER_INFO); +} + export default router; \ No newline at end of file diff --git a/src/router/router-constants/navigation-scenarios.js b/src/router/router-constants/navigation-scenarios.js index 55efdcaec..972944d80 100644 --- a/src/router/router-constants/navigation-scenarios.js +++ b/src/router/router-constants/navigation-scenarios.js @@ -8,7 +8,8 @@ const navigationScenarios = { SELECTED_PARTS: "SELECTED_PARTS", SELECTED_DAMAGE_WITH_SINGLE_PART: "SELECTED_DAMAGE_WITH_SINGLE_PART", SELECTED_DAMAGE_WITH_MULTIPLE_PARTS: "SELECTED_DAMAGE_WITH_MULTIPLE_PARTS", - SELECTED_DAMAGE_WITH_PART_QUESTIONS: "SELECTED_DAMAGE_WITH_PART_QUESTIONS" + SELECTED_DAMAGE_WITH_PART_QUESTIONS: "SELECTED_DAMAGE_WITH_PART_QUESTIONS", + MOVE_TO_HERITAGE_FUNNEL: "MOVE_TO_HERITAGE_FUNNEL", }; export { navigationScenarios }; diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 70e47c832..8fc8ad013 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -59,8 +59,9 @@ const routingTable = [ destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE, }, { - scenario: navigationScenarios.CLICKED_FORWARD, + scenario: navigationScenarios.MOVE_TO_HERITAGE_FUNNEL, destinationUrl: externalUrls.HERITAGE_FUNNEL, + shouldNavigateToHeritageFunnel: true }, { scenario: navigationScenarios.SELECTED_DAMAGE_WITH_SINGLE_PART, @@ -89,7 +90,6 @@ const routingTable = [ }, { scenario: navigationScenarios.CLICKED_FORWARD, - // destinationUrl: externalUrls.HERITAGE_FUNNEL, destinationFmgPageValue: fmgPageValues.REVEAL, }, ], From 6a17e122eabdf69dcbb46cdb90838f679065fdca Mon Sep 17 00:00:00 2001 From: Katie Date: Tue, 15 Mar 2022 16:13:29 -0400 Subject: [PATCH 06/64] CSR-98 Move functions into heritage-integration-helper --- src/helpers/heritage-integration-helper.js | 57 +++++++++++++++++++ .../heritage-integration-helper.spec.js | 41 +++++++++++++ src/layouts/vehicle-damage/vehicle-damage.vue | 3 +- src/mixins/base-mixin.js | 33 ----------- src/mixins/base-mixin.spec.js | 5 +- src/router/index.js | 22 +------ 6 files changed, 106 insertions(+), 55 deletions(-) create mode 100644 src/helpers/heritage-integration-helper.js create mode 100644 src/helpers/heritage-integration-helper.spec.js diff --git a/src/helpers/heritage-integration-helper.js b/src/helpers/heritage-integration-helper.js new file mode 100644 index 000000000..95ee7ef09 --- /dev/null +++ b/src/helpers/heritage-integration-helper.js @@ -0,0 +1,57 @@ +import { storeActions } from "@/constants/store-actions.js"; +import { storeMutations } from "@/constants/store-mutations.js"; +import { cookieNames } from "@/constants/cookie-names"; +import store from "@/store"; +import router from "@/router"; +import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; +import baseMixin from "../mixins/base-mixin"; + +// Read info from heritage funnel and reset state or load referral +export function handleInfoFromHeritageFunnel() { + var orderInfoJson = getHeritageCookieValue(); + var orderInfo = orderInfoJson == null ? null : JSON.parse(orderInfoJson); + + if (orderInfo?.ShouldResetState) { + store.dispatch(storeActions.RESET_STATE); + } + else if (orderInfo != null) { + // should load referral here + } + + // Delete cookie once state is loaded or reset + deleteHeritageCookie(); +} + +export function navigateToHeritageFunnel() { + var referralCorrelationId = store.getters.referralCorrelationId; + + router.navigate( + navigationScenarios.MOVE_TO_HERITAGE_FUNNEL, + router.currentRoute.value, + { + corid: referralCorrelationId, + src: "concept-funnel", + // TODO CSR-98 REMOVE THIS + cns: "all", + experiments: "ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true" + } + ); +} + +export async function saveOrder() { + var savedOrderInfo = (await baseMixin.methods.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); +} + +export function getHeritageCookieValue() { + return document.cookie + ?.split("; ") + ?.find(row => row.startsWith(`${cookieNames.ORDER_INFO}=`)) + ?.split("=")[1]; +} + +export function deleteHeritageCookie() { + document.cookie = `${cookieNames.ORDER_INFO}=; Max-Age=0; path=/; domain=${location.hostname}`; +} \ No newline at end of file diff --git a/src/helpers/heritage-integration-helper.spec.js b/src/helpers/heritage-integration-helper.spec.js new file mode 100644 index 000000000..9f49b4565 --- /dev/null +++ b/src/helpers/heritage-integration-helper.spec.js @@ -0,0 +1,41 @@ + + // test("getCookieValue: Gets correct cookie value", () => { + // // Arrange + // const mixIn = getMixInInstance({}); + // const testCookieName = "testCookie"; + // const testCookieValue = "testCookieValue"; + + // document.cookie = `yearMakeModel=2020 ACURA MDX;`; + // document.cookie = `SavedQuoteID=d2770645-0680-4852-9649-6170659b1bd6;`; + // document.cookie = `${testCookieName}=${testCookieValue};`; + // document.cookie = `EMBEDDEDPAYMENTPAGE_PAYPAL_SUBMITBUTTON=COMPLETED;`; + // document.cookie = `orderconfirmation=7411543;`; + + // console.log(document.cookie) + + // // Act + // const actualCookieValue = mixIn.methods.getCookieValue(testCookieName); + + // // Assert + // expect(actualCookieValue).toEqual(testCookieValue); + // expect(document.cookie).toEqual(`yearMakeModel=2020 ACURA MDX; SavedQuoteID=d2770645-0680-4852-9649-6170659b1bd6; ${testCookieName}=${testCookieValue}; EMBEDDEDPAYMENTPAGE_PAYPAL_SUBMITBUTTON=COMPLETED; orderconfirmation=7411543`); + // clearCookies(); + // }); + + // test("getCookieValue: Gets undefined cookie value", () => { + // // Arrange + // const mixIn = getMixInInstance({}); + // const testCookieName = "testCookie"; + + // document.cookie = `yearMakeModel=2020 ACURA MDX;`; + // document.cookie = `SavedQuoteID=d2770645-0680-4852-9649-6170659b1bd6;`; + // document.cookie = `EMBEDDEDPAYMENTPAGE_PAYPAL_SUBMITBUTTON=COMPLETED;`; + // document.cookie = `orderconfirmation=7411543;`; + + // // Act + // const actualCookieValue = mixIn.methods.getCookieValue(testCookieName); + + // // Assert + // expect(actualCookieValue).toEqual(undefined); + // expect(document.cookie).toEqual(`yearMakeModel=2020 ACURA MDX; SavedQuoteID=d2770645-0680-4852-9649-6170659b1bd6; EMBEDDEDPAYMENTPAGE_PAYPAL_SUBMITBUTTON=COMPLETED; orderconfirmation=7411543;`); + // }); \ No newline at end of file diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index aeb4e8ac6..d2d786d5d 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -77,6 +77,7 @@ import { required } from "@/helpers/validation-rules"; import { errorMessages } from "@/constants/error-messages"; import { damageLocationsCms } from "@/constants/damage-locations-cms.js"; import { damageLocationsSelected } from "@/constants/damage-locations-selected.js"; +import { navigateToHeritageFunnel } from "@/helpers/heritage-integration-helper"; // DEFINE VALIDATION RULES defineRule("replace-options-required", required(errorMessages.REPLACE_OPTIONS_REQUIRED)); @@ -296,7 +297,7 @@ export default { navigateForward(partsData){ // CSR-98 TEMP if (store.getters.vehicle.year == 2010) { - this.navigateToHeritageFunnel(); + navigateToHeritageFunnel(); return; } diff --git a/src/mixins/base-mixin.js b/src/mixins/base-mixin.js index 8fdd6dd8d..af2eb1c2a 100644 --- a/src/mixins/base-mixin.js +++ b/src/mixins/base-mixin.js @@ -22,39 +22,6 @@ 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); - }, - getCookieValue(cookieName) { - return document.cookie - ?.split("; ") - ?.find(row => row.startsWith(`${cookieName}=`)) - ?.split("=")[1]; - }, - setCookieValue(cookieName, cookieValue) { - document.cookie = `${cookieName}=${cookieValue}`; - }, - deleteCookie(cookieName) { - document.cookie = `${cookieName}=; Max-Age=0; path=/; domain=${location.hostname}`; - }, - navigateToHeritageFunnel() { - var referralCorrelationId = store.getters.referralCorrelationId; - - router.navigate( - navigationScenarios.MOVE_TO_HERITAGE_FUNNEL, - router.currentRoute.value, - { - corid: referralCorrelationId, - src: "concept-funnel", - // TODO CSR-98 REMOVE THIS - cns: "all", - experiments: "ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true" - } - ); - } }, computed: { storeActions() { diff --git a/src/mixins/base-mixin.spec.js b/src/mixins/base-mixin.spec.js index e1599a319..8c33a5774 100644 --- a/src/mixins/base-mixin.spec.js +++ b/src/mixins/base-mixin.spec.js @@ -79,8 +79,6 @@ describe("baseMixin.js", () => { }); }); - - function getMixInInstance({ isDispatchSuccess = true }) { // Mock Store const storeDispatch = jest.fn(); @@ -103,6 +101,9 @@ function getMixInInstance({ isDispatchSuccess = true }) { baseMixIn.methods.$route = route; baseMixIn.methods.storeActions = storeActions; baseMixIn.methods.widgetNames = widgetNames; + baseMixin.document = { + cookie: "" + } store.dispatch = storeDispatch; store.commit = jest.fn(); diff --git a/src/router/index.js b/src/router/index.js index 8d9876a74..7f90a733c 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -7,7 +7,7 @@ import { routingTable } from "@/router/router-constants/routing-table.js"; import { globalEvents, globalEventTypes } from "@/constants/events"; import eventBus from "@/helpers/event-bus/event-bus"; import store from "@/store"; -import { cookieNames } from "@/constants/cookie-names"; +import { handleInfoFromHeritageFunnel, saveOrder, } from "@/helpers/heritage-integration-helper"; // Components import ComponentTest from "@/layouts/component-test/component-test.vue"; @@ -158,7 +158,7 @@ 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); - baseMixin.methods.saveOrder(); + saveOrder(); router.push({ name: "root", @@ -169,7 +169,7 @@ function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {}, }); } else if (matchingScenarioMap.destinationUrl !== undefined) { if (matchingScenarioMap.shouldNavigateToHeritageFunnel) { - baseMixin.methods.saveOrder(); + saveOrder(); } navigateToUrl(matchingScenarioMap.destinationUrl, optionalQuery); @@ -258,20 +258,4 @@ function resetDependentState(component) { return component.default.methods.resetDependentState(); } -// Read info from heritage funnel and reset state or load referral -function handleInfoFromHeritageFunnel() { - var orderInfoJson = baseMixin.methods.getCookieValue(cookieNames.ORDER_INFO); - var orderInfo = orderInfoJson == null ? null : JSON.parse(orderInfoJson); - - if (orderInfo?.ShouldResetState) { - store.dispatch(storeActions.RESET_STATE); - } - else if (orderInfo != null) { - // should load referral here - } - - // Delete cookie once state is loaded or reset - baseMixin.methods.deleteCookie(cookieNames.ORDER_INFO); -} - export default router; \ No newline at end of file From 0d6571abf716c53fd10c2cfbc5111daa6e7966cd Mon Sep 17 00:00:00 2001 From: Katie Date: Thu, 17 Mar 2022 08:28:37 -0400 Subject: [PATCH 07/64] CSR-98 Add experiments to query string for testing --- src/helpers/heritage-integration-helper.js | 2 +- src/helpers/unit-test-helper.js | 1 - src/mixins/base-mixin.spec.js | 3 --- src/router/index.js | 4 ++-- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/helpers/heritage-integration-helper.js b/src/helpers/heritage-integration-helper.js index 95ee7ef09..12cba038b 100644 --- a/src/helpers/heritage-integration-helper.js +++ b/src/helpers/heritage-integration-helper.js @@ -33,7 +33,7 @@ export function navigateToHeritageFunnel() { src: "concept-funnel", // TODO CSR-98 REMOVE THIS cns: "all", - experiments: "ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true" + experiments: "RemoveServiceAreaPage=ServAreaRemoval_V7=ServAreaNoRemove_V7_TEST=true,ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true" } ); } diff --git a/src/helpers/unit-test-helper.js b/src/helpers/unit-test-helper.js index 1509a4b16..561798629 100644 --- a/src/helpers/unit-test-helper.js +++ b/src/helpers/unit-test-helper.js @@ -49,7 +49,6 @@ export function getMountOptions(mockData) { mocks.$router = mockData.router; mocks.$route = mockData.route; - const global = { mocks: mocks, }; diff --git a/src/mixins/base-mixin.spec.js b/src/mixins/base-mixin.spec.js index 8c33a5774..da684af1b 100644 --- a/src/mixins/base-mixin.spec.js +++ b/src/mixins/base-mixin.spec.js @@ -101,9 +101,6 @@ function getMixInInstance({ isDispatchSuccess = true }) { baseMixIn.methods.$route = route; baseMixIn.methods.storeActions = storeActions; baseMixIn.methods.widgetNames = widgetNames; - baseMixin.document = { - cookie: "" - } store.dispatch = storeDispatch; store.commit = jest.fn(); diff --git a/src/router/index.js b/src/router/index.js index 7f90a733c..a49d416aa 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -132,7 +132,7 @@ router.navigateAfterSave = (scenario, currentRoute, optionalQuery = {}, optional // PRIVATE FUNCTIONS // Navigate to the next route, depending on the scenario. -function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) { +async function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) { if (!scenario) { console.error("No scenario provided. Please review the routing table."); return; @@ -169,7 +169,7 @@ function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {}, }); } else if (matchingScenarioMap.destinationUrl !== undefined) { if (matchingScenarioMap.shouldNavigateToHeritageFunnel) { - saveOrder(); + await saveOrder(); } navigateToUrl(matchingScenarioMap.destinationUrl, optionalQuery); From f4a6cc66cfc574b277a73e5d7dab8818199c77ad Mon Sep 17 00:00:00 2001 From: Katie Date: Thu, 17 Mar 2022 16:12:20 -0400 Subject: [PATCH 08/64] CSR-98 Check and edit cookie info as needed --- src/helpers/heritage-integration-helper.js | 37 ++++++++++++++++------ src/router/index.js | 4 +-- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/helpers/heritage-integration-helper.js b/src/helpers/heritage-integration-helper.js index 12cba038b..68cb2484e 100644 --- a/src/helpers/heritage-integration-helper.js +++ b/src/helpers/heritage-integration-helper.js @@ -8,18 +8,16 @@ import baseMixin from "../mixins/base-mixin"; // Read info from heritage funnel and reset state or load referral export function handleInfoFromHeritageFunnel() { - var orderInfoJson = getHeritageCookieValue(); - var orderInfo = orderInfoJson == null ? null : JSON.parse(orderInfoJson); + var orderInfo = getHeritageCookieValue(); if (orderInfo?.ShouldResetState) { store.dispatch(storeActions.RESET_STATE); - } - else if (orderInfo != null) { - // should load referral here + deleteHeritageCookie(); } - // Delete cookie once state is loaded or reset - deleteHeritageCookie(); + if (orderInfo?.DidHeritageFunnelUpdateLast) { + // Load referral here + } } export function navigateToHeritageFunnel() { @@ -43,15 +41,36 @@ export async function saveOrder() { 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); + + setDidHeritageFunnelUpdateLastInHeritageCookie(false); } +/* Start cookie related functions */ export function getHeritageCookieValue() { - return document.cookie + var cookieJson = document.cookie ?.split("; ") ?.find(row => row.startsWith(`${cookieNames.ORDER_INFO}=`)) ?.split("=")[1]; + + return cookieJson == null ? null : JSON.parse(cookieJson); } export function deleteHeritageCookie() { document.cookie = `${cookieNames.ORDER_INFO}=; Max-Age=0; path=/; domain=${location.hostname}`; -} \ No newline at end of file +} + +function setHeritageCookieValue(cookieValue) { + var cookieValueJson = JSON.stringify(cookieValue); + document.cookie = `${cookieNames.ORDER_INFO}=${cookieValueJson}; path=/`; +} + +function setDidHeritageFunnelUpdateLastInHeritageCookie(didHeritageFunnelUpdateLast) { + var cookie = getHeritageCookieValue(); + + if (cookie != null) { + cookie.DidHeritageFunnelUpdateLast = false; + + setHeritageCookieValue(cookie); + } +} +/* End cookie related functions */ \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index d9d03e213..c77285677 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -52,9 +52,9 @@ const routes = [ path: "/", name: "root", async beforeEnter(to, from, next) { - // TODO CSR-98 Also triggers on refresh... should it though? - // Entering the concept funnel + // On entering the concept funnel if (from.redirectedFrom === undefined) { + // Read cookie information, decide what to do next handleInfoFromHeritageFunnel(); } From 442125ed650c90d2ca9e56b4964e4c22c89e5688 Mon Sep 17 00:00:00 2001 From: Katie Date: Thu, 17 Mar 2022 16:50:58 -0400 Subject: [PATCH 09/64] CSR-98 Refactor cookie code --- src/helpers/heritage-integration-helper.js | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/helpers/heritage-integration-helper.js b/src/helpers/heritage-integration-helper.js index 68cb2484e..eda55a063 100644 --- a/src/helpers/heritage-integration-helper.js +++ b/src/helpers/heritage-integration-helper.js @@ -14,9 +14,12 @@ export function handleInfoFromHeritageFunnel() { store.dispatch(storeActions.RESET_STATE); deleteHeritageCookie(); } - - if (orderInfo?.DidHeritageFunnelUpdateLast) { + else if (orderInfo?.DidHeritageFunnelUpdateLast) { // Load referral here + + // setHeritageCookieProperties({ + // ShouldResetState: false + // }) } } @@ -42,11 +45,13 @@ export async function saveOrder() { store.commit(storeMutations.UPDATE_REFERRAL_DATE, savedOrderInfo.referralDate); store.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, savedOrderInfo.referralCorrelationId); - setDidHeritageFunnelUpdateLastInHeritageCookie(false); + setHeritageCookieProperties({ + DidHeritageFunnelUpdateLast: false + }) } /* Start cookie related functions */ -export function getHeritageCookieValue() { +function getHeritageCookieValue() { var cookieJson = document.cookie ?.split("; ") ?.find(row => row.startsWith(`${cookieNames.ORDER_INFO}=`)) @@ -55,22 +60,29 @@ export function getHeritageCookieValue() { return cookieJson == null ? null : JSON.parse(cookieJson); } -export function deleteHeritageCookie() { +function deleteHeritageCookie() { document.cookie = `${cookieNames.ORDER_INFO}=; Max-Age=0; path=/; domain=${location.hostname}`; } function setHeritageCookieValue(cookieValue) { - var cookieValueJson = JSON.stringify(cookieValue); + let cookieValueJson = cookieValue; + if (typeof cookieValue == "object") + cookieValueJson = JSON.stringify(cookieValue); + document.cookie = `${cookieNames.ORDER_INFO}=${cookieValueJson}; path=/`; } -function setDidHeritageFunnelUpdateLastInHeritageCookie(didHeritageFunnelUpdateLast) { - var cookie = getHeritageCookieValue(); +function setHeritageCookieProperties(properties) { + if (typeof properties == "object") { + let cookie = getHeritageCookieValue(); - if (cookie != null) { - cookie.DidHeritageFunnelUpdateLast = false; - - setHeritageCookieValue(cookie); + if (cookie != null) { + Object.keys(properties).forEach(key => { + cookie[key] = properties[key]; + }); + + setHeritageCookieValue(cookie); + } } } /* End cookie related functions */ \ No newline at end of file From 10bad18b5689e31e344b50aed9c3f3aaf74e0807 Mon Sep 17 00:00:00 2001 From: bmauger Date: Fri, 18 Mar 2022 12:18:43 -0400 Subject: [PATCH 10/64] WIP Do not merge. --- src/layouts/vin-lookup/vin-lookup.vue | 78 ++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 8dbb6cdc9..2920be727 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -1,9 +1,8 @@