From 07079997f01aff9fa80af5945cce2b3247adcec2 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Wed, 7 Jun 2023 13:07:41 -0400 Subject: [PATCH] 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: {