From b593d921ccd8d2057f048fb49f77e1c18fb0809b Mon Sep 17 00:00:00 2001 From: CarlNation Date: Fri, 3 Jan 2025 11:51:27 -0500 Subject: [PATCH 1/9] CASH-60 CASH-60 handle scenarios where the user may be using browser navigation. try to wait for promises. reset pia indicator. also add route from customer-details for pay-now scenario. the browser back/forward seems to trigger 2 scenarios on customer-details so just sending the pay-now scenario back to payment-method page instead of causing a script error --- .../customer-details/customer-details.vue | 14 ++++- src/layouts/payment/payment.vue | 53 +++++++++++++++++-- src/router/index.js | 14 ++++- src/router/router-constants/routing-table.js | 4 ++ src/store/index.js | 9 ++-- 5 files changed, 84 insertions(+), 10 deletions(-) diff --git a/src/layouts/customer-details/customer-details.vue b/src/layouts/customer-details/customer-details.vue index ccb77c184..820d5ddc1 100644 --- a/src/layouts/customer-details/customer-details.vue +++ b/src/layouts/customer-details/customer-details.vue @@ -87,6 +87,7 @@ import { required, regex } from "@/helpers/validation-rules"; import { Form, defineRule } from "vee-validate"; import { useField, validate } from "vee-validate"; import store from "@/store"; +import { paymentMethods } from "@/constants/payment-method-constants"; // DEFINE VALIDATION RULES defineRule("first-name-required", required(errorMessages.FIRST_NAME_REQUIRED)); @@ -162,7 +163,7 @@ export default { backButtonAction() { this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); }, - forwardButtonAction() { + async forwardButtonAction() { this.dispatchStoreAction( this.storeActions.SAVE_CUSTOMER_DETAILS, { @@ -181,6 +182,17 @@ export default { false ); + // if the user has resorted to using browser back/forward buttons we could have promises unresolved if they clicked back before pia work order submission. + // so attempt to wait for them to finish. + if (store.getters.order.payment.isPia) { + this.dispatchStoreAction( + storeActions.SAVE_PAYMENT_METHOD_CHOICE, + paymentMethods.NONE, + false + ); + await store.getters.applicationUser.saveSessionPromise; + } + this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD, this.$route); }, }, diff --git a/src/layouts/payment/payment.vue b/src/layouts/payment/payment.vue index 419ccbdd5..30bbb9731 100644 --- a/src/layouts/payment/payment.vue +++ b/src/layouts/payment/payment.vue @@ -483,7 +483,7 @@ export default { }, }, methods: { - arePagePrerequisitesValid() { + async arePagePrerequisitesValid() { // Service Location const serviceLocation = store.getters.order.serviceLocation; const mobileReqs = !!( @@ -532,13 +532,58 @@ export default { store.getters.order.payment.isPia !== null && (store.getters.order.payment.isPia || !!store.getters.order.payment.piaType); - return ( + const preReqResult = serviceLocationReqs && isInsuranceSet && scheduleReqs && customerReqs && - paymentMethodReqs - ); + paymentMethodReqs; + + // prettier-ignore + { + if (store.getters.applicationUser.loggingOption || !preReqResult) { + console.log("------------- payment.vue pagePrereqs start -----------------"); + console.log(new Date() + "mobileReqs:" + mobileReqs); + console.log(new Date() + "serviceLocation.address:" + serviceLocation.address); + console.log(new Date() + "serviceLocation.city:" + serviceLocation.city); + console.log(new Date() + "serviceLocation.state:" + serviceLocation.state); + console.log(new Date() + "serviceLocation.zipCode:" + serviceLocation.zipCode); + console.log(""); + console.log(new Date() + "dropOffInshopReqs:" + dropOffInshopReqs); + console.log(new Date() + "serviceLocationReqs:" + serviceLocationReqs); + console.log(new Date() + "providerLocation.streetAddress:" + providerLocation.streetAddress); + console.log(new Date() + "providerLocation.city:" + providerLocation.city); + console.log(new Date() + "providerLocation.state:" + providerLocation.state); + console.log(new Date() + "providerLocation.zipCode:" + providerLocation.zipCode); + console.log(""); + console.log(new Date() + "isInsuranceSet:" + isInsuranceSet); + console.log(""); + console.log(new Date() + "scheduleReqs:" + scheduleReqs); + console.log(new Date() + "schedule.date:" + schedule.date); + console.log(new Date() + "schedule.startTime:" + schedule.startTime); + console.log(new Date() + "schedule.endTime:" + schedule.endTime); + console.log(new Date() + "schedule.jobMaxMinutes:" + schedule.jobMaxMinutes); + console.log(new Date() + "schedule.jobMinMinutes:" + schedule.jobMinMinutes); + console.log(""); + console.log(new Date() + "customerReqs:" + customerReqs); + console.log(new Date() + "customer.firstName:" + customer.firstName); + console.log(new Date() + "customer.lastName:" + customer.lastName); + console.log(new Date() + "customer.phoneNumber:" + customer.phoneNumber); + console.log(new Date() + "customer.emailAddress:" + customer.emailAddress); + console.log(""); + console.log(new Date() + "paymentMethodReqs:" + paymentMethodReqs); + console.log(new Date() + "store.getters.order.payment.isPia:" + store.getters.order.payment.isPia); + console.log(new Date() + "store.getters.order.payment.piaType:" + store.getters.order.payment.piaType); + console.log("------------- payment.vue pagePrereqs end -------------------"); + } + } + + if (!preReqResult) { + await store.getters.applicationUser.saveSessionPromise; + this.backButtonAction(); + } + + return preReqResult; }, getWOrkOrderNumber() { if (store.getters.order.workOrderNumber) { diff --git a/src/router/index.js b/src/router/index.js index 53adc4613..22e5da6b1 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -380,6 +380,8 @@ router.navigateWithSaving = ( }; router.navigateToExternalUrl = (url, optionalQuery = {}) => { + log("------------- router navigateToExternalUrl -----------------"); + log("url:", url) navigateToUrl(url, optionalQuery); }; @@ -397,6 +399,13 @@ router.overrideNavigation = ( optionalParams = {}, optionalPageData ) => { + log("------------- router overrideNavigation -----------------"); + log("scenario:", scenario); + log("currentRoute:", currentRoute); + log("isSavingNavigation:", isSavingNavigation); + log("optionalQuery:", optionalQuery); + log("optionalParams:", optionalParams); + log("optionalPageData:", optionalPageData); navigate( scenario, currentRoute, @@ -508,6 +517,9 @@ async function navigate( // Get navigation map depending on the scenario and the current 'page' you're on. function getNavigationMap(scenario, currentRoute) { const fmgPageValue = currentRoute.query.fmgPage; + log("------------- router index.js getNavigationMap start -----------------"); + log("fmgPage: " + fmgPageValue + " scenario: " + scenario, ""); + log("------------- router index.js getNavigationMap end -----------------"); const matchedQueryValue = routingTable(store) .filter( (item) => @@ -525,7 +537,7 @@ function log(message, data) { data = data ?? ""; const outData = typeof data === "object" ? JSON.stringify(data) : data; - if (log === "true") { + if (log === "true" || store.getters.applicationUser.loggingOption) { console.log(new Date() + message + outData); } } diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index d1a89897d..3e3dbd4bf 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -470,6 +470,10 @@ const routingTable = function (store) { scenario: navigationScenarios.CLICKED_FORWARD, destinationFmgPageValue: fmgPageValues.PAYMENT_METHOD, }, + { + scenario: navigationScenarios.CLICKED_PAY_NOW, + destinationFmgPageValue: fmgPageValues.PAYMENT_METHOD, + }, ], }, { diff --git a/src/store/index.js b/src/store/index.js index e17abda16..1ed4116bb 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2005,8 +2005,7 @@ export const actions = { order.payment.insuranceCoverage.coverageStatus?.toString(), coverageVerificationType: order.payment.insuranceCoverage.coverageVerificationType, - coverageSubStatus: - order.payment.insuranceCoverage.coverageSubStatus, + coverageSubStatus: order.payment.insuranceCoverage.coverageSubStatus, }, isInsurance: order.payment.isInsurance, parentAccountNumber: order.payment.parentAccountNumber, @@ -2462,10 +2461,12 @@ export const actions = { }, savePaymentMethodChoice(context, paymentMethod) { - const isPia = paymentMethod !== paymentMethods.LATER; + var isPia = null; + if (paymentMethod !== paymentMethods.NONE) { + isPia = paymentMethod !== paymentMethods.LATER; + } context.commit(storeMutations.UPDATE_IS_PIA, isPia); - context.commit(storeMutations.UPDATE_PIA_TYPE, isPia ? paymentMethod : null); }, From 43933480b561ffde30446bca46293004c6b19a8e Mon Sep 17 00:00:00 2001 From: CarlNation Date: Fri, 3 Jan 2025 13:44:56 -0500 Subject: [PATCH 2/9] CASH-60 CASH-60 remove the async await from the payment page prereqs. Causes a promise to be returned instead of a bool. Moved it to the router instead --- src/layouts/payment/payment.spec.js | 3 +++ src/layouts/payment/payment.vue | 5 ++--- src/router/index.js | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/layouts/payment/payment.spec.js b/src/layouts/payment/payment.spec.js index 4290a97d4..7bc14f229 100644 --- a/src/layouts/payment/payment.spec.js +++ b/src/layouts/payment/payment.spec.js @@ -202,6 +202,9 @@ describe("payment.vue", () => { jobMaxMinutes: "45", }, }, + applicationUser: { + loggingOption: false, + }, policy: { currentDeductible: 1, }, diff --git a/src/layouts/payment/payment.vue b/src/layouts/payment/payment.vue index 30bbb9731..750e54302 100644 --- a/src/layouts/payment/payment.vue +++ b/src/layouts/payment/payment.vue @@ -483,7 +483,7 @@ export default { }, }, methods: { - async arePagePrerequisitesValid() { + arePagePrerequisitesValid() { // Service Location const serviceLocation = store.getters.order.serviceLocation; const mobileReqs = !!( @@ -579,8 +579,7 @@ export default { } if (!preReqResult) { - await store.getters.applicationUser.saveSessionPromise; - this.backButtonAction(); + return false; } return preReqResult; diff --git a/src/router/index.js b/src/router/index.js index 22e5da6b1..7f5fcbf80 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -194,6 +194,12 @@ const routes = [ if (!arePagePrerequisitesValid(component)) { console.log("Page prereq error: " + component.default.name); + + if (to.query.fmgPage === fmgPageValues.PAYMENT) { + await store.getters.applicationUser.saveSessionPromise; + window.location = applicationConfig.PIA_CANCEL_URL; + } + GoToFunnelStartOn404(next); } From c61a299adb32454873c36a59cfb9419fa96568f0 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Fri, 3 Jan 2025 13:50:49 -0500 Subject: [PATCH 3/9] CASH-60 removed unnecassary code CASH-60 removed unnecessary code --- src/layouts/payment/payment.vue | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/layouts/payment/payment.vue b/src/layouts/payment/payment.vue index 750e54302..ce5e6bcbe 100644 --- a/src/layouts/payment/payment.vue +++ b/src/layouts/payment/payment.vue @@ -578,10 +578,6 @@ export default { } } - if (!preReqResult) { - return false; - } - return preReqResult; }, getWOrkOrderNumber() { From e54363e503afe6b1a4d57c657384ff098f05b264 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Fri, 3 Jan 2025 13:58:09 -0500 Subject: [PATCH 4/9] CASH-60 CASH-60 return to avoid race conditions. --- src/router/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/router/index.js b/src/router/index.js index 7f5fcbf80..833a359b7 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -198,6 +198,7 @@ const routes = [ if (to.query.fmgPage === fmgPageValues.PAYMENT) { await store.getters.applicationUser.saveSessionPromise; window.location = applicationConfig.PIA_CANCEL_URL; + return; } GoToFunnelStartOn404(next); From c2aa73cf7c8fd7b492069c84eb4a561fa3ca21ef Mon Sep 17 00:00:00 2001 From: CarlNation Date: Mon, 6 Jan 2025 14:15:58 -0500 Subject: [PATCH 5/9] CASH-80 CASH-80 allow heritage to redirect to insurance company page now. --- src/helpers/heritage-integration/navigation-helper.js | 5 +---- src/layouts/customer-details/customer-details.vue | 2 +- src/layouts/vehicle/vehicle.vue | 2 +- src/router/index.js | 4 +++- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index 5e71bb5b7..3090ccb1c 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -42,10 +42,7 @@ export async function getDirectNavigation(toRoute) { return fmgPageValues.VEHICLE_DAMAGE; } - if ( - fmgPageValue === fmgPageValues.QUOTE || - fmgPageValue === fmgPageValues.INSURANCE_COMPANY - ) { + if (fmgPageValue === fmgPageValues.QUOTE) { const skipVin = await skipVinLookup(); if (skipVin) { diff --git a/src/layouts/customer-details/customer-details.vue b/src/layouts/customer-details/customer-details.vue index 820d5ddc1..6775e36da 100644 --- a/src/layouts/customer-details/customer-details.vue +++ b/src/layouts/customer-details/customer-details.vue @@ -183,7 +183,7 @@ export default { ); // if the user has resorted to using browser back/forward buttons we could have promises unresolved if they clicked back before pia work order submission. - // so attempt to wait for them to finish. + // so attempt to wait for them to finish. if (store.getters.order.payment.isPia) { this.dispatchStoreAction( storeActions.SAVE_PAYMENT_METHOD_CHOICE, diff --git a/src/layouts/vehicle/vehicle.vue b/src/layouts/vehicle/vehicle.vue index 18eee6988..1009b9713 100644 --- a/src/layouts/vehicle/vehicle.vue +++ b/src/layouts/vehicle/vehicle.vue @@ -402,7 +402,7 @@ export default { !options.length || store.getters.payment?.insuranceCoverage?.isVerified || (store.getters.order.payment?.isInsurance && - getFunnelCookie().HasDelayedClaimRegistration) + getFunnelCookie()?.HasDelayedClaimRegistration) ) { return true; } else { diff --git a/src/router/index.js b/src/router/index.js index 833a359b7..7c1738464 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -113,6 +113,7 @@ const routes = [ store.commit(storeMutations.UPDATE_AFFILIATE_COOKIES, affiliateCookies); } setupAdvertiserTracking(); + log(" --load session start"); const loadSessionResponse = await loadSessionIfPresent( to.query.isInsurance != null ? to.query.isInsurance == "true" @@ -121,6 +122,7 @@ const routes = [ : null, to.query.fmgPage ); + log(" --load session end"); //Update external parameter state but not when returning from heritage if (!to.query.fmgPage?.startsWith("service-location")) { @@ -388,7 +390,7 @@ router.navigateWithSaving = ( router.navigateToExternalUrl = (url, optionalQuery = {}) => { log("------------- router navigateToExternalUrl -----------------"); - log("url:", url) + log("url:", url); navigateToUrl(url, optionalQuery); }; From 68b76c5f0d1d2b299bb75b95d247d9a692f297a9 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Mon, 6 Jan 2025 14:52:16 -0500 Subject: [PATCH 6/9] CASH-80 correct test CASH-80 correct test --- .../navigation-helper.spec.js | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index 2af724828..ae20659f5 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -400,26 +400,6 @@ describe("getPageToRouteExistingOrderTo", () => { // Assert expect(result).toBe(fmgPageValues.ESTIMATE); }); - - test("Replace navigation to `insurance-company` with `estimate`", async () => { - // Arrange - const toRoute = { - query: { - fmgPage: fmgPageValues.INSURANCE_COMPANY, - }, - }; - - store.commit(storeMutations.UPDATE_IS_VERIFIED_INSURANCE, true); - store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, "666666"); - store.commit(storeMutations.UPDATE_IS_REPAIR, true); - store.commit(storeMutations.UPDATE_MAKE, "acura"); - - // Act - const result = await getPageToRouteExistingOrderTo(toRoute); - - // Assert - expect(result).toBe(fmgPageValues.ESTIMATE); - }); }); describe("Vin-Required", () => { @@ -445,29 +425,6 @@ describe("getPageToRouteExistingOrderTo", () => { // Assert expect(result).toBe(fmgPageValues.VIN_LOOKUP); }); - - test("Replace navigation to `insurance-company` with `vin-lookup`", async () => { - // Arrange - const toRoute = { - query: { - fmgPage: fmgPageValues.INSURANCE_COMPANY, - }, - }; - - store.commit(storeMutations.UPDATE_IS_VERIFIED_INSURANCE, true); - store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, "666666"); - store.commit(storeMutations.UPDATE_IS_REPAIR, false); - store.commit(storeMutations.UPDATE_MAKE, "acura"); - store.commit(storeMutations.UPDATE_GLASS_TO_REPLACE, [ - { glassLocation: glassLocations.WINDSHIELD }, - ]); - - // Act - const result = await getPageToRouteExistingOrderTo(toRoute); - - // Assert - expect(result).toBe(fmgPageValues.VIN_LOOKUP); - }); }); }); From d2ae8a5237975b2b93799c823e51f571eacaef60 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Tue, 7 Jan 2025 13:19:35 -0500 Subject: [PATCH 7/9] CASH-80 tests CASH-80 tests --- src/helpers/heritage-integration/navigation-helper.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index ae20659f5..396b4eee1 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -418,6 +418,7 @@ describe("getPageToRouteExistingOrderTo", () => { store.commit(storeMutations.UPDATE_GLASS_TO_REPLACE, [ { glassLocation: glassLocations.WINDSHIELD }, ]); + store.commit(storeMutations.UPDATE_VEHICLE_VIN, "abcd1234"); // Act const result = await getPageToRouteExistingOrderTo(toRoute); From 02183aab9f102bd9fda04d3bd9fd0b8b23273091 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Tue, 7 Jan 2025 13:21:52 -0500 Subject: [PATCH 8/9] CASH-80 request insurance company page and let nextgen decide CASH-80 request insurance company page and let nextgen decide --- src/helpers/heritage-integration/navigation-helper.js | 2 +- src/router/index.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index 3090ccb1c..4afc7e115 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -45,7 +45,7 @@ export async function getDirectNavigation(toRoute) { if (fmgPageValue === fmgPageValues.QUOTE) { const skipVin = await skipVinLookup(); - if (skipVin) { + if (skipVin || !store.getters.vehicle?.vin) { return fmgPageValues.ESTIMATE; } else { return fmgPageValues.VIN_LOOKUP; diff --git a/src/router/index.js b/src/router/index.js index 7c1738464..da3c1914c 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -157,7 +157,10 @@ const routes = [ // Reroute around pages that should not be available. // Exception 1: Integrated Users should not see vehicle or quote pages. - if (store.getters.payment?.insuranceCoverage?.isVerified) { + if ( + store.getters.payment?.insuranceCoverage?.isVerified || + store.getters.order?.referralNumber?.length === 6 + ) { if (to.query.fmgPage === fmgPageValues.VEHICLE) { to.query.fmgPage = fmgPageValues.VEHICLE_DAMAGE; } else if ( From 25717e674b19df9d547b72d370bae3e1aa79853f Mon Sep 17 00:00:00 2001 From: CarlNation Date: Tue, 14 Jan 2025 11:30:28 -0500 Subject: [PATCH 9/9] CASH-79 move save-session after save quote CASH-79 move save-session after save quote so that the email is still empty in Dynamo when the save-quote is called --- src/helpers/heritage-integration/order-helper.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index e88a64c27..76729e49f 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -99,6 +99,13 @@ export async function submitWorkOrder({ } export async function saveQuote({ pageNameToLog }) { + await baseMixin.methods.dispatchStoreActionWithLogging( + storeActions.SAVE_QUOTE, + {}, + pageNameToLog, + false + ); + // save session back to sv2 so the email gets saved just in case they refresh or step away and come back later await saveSession({ pageNameToLog: pageNameToLog, @@ -107,12 +114,7 @@ export async function saveQuote({ pageNameToLog }) { createUnscheduledStatusWorkOrderForPIA: false, }); - return await baseMixin.methods.dispatchStoreActionWithLogging( - storeActions.SAVE_QUOTE, - {}, - pageNameToLog, - false - ); + return; } // PRIVATE FUNCTIONS //