From 5d6f1069b3656828f9d313b0c182b29f9649c352 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Tue, 30 May 2023 09:31:50 -0400 Subject: [PATCH] CSR-1137 | Small refactor --- src/layouts/schedule/schedule.vue | 2 +- .../time-slot-modal-question.vue | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 5e68ef0ee..796bc043c 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -324,7 +324,7 @@ export default { getDisplayTextForMilitaryTime(militaryTimeInput, shouldTrimMinutesIfEmpty = false) { let hours = parseInt(militaryTimeInput.split(":")[0]); const minutes = militaryTimeInput.split(":")[1]; - let meridianNotation = hours > 11 ? "PM" : "AM"; + const meridianNotation = hours > 11 ? "PM" : "AM"; if (hours > 12) { hours -= 12; } diff --git a/src/layouts/schedule/time-slot-modal-question/time-slot-modal-question.vue b/src/layouts/schedule/time-slot-modal-question/time-slot-modal-question.vue index 24bb0e0eb..a622dd875 100644 --- a/src/layouts/schedule/time-slot-modal-question/time-slot-modal-question.vue +++ b/src/layouts/schedule/time-slot-modal-question/time-slot-modal-question.vue @@ -79,7 +79,6 @@ export default { data() { return { selectedTimeSlotId: null, - isSelectedAppointmentPremium: null, timeSlotModalListButton: timeSlotModalListButton, }; }, @@ -189,23 +188,22 @@ export default { }, // fires any time the footer button is used, is fired before "onModalClosed" closeModal() { - if (this.selectedTimeSlotId.toString().includes(PREMIUM_TIME_SLOT_ID_FLAG)) { + let isSelectedAppointmentPremium = false; + if (this.selectedTimeSlotId.includes(PREMIUM_TIME_SLOT_ID_FLAG)) { this.selectedTimeSlotId = this.removePremiumFlagFromInput(this.selectedTimeSlotId); - this.isSelectedAppointmentPremium = true; - } else { - this.isSelectedAppointmentPremium = false; + isSelectedAppointmentPremium = true; } const selectedTimeSlotData = { id: this.selectedTimeSlotId, - isPremiumAppointment: this.isSelectedAppointmentPremium, + isPremiumAppointment: isSelectedAppointmentPremium, }; this.$emit("update:modelValue", selectedTimeSlotData); this.$refs["timeSlots"].closeModal(); }, // fires any time the modal is closed, AFTER "closeModal" fires if footer button is used onModalClosed() { - this.isSelectedAppointmentPremium = this.modelValue.isPremiumAppointment; - if (this.isSelectedAppointmentPremium) { + // Reset component state to parent's state + if (this.modelValue.isPremiumAppointment) { this.selectedTimeSlotId = this.addPremiumFlagToInput(this.modelValue.id); } else { this.selectedTimeSlotId = this.modelValue.id; @@ -216,7 +214,7 @@ export default { getDisplayTextForMilitaryTime(militaryTimeInput) { let hours = parseInt(militaryTimeInput.split(":")[0]); const minutes = militaryTimeInput.split(":")[1]; - let meridianNotation = hours > 11 ? "PM" : "AM"; + const meridianNotation = hours > 11 ? "PM" : "AM"; if (hours > 12) { hours -= 12; } @@ -295,7 +293,7 @@ export default { return (timeSlotId += PREMIUM_TIME_SLOT_ID_FLAG); }, removePremiumFlagFromInput(timeSlotId) { - return parseInt(timeSlotId.trim(PREMIUM_TIME_SLOT_ID_FLAG.length)); + return timeSlotId.substring(0, timeSlotId.length - PREMIUM_TIME_SLOT_ID_FLAG.length); }, }, components: {