From 764c8559d23c7df5195472667283633da25ea558 Mon Sep 17 00:00:00 2001 From: katieoh-safelite <76531609+katieoh-safelite@users.noreply.github.com> Date: Wed, 11 May 2022 08:17:33 -0400 Subject: [PATCH 1/5] Revert "Revert "Feature/csr 416"" --- src/constants/store-actions.js | 1 + src/constants/store-mutations.js | 4 +- .../heritage-integration/navigation-helper.js | 16 ++++- src/layouts/vehicle-damage/vehicle-damage.vue | 2 - src/layouts/vin-lookup/vin-lookup.vue | 9 ++- src/router/router-constants/routing-table.js | 4 ++ src/store/index.js | 72 +++++++++++++++---- src/store/store.spec.js | 24 +++++-- 8 files changed, 106 insertions(+), 26 deletions(-) diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 2a0a7f29d..fe658fbe1 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -22,6 +22,7 @@ const storeActions = { LOG_PAGE_VIEW: "logPageView", LOG_CUSTOM_EVENT: "logCustomEvent", GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser", + UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION: "updateServiceLocationWithVehicleRegistration", // DEPENDENCY MUTATIONS RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies", diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 65f4719ec..179b484ef 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -44,8 +44,8 @@ const storeMutations = { // OTHER MUTATIONS UPDATE_PAGE_DATA: "updatePageData", - UPDATE_STATE_WITH_ORDER_INFORMATION: "updateStateWithOrderInformation" - + UPDATE_STATE_WITH_ORDER_INFORMATION: "updateStateWithOrderInformation", + UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION: "updateServiceLocationWithVehicleRegistration" }; export { storeMutations }; diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index c7cf34940..6d2c0d93e 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -3,8 +3,10 @@ import { externalUrls } from "@/router/router-constants/externalUrl-values"; import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js"; import { saveOrder } from "@/helpers/heritage-integration/order-helper.js"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; +import { storeActions } from "@/constants/store-actions"; import store from "@/store"; import router from "@/router"; +import baseMixin from "@/mixins/base-mixin.js"; /* If the user has visited the funnel before this method will determine the bets place to @@ -12,7 +14,6 @@ import router from "@/router"; the user has an existing order and they come back in from the Safelite.com CTA. */ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHeritageOrder = false) { - // If the user is coming in via the Safelite.Com CTA if (toRoute.query[queryStrings.START_TYPE] === 'fmg') { // If they have an existing order, return 'heritage' for the page name. @@ -56,6 +57,9 @@ export async function navigateToHeritageFunnel() { export async function navigateAfterSaveToHeritageFunnel(currentRoute) { const currentComponent = currentRoute.matched[0].components; currentComponent.default.methods.resetDependentState(); + + setupOrderBeforeSave(); + // Create the order (or save existing order) when navigating to Heritage Funnel. await saveOrder(); @@ -140,4 +144,14 @@ function isVinRelatedPage(toRoute) { fmgPageValue === fmgPageValues.ADDRESS_LOOKUP || fmgPageValue === fmgPageValues.ADDRESS_VEHICLES || fmgPageValue === fmgPageValues.ESTIMATE; +} + +function setupOrderBeforeSave() { + const serviceLocation = store.getters.order.serviceLocation; + + if (!serviceLocation.zipCode && serviceLocation.zipCode == store.getters.vehicle.registration.zipCode) { + baseMixin.methods.dispatchStoreAction( + storeActions.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION + ); + } } \ 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 a4b2bfdc8..ddeae5bec 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -87,8 +87,6 @@ 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/navigation-helper"; -import { queryStrings } from "@/constants/query-strings"; import store from "@/store"; import baseMixin from "@/mixins/base-mixin"; diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 05c251bfd..d6c28c5b1 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -268,7 +268,7 @@ export default { return store.getters.vehicle.vin }, getZipFromStore(){ - return store.getters.vehicle.registration.zipCode + return store.getters.order.serviceLocation.zipCode; }, attachCustomEvents() { this.prependActionToMethod(this, this.forwardButtonAction, () => { @@ -281,7 +281,12 @@ export default { }); }, backButtonAction() { - this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); + if (store.getters.vehicle.vin) { + this.$router.navigate(this.navigationScenarios.CLICKED_BACK_WITH_VIN, this.$route); + } + else { + this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); + } }, async forwardButtonAction() { const zipValidation = this.validateZip(this.zip); diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index cd2d876b3..290e5fcea 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -107,6 +107,10 @@ const routingTable = [ { scenario: navigationScenarios.CLICKED_FORWARD, destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, + }, + { + scenario: navigationScenarios.CLICKED_BACK_WITH_VIN, + destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, } ], }, diff --git a/src/store/index.js b/src/store/index.js index b1845aa7c..d2123e546 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -15,7 +15,7 @@ const getDefaultState = () => { model: null, style: null, carId: null, - category: null, + category: null, vin: null, imageUrl: null, imageVifNumber: null, @@ -31,6 +31,9 @@ const getDefaultState = () => { }, }, serviceLocation: { + address: null, + city: null, + state: null, zipCode: null, }, customer: { @@ -227,18 +230,39 @@ export const mutations = { imageUrl: orderInformation.vehicle?.imageUrl, imageVifNumber: orderInformation.vehicle?.imageVifNumber, imageColor: orderInformation.vehicle?.imageVifColor, + registration: { + firstName: orderInformation.vehicle.registration.firstName, + lastName: orderInformation.vehicle.registration.lastName, + address: orderInformation.vehicle.registration.streetAddress, + city: orderInformation.vehicle.registration.city, + state: orderInformation.vehicle.registration.state, + zipCode: orderInformation.vehicle.registration.zipCode, + licensePlate: orderInformation.vehicle.registration.licensePlate, + } }); - state.order.damage.glassToReplace = orderInformation.glassToReplace; - state.order.damage.isRepair = orderInformation.isRepair; - state.order.damage.numberOfChips = orderInformation.numberOfChips; + state.order.damage.glassToReplace = orderInformation.damage.glassToReplace; + state.order.damage.isRepair = orderInformation.damage.isRepair; + state.order.damage.numberOfChips = orderInformation.damage.numberOfChips; state.order.lineItems.glassParts = orderInformation.parts; state.order.accountNumber = orderInformation.accountNumber; - state.order.serviceLocation.zipCode = orderInformation.zipCode; + state.order.serviceLocation.address = orderInformation.serviceLocation.streetAddress, + state.order.serviceLocation.city = orderInformation.serviceLocation.city, + state.order.serviceLocation.state = orderInformation.serviceLocation.state, + state.order.serviceLocation.zipCode = orderInformation.serviceLocation.zipCode; state.order.payment.isInsurance = orderInformation.IsInsuranceOrder; state.order.payment.insuranceCoverage.isVerified = orderInformation?.insuranceInfo.coverageVerified; + + state.order.customer.emailAddress = orderInformation.customer.emailAddress; + }, + + updateServiceLocationWithVehicleRegistration(state) { + state.order.serviceLocation.address = state.order.vehicle.registration.address; + 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; } } @@ -419,6 +443,9 @@ export const actions = { context.commit(storeMutations.UPDATE_REFERRAL_DATE, referralDate); context.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, referralCorrelationId); }, + updateServiceLocationWithVehicleRegistration(context) { + context.commit(storeMutations.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION); + }, logExperimentExposure(context, { userId, sessionKey, pageName, universeName }) { return globalMethods.callHttpClient({ @@ -502,6 +529,7 @@ export const actions = { saveOrder(context) { const vehicle = context.getters.vehicle; const damage = context.getters.damage; + const order = context.state.order; return globalMethods.callHttpClient({ method: endpoints.SaveOrder.method, @@ -513,14 +541,34 @@ export const actions = { make: vehicle.make, model: vehicle.model, style: vehicle.style, - vin: vehicle.vin + vin: vehicle.vin, + registration: { + firstName: vehicle.registration.firstName, + lastName: vehicle.registration.lastName, + streetAddress: vehicle.registration.address, + city: vehicle.registration.city, + state: vehicle.registration.state, + zipCode: vehicle.registration.zipCode, + licensePlateNumber: vehicle.registration.licensePlate, + }, }, - numberOfChips: damage.numberOfChips, - zipCode: 43215, // TODO CSR-416, should not be hardcoded (state.order.serviceLocation.zipCode) - glassToReplace: damage.glassToReplace, - referralNumber: context.state.order.referralNumber, - referralDate: context.state.order.referralDate, - accountNumber: context.state.order.accountNumber + damage: { + numberOfChips: damage.numberOfChips, + glassToReplace: damage.glassToReplace, + isRepair: damage.isRepair + }, + customer: { + emailAddress: order.customer.emailAddress, + }, + serviceLocation: { + streetAddress: order.serviceLocation.address, + city: order.serviceLocation.city, + state: order.serviceLocation.state, + zipCode: order.serviceLocation.zipCode + }, + referralNumber: order.referralNumber, + referralDate: order.referralDate, + accountNumber: order.accountNumber }, }); }, diff --git a/src/store/store.spec.js b/src/store/store.spec.js index b1667eb4c..24aa7cbd3 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -215,14 +215,19 @@ describe("Mutations", () => { model: "ILX", style: "4 DOOR SEDAN", carId: "C0000001", - category: "CAR" + category: "CAR", + registration: {} + }, + damage: { + glassToReplace: ["Windshield"], + isRepair: false, + numberOfChips: 0, }, - glassToReplace: ["Windshield"], - isRepair: false, - numberOfChips: 0, parts: [], accountNumber: "123456789", - insuranceInfo: {} + insuranceInfo: {}, + serviceLocation: {}, + customer: {} }); // Assert @@ -562,11 +567,16 @@ describe("Actions", () => { const context = state; context.getters = { - vehicle: {}, + vehicle: { + registration: {} + }, damage: {}, }; context.state = { - order: {} + order: { + serviceLocation: {}, + customer: {} + } }; globalMethods.callHttpClient.mockImplementation(() => { From 8bfdb6b50ce3e1fba0ffff1e3d2f8c777c796948 Mon Sep 17 00:00:00 2001 From: Katie Date: Thu, 12 May 2022 08:45:32 -0400 Subject: [PATCH 2/5] CSR-416 Fix returning license plate on load --- src/store/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index d2123e546..69f6c2ba0 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -237,7 +237,7 @@ export const mutations = { city: orderInformation.vehicle.registration.city, state: orderInformation.vehicle.registration.state, zipCode: orderInformation.vehicle.registration.zipCode, - licensePlate: orderInformation.vehicle.registration.licensePlate, + licensePlate: orderInformation.vehicle.registration.licensePlateNumber, } }); From 7a511d73bc0afcae38ebda7f8e39cbca431a97ef Mon Sep 17 00:00:00 2001 From: Katie Date: Thu, 12 May 2022 15:28:45 -0400 Subject: [PATCH 3/5] CSR-416 Move setupOrderBeforeSave to address-lookup --- .../heritage-integration/navigation-helper.js | 12 ------------ src/layouts/address-lookup/address-lookup.vue | 12 +++++++++++- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index 6d2c0d93e..9bf69ddcf 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -58,8 +58,6 @@ export async function navigateAfterSaveToHeritageFunnel(currentRoute) { const currentComponent = currentRoute.matched[0].components; currentComponent.default.methods.resetDependentState(); - setupOrderBeforeSave(); - // Create the order (or save existing order) when navigating to Heritage Funnel. await saveOrder(); @@ -144,14 +142,4 @@ function isVinRelatedPage(toRoute) { fmgPageValue === fmgPageValues.ADDRESS_LOOKUP || fmgPageValue === fmgPageValues.ADDRESS_VEHICLES || fmgPageValue === fmgPageValues.ESTIMATE; -} - -function setupOrderBeforeSave() { - const serviceLocation = store.getters.order.serviceLocation; - - if (!serviceLocation.zipCode && serviceLocation.zipCode == store.getters.vehicle.registration.zipCode) { - baseMixin.methods.dispatchStoreAction( - storeActions.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION - ); - } } \ No newline at end of file diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index b6140be2f..7fad2f1d0 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -264,6 +264,8 @@ export default { this.displayVinLookupByHomeAddressNotAllowedAlert = false; }, navigateForward(carEntered, carsFound) { + this.setupOrderBeforeSave(); + if (carsFound.length == 1) { // if a different vehicle is found than the one entered and the selected glass // is not available for that vehicle @@ -334,7 +336,15 @@ export default { store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, this.serviceZipCode); store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.customerQuestions.emailAddress); }, - + setupOrderBeforeSave() { + const serviceLocation = store.getters.order.serviceLocation; + + if (!serviceLocation.zipCode && serviceLocation.zipCode == store.getters.vehicle.registration.zipCode) { + baseMixin.methods.dispatchStoreAction( + storeActions.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION + ); + } + } }, computed: { AlertNonServiceableZipHeader(){ From 50d837b798a2fc5b00d7ac83636f29d8976df6c1 Mon Sep 17 00:00:00 2001 From: Katie Date: Thu, 12 May 2022 15:31:21 -0400 Subject: [PATCH 4/5] CSR-416 Rename function --- src/layouts/address-lookup/address-lookup.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index 7fad2f1d0..f95c5de28 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -264,8 +264,8 @@ export default { this.displayVinLookupByHomeAddressNotAllowedAlert = false; }, navigateForward(carEntered, carsFound) { - this.setupOrderBeforeSave(); - + this.setupServiceLocationIfNecessary(); + if (carsFound.length == 1) { // if a different vehicle is found than the one entered and the selected glass // is not available for that vehicle @@ -336,7 +336,7 @@ export default { store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, this.serviceZipCode); store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.customerQuestions.emailAddress); }, - setupOrderBeforeSave() { + setupServiceLocationIfNecessary() { const serviceLocation = store.getters.order.serviceLocation; if (!serviceLocation.zipCode && serviceLocation.zipCode == store.getters.vehicle.registration.zipCode) { From 7fae07a59e3b695cb382f77f52d25855452ff171 Mon Sep 17 00:00:00 2001 From: Katie Date: Thu, 12 May 2022 15:53:49 -0400 Subject: [PATCH 5/5] CSR-416 Revert --- .../heritage-integration/navigation-helper.js | 12 ++++++++++++ src/layouts/address-lookup/address-lookup.vue | 12 +----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index 9bf69ddcf..6d2c0d93e 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -58,6 +58,8 @@ export async function navigateAfterSaveToHeritageFunnel(currentRoute) { const currentComponent = currentRoute.matched[0].components; currentComponent.default.methods.resetDependentState(); + setupOrderBeforeSave(); + // Create the order (or save existing order) when navigating to Heritage Funnel. await saveOrder(); @@ -142,4 +144,14 @@ function isVinRelatedPage(toRoute) { fmgPageValue === fmgPageValues.ADDRESS_LOOKUP || fmgPageValue === fmgPageValues.ADDRESS_VEHICLES || fmgPageValue === fmgPageValues.ESTIMATE; +} + +function setupOrderBeforeSave() { + const serviceLocation = store.getters.order.serviceLocation; + + if (!serviceLocation.zipCode && serviceLocation.zipCode == store.getters.vehicle.registration.zipCode) { + baseMixin.methods.dispatchStoreAction( + storeActions.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION + ); + } } \ No newline at end of file diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index f95c5de28..b6140be2f 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -264,8 +264,6 @@ export default { this.displayVinLookupByHomeAddressNotAllowedAlert = false; }, navigateForward(carEntered, carsFound) { - this.setupServiceLocationIfNecessary(); - if (carsFound.length == 1) { // if a different vehicle is found than the one entered and the selected glass // is not available for that vehicle @@ -336,15 +334,7 @@ export default { store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, this.serviceZipCode); store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.customerQuestions.emailAddress); }, - setupServiceLocationIfNecessary() { - const serviceLocation = store.getters.order.serviceLocation; - - if (!serviceLocation.zipCode && serviceLocation.zipCode == store.getters.vehicle.registration.zipCode) { - baseMixin.methods.dispatchStoreAction( - storeActions.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION - ); - } - } + }, computed: { AlertNonServiceableZipHeader(){