From af8db1c343168fa9e260253a956d7f73362c8f54 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Wed, 7 Jun 2023 07:42:42 -0400 Subject: [PATCH 01/10] CSR-1144 Save premium early bird appointment into supporting items --- src/layouts/schedule/schedule.vue | 35 +++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 675c79887..31382b471 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -73,7 +73,7 @@ import { getRouterLinkRouteFromCopy, getRouterLinkDisplayTextFromCopy, } from "@/helpers/cms-content-helper"; -import { AppointmentTypeStrings } from "@/constants/schedule-constants"; +import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from "@/constants/schedule-constants"; import { errorMessages } from "@/constants/error-messages"; import { required } from "@/helpers/validation-rules"; import store from "@/store"; @@ -341,7 +341,8 @@ export default { backButtonAction() { this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); }, - async forwardButtonAction() { + forwardButtonAction() { + this.updateSupportingItems(); this.dispatchStoreAction( this.storeActions.SAVE_SCHEDULE, this.appointmentDateAndTime, @@ -349,6 +350,36 @@ export default { ); navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal }); }, + + updateSupportingItems() { + // if we have a premium fee(early bird), then save/update supporting items + if ( + this.appointmentType === AppointmentTypeStrings.MOBILE && + this.selectedTimeSlotData?.isPremiumAppointment > 0 + ) { + const supportingItems = store.getters.lineItems.supportingItems; + const earlyBirdIndex = supportingItems.findIndex( + (item) => item.partNumber == PREMIUM_FEE_PART_TYPE + ); + + if (earlyBirdIndex >= 0) { + supportingItems[earlyBirdIndex].laborAmount = + this.mobilePremiumAppointmentFee.laborAmount; + supportingItems[earlyBirdIndex].selingPrice = + this.mobilePremiumAppointmentFee.selingPrice; + supportingItems[earlyBirdIndex].kitPrice = + this.mobilePremiumAppointmentFee.kitPrice; + } else { + supportingItems.push(this.mobilePremiumAppointmentFee); + } + + this.dispatchStoreAction( + this.storeActions.SAVE_SUPPORTING_ITEMS, + supportingItems, + false + ); + } + }, }, watch: { selectedDate(newValue, oldValue) { From b1a2bd4e003b0978a3a9ed074d24d2bb63dd0b9b Mon Sep 17 00:00:00 2001 From: CarlNation Date: Wed, 7 Jun 2023 11:24:02 -0400 Subject: [PATCH 02/10] CSR-1144 reset schedule data when appointment data for early bird not found --- src/store/index.js | 67 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index eac41c311..f00d6c460 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -11,7 +11,7 @@ import { damageLocationsSelected } from "@/constants/damage-locations-selected"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; import router from "@/router"; import { deleteFunnelCookie } from "@/helpers/heritage-integration/cookie-helper.js"; -import { AppointmentTypeStrings } from "@/constants/schedule-constants"; +import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from "@/constants/schedule-constants"; // Export State const getDefaultState = () => { @@ -1406,6 +1406,7 @@ export const actions = { if (context.state.order.eon && context.state.order.eon != response.data.eon) { context.commit(storeMutations.RESET_STATE); } + context.commit( storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, response.data @@ -2070,6 +2071,40 @@ async function validateAppointment(context, order) { }, false ); + + if (newTimeSlotsResponse?.data.days?.length === 0) { + context.commit(storeMutations.RESET_SCHEDULE); + return; + } + + var mobileRouteCodeFound = false; + // if early bird fee is in supporting items then need to check the timeslot to see if offer premium is also still available + if ( + order.lineItem?.supportingItems?.findIndex( + (item) => item.partNumber == PREMIUM_FEE_PART_TYPE + ) + ) { + newTimeSlotsResponse.data.days?.forEach((day) => { + day.timeSlots.forEach((ts) => { + if (ts.id === order.schedule.routeCode && ts.offerPremium) { + mobileRouteCodeFound = true; + } + }); + }); + } else { + newTimeSlotsResponse.data.days?.forEach((day) => { + day.timeSlots.forEach((ts) => { + if (ts.id === order.schedule.routeCode) { + mobileRouteCodeFound = true; + } + }); + }); + } + + if (!mobileRouteCodeFound) { + context.commit(storeMutations.RESET_SCHEDULE); + return; + } } else { newTimeSlotsResponse = await context.dispatch( storeActions.GET_SHOP_TIME_SLOTS, @@ -2081,24 +2116,24 @@ async function validateAppointment(context, order) { }, false ); - } - if (newTimeSlotsResponse?.data.days?.length === 0) { - context.commit(storeMutations.RESET_SCHEDULE); - return; - } + if (newTimeSlotsResponse?.data.days?.length === 0) { + context.commit(storeMutations.RESET_SCHEDULE); + return; + } - var routeCodeFound = false; - newTimeSlotsResponse.data.days?.forEach((day) => { - day.timeSlots.forEach((ts) => { - if (ts.id === order.schedule.routeCode) { - routeCodeFound = true; - } + var routeCodeFound = false; + newTimeSlotsResponse.data.days?.forEach((day) => { + day.timeSlots.forEach((ts) => { + if (ts.id === order.schedule.routeCode) { + routeCodeFound = true; + } + }); }); - }); - if (!routeCodeFound) { - context.commit(storeMutations.RESET_SCHEDULE); - return; + if (!routeCodeFound) { + context.commit(storeMutations.RESET_SCHEDULE); + return; + } } } From 7b1f394fae9b292f51cf5188724bc37c45819882 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Wed, 7 Jun 2023 11:33:18 -0400 Subject: [PATCH 03/10] CSR-1144 isPremium is a bool --- src/layouts/schedule/schedule.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 31382b471..327724379 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -355,7 +355,7 @@ export default { // if we have a premium fee(early bird), then save/update supporting items if ( this.appointmentType === AppointmentTypeStrings.MOBILE && - this.selectedTimeSlotData?.isPremiumAppointment > 0 + this.selectedTimeSlotData?.isPremiumAppointment ) { const supportingItems = store.getters.lineItems.supportingItems; const earlyBirdIndex = supportingItems.findIndex( From fc8debc871cfd918c9e5bdfaba4a3aca08f5b99a Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Wed, 7 Jun 2023 12:54:48 -0400 Subject: [PATCH 04/10] Updates for CMS provider/serviceloc ctu --- src/layouts/schedule/location-alerts/location-alerts.vue | 8 ++++++-- src/layouts/schedule/schedule.vue | 5 ++++- src/layouts/service-location/service-location.vue | 1 + src/store/index.js | 4 +++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/layouts/schedule/location-alerts/location-alerts.vue b/src/layouts/schedule/location-alerts/location-alerts.vue index 0f8c7b46d..66f26e263 100644 --- a/src/layouts/schedule/location-alerts/location-alerts.vue +++ b/src/layouts/schedule/location-alerts/location-alerts.vue @@ -36,8 +36,12 @@ export default { }, }, methods: { - loadInitialData(zipCodeCtu) { - return getAlertReasons(zipCodeCtu); + loadInitialData(serviceLocationCtu, providerCtu) { + let ctuToUse = serviceLocationCtu; + if (providerCtu) { + ctuToUse = providerCtu; + } + return getAlertReasons(ctuToUse); }, initializeComponent(initialData) { this.alertReasons = initialData; diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index fe9f3dac8..68ccd593c 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -50,6 +50,7 @@ import funnelFooter from "@/fmg-components/funnel-footer/funnel-footer"; import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header"; import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue"; import { Form, defineRule } from "vee-validate"; +import { processIfStatements } from "@/helpers/cms-content-helper"; import datePicker from "@/digital-components/date-picker/date-picker"; import locationAlerts from "@/layouts/schedule/location-alerts/location-alerts"; import timeSlotModalQuestion from "./time-slot-modal-question/time-slot-modal-question"; @@ -146,7 +147,8 @@ export default { }); const alertReasonsPromise = locationAlerts.methods.loadInitialData( - store.getters.order.serviceLocation.zipCodeCtu + store.getters.order.serviceLocation.zipCodeCtu, + store.getters.order.serviceLocation.provider?.address?.zipCtu ); // Settle promises and get results const promiseResultMap = [ @@ -227,6 +229,7 @@ export default { splitCopyOnCMSPlaceHolder, getRouterLinkRouteFromCopy, getRouterLinkDisplayTextFromCopy, + processIfStatements, arePagePrerequisitesValid() { const serviceLocation = store.getters.order.serviceLocation; const serviceLocationPreReqs = diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 252eac529..fe1d4ae2b 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -394,6 +394,7 @@ export default { city: this.selectedProvider?.address?.city, state: this.selectedProvider?.address?.state, zip: this.selectedProvider?.address?.zipCode, + zipCtu: this.selectedProvider?.address?.zipCodeCtu, }, }, }, diff --git a/src/store/index.js b/src/store/index.js index eac41c311..1223a407a 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -264,6 +264,8 @@ export const mutations = { serviceLocationInfo.provider?.address?.state; state.order.serviceLocation.provider.address.zip = serviceLocationInfo.provider?.address?.zip; + state.order.serviceLocation.provider.address.zipCtu = + serviceLocationInfo.provider?.address?.zipCtu; } }, updateSchedule(state, scheduleInfo) { @@ -1345,6 +1347,7 @@ export const actions = { city: order.serviceLocation.provider?.address?.city, state: order.serviceLocation.provider?.address?.state, zip: order.serviceLocation.provider?.address?.zip, + zipCtu: order.serviceLocation.provider?.address?.zipCtu, }, }, }, @@ -1799,7 +1802,6 @@ export const actions = { `&${availableLineItemsFormattedForRequest}`; const lineItemServerData = context.getters.order.lineItems.serverData; - if (lineItemServerData) { queryString += `&ServerData=${encodeURIComponent(lineItemServerData)}`; } From 07079997f01aff9fa80af5945cce2b3247adcec2 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Wed, 7 Jun 2023 13:07:41 -0400 Subject: [PATCH 05/10] CSR-1144 remove early bird from supporting items if it exists but not needed because the appointment changed --- src/layouts/schedule/schedule.vue | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 327724379..afd296fc2 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -352,12 +352,13 @@ export default { }, updateSupportingItems() { + const supportingItems = store.getters.lineItems.supportingItems; + // if we have a premium fee(early bird), then save/update supporting items if ( this.appointmentType === AppointmentTypeStrings.MOBILE && this.selectedTimeSlotData?.isPremiumAppointment ) { - const supportingItems = store.getters.lineItems.supportingItems; const earlyBirdIndex = supportingItems.findIndex( (item) => item.partNumber == PREMIUM_FEE_PART_TYPE ); @@ -379,6 +380,17 @@ export default { false ); } + else { + // if it's not a mobile and/or premium early bird, then make sure we remove any that may have beedn added + const removeEarlyBirdIndex = supportingItems.findIndex( + (item) => item.partNumber == PREMIUM_FEE_PART_TYPE + ); + + if (removeEarlyBirdIndex >= 0) { + supportingItems.splice(removeEarlyBirdIndex, 1) + this.dispatchStoreAction(this.storeActions.SAVE_SUPPORTING_ITEMS, supportingItems, false); + } + } }, }, watch: { From b4cfc1ed6c9f3c5c989abfe487d32002282b07fb Mon Sep 17 00:00:00 2001 From: CarlNation Date: Wed, 7 Jun 2023 13:25:33 -0400 Subject: [PATCH 06/10] CSR-1144 typo --- src/layouts/schedule/schedule.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index b79d31014..775fc3088 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -375,7 +375,7 @@ export default { ); } else { - // if it's not a mobile and/or premium early bird, then make sure we remove any that may have beedn added + // if it's not a mobile and/or premium early bird, then make sure we remove any that may have been added const removeEarlyBirdIndex = supportingItems.findIndex( (item) => item.partNumber == PREMIUM_FEE_PART_TYPE ); From 036567b1c30a05e06c04ac59c7536f8aeeedad77 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Wed, 7 Jun 2023 13:29:25 -0400 Subject: [PATCH 07/10] CSR-1144 prettier run --- src/layouts/schedule/schedule.vue | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 775fc3088..71383487a 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -373,17 +373,20 @@ export default { supportingItems, false ); - } - else { + } else { // if it's not a mobile and/or premium early bird, then make sure we remove any that may have been added const removeEarlyBirdIndex = supportingItems.findIndex( (item) => item.partNumber == PREMIUM_FEE_PART_TYPE ); if (removeEarlyBirdIndex >= 0) { - supportingItems.splice(removeEarlyBirdIndex, 1) - this.dispatchStoreAction(this.storeActions.SAVE_SUPPORTING_ITEMS, supportingItems, false); - } + supportingItems.splice(removeEarlyBirdIndex, 1); + this.dispatchStoreAction( + this.storeActions.SAVE_SUPPORTING_ITEMS, + supportingItems, + false + ); + } } }, }, From 2b1b20fc63d38a3430402f542a52121d226b6d92 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Wed, 7 Jun 2023 14:10:58 -0400 Subject: [PATCH 08/10] Added 'loader' method for address2 on service-location --- src/layouts/service-location/service-location.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index fe1d4ae2b..8f63e5df7 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -138,7 +138,7 @@ export default { data() { return { streetAddress: this.getServiceAddressFromStore(), - apartmentNumberOrBusinessName: "", + apartmentNumberOrBusinessName: this.getServiceAddress2FromStore(), city: this.getServiceCityFromStore(), state: this.getServiceStateFromStore(), zipCode: this.getServiceZipCodeFromStore(), @@ -339,6 +339,9 @@ export default { getServiceAddressFromStore() { return store.getters.order.serviceLocation.address; }, + getServiceAddress2FromStore() { + return store.getters.order.serviceLocation.address2; + }, getServiceCityFromStore() { return store.getters.order.serviceLocation.city; }, From 12e02313d1f750b08a7e2e0dc240acd12415c526 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Wed, 7 Jun 2023 14:32:16 -0400 Subject: [PATCH 09/10] CSR-1144 clear early bird whenever schedule data is reset --- jest.config.js | 2 +- src/store/index.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/jest.config.js b/jest.config.js index 28c5557cb..c712c24da 100644 --- a/jest.config.js +++ b/jest.config.js @@ -26,7 +26,7 @@ module.exports = { testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"], coverageThreshold: { global: { - statements: 78, + statements: 77, // Got the go ahead from Mark to temporarily lower this. Taking out initialize component made the year,make,model and style coverage drop a bit. Once unit tests for license plate lookup, vin lookup and address lookup are in the coverage should go back up to 90 }, }, diff --git a/src/store/index.js b/src/store/index.js index f00d6c460..38dd859be 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -349,6 +349,17 @@ export const mutations = { state.order.schedule.endTime = null; state.order.schedule.routeCode = null; state.order.schedule.jobMaxMinutes = null; + + //early bird fee used on schedule page also needs reset when schedule is reset + const supportingItems = state.order.lineItems.supportingItems; + const removeEarlyBirdIndex = supportingItems.findIndex( + (item) => item.partNumber == PREMIUM_FEE_PART_TYPE + ); + + if (removeEarlyBirdIndex >= 0) { + supportingItems.splice(removeEarlyBirdIndex, 1); + state.order.lineItems.supportingItems = supportingItems; + } }, resetState(state) { Object.assign(state, getDefaultState()); From 06467c2183c3b8d41e8ab22ade6969b5d93e4805 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Thu, 8 Jun 2023 11:18:10 -0400 Subject: [PATCH 10/10] WIP --- src/store/index.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 1223a407a..64838564e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -409,18 +409,20 @@ export const mutations = { state.order.lineItems.supportingItems = sessionInformation.order.lineItems.supportingItems; state.order.lineItems.vaps = sessionInformation.order.lineItems.vaps; state.order.lineItems.serverData = sessionInformation.order.lineItems.serverData; + state.order.payment.parentAccountNumber = sessionInformation.order.payment.parentAccountNumber; - (state.order.serviceLocation.address = - sessionInformation.order.serviceLocation.streetAddress), - (state.order.serviceLocation.address2 = - sessionInformation.order.serviceLocation.address2), - (state.order.serviceLocation.city = sessionInformation.order.serviceLocation.city), - (state.order.serviceLocation.state = sessionInformation.order.serviceLocation.state), - (state.order.serviceLocation.zipCode = - sessionInformation.order.serviceLocation.zipCode), - (state.order.serviceLocation.zipCodeCtu = - sessionInformation.order.serviceLocation.zipCodeCtu); + + state.order.serviceLocation.address = + sessionInformation.order.serviceLocation.streetAddress; + state.order.serviceLocation.address2 = + sessionInformation.order.serviceLocation.streetAddress2; + state.order.serviceLocation.city = sessionInformation.order.serviceLocation.city; + state.order.serviceLocation.state = sessionInformation.order.serviceLocation.state; + state.order.serviceLocation.zipCode = sessionInformation.order.serviceLocation.zipCode; + state.order.serviceLocation.zipCodeCtu = + sessionInformation.order.serviceLocation.zipCodeCtu; + state.order.serviceLocation.appointmentType = sessionInformation.order.serviceLocation.appointmentType; state.order.serviceLocation.isVehicleProtected =