From 6ca3d916baef44ed16886f67a0678574ef0c30cb Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Fri, 12 May 2023 10:56:54 -0400 Subject: [PATCH] CSR-1137 | Tech review changes --- src/layouts/schedule/schedule.vue | 56 ++++++++++--------- .../time-slot-modal-question.vue} | 37 ++++++------ 2 files changed, 51 insertions(+), 42 deletions(-) rename src/layouts/schedule/{time-slot-selection-modal/time-slot-selection-modal.vue => time-slot-modal-question/time-slot-modal-question.vue} (78%) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 7bdda50d6..8263b0b93 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -23,14 +23,14 @@ v-model="selectedDate" :customSelectableDatesCallback="getAvailableDates" /> - - + :estimatedServiceMinutesMaximum="selectableDatesData.estimatedServiceMinutesMaximum"/> + selectableDate.dateString === this.selectedDate.dateString); - } + }, + appointmentDateAndTime() { + if (!this.selectedTimeSlotId) { + return null; + } + const timeSlotSelectedObject = this.getTimeSlotObjectFromTimeSlotId(this.selectedTimeSlotId); + if (timeSlotSelectedObject) { + return { + date: this.selectedDate.dateString, + startTime: timeSlotSelectedObject.startTime, + endTime: timeSlotSelectedObject.endTime, + id: this.selectedTimeSlotId, + }; + } else { + return null; + } + + }, }, methods: { doesCopyContainRouterLink, @@ -164,18 +175,11 @@ export default { }); return responseData; }, - openInshopTimeslotsModal() { - this.$refs["timeSlotModal"].openModal(); - }, - updateAppointmentDateAndTime() { - let timeSlotSelectedObject = this.getTimeSlotObjectFromTimeSlotId(this.selectedTimeSlotId); - this.appointmentDateAndTime.date = this.selectedDate.dateString; - this.appointmentDateAndTime.startTime = timeSlotSelectedObject.startTime; - this.appointmentDateAndTime.endTime = timeSlotSelectedObject.endTime; - this.appointmentDateAndTime.id = this.selectedTimeSlotId; + openInshopTimeSlotsModal() { + this.$refs["timeSlotModalQuestion"].openModal(); }, getTimeSlotObjectFromTimeSlotId(timeSlotId) { - let timeSlots = this.selectableDatesData.find(selectableDate => selectableDate.dateString === this.selectedDate.dateString).timeSlots; + const timeSlots = this.selectableDatesData.find(selectableDate => selectableDate.dateString === this.selectedDate.dateString).timeSlots; return timeSlots.find(timeSlot => timeSlot.id === timeSlotId); }, backButtonAction() { @@ -199,7 +203,7 @@ export default { Form, loadingModal, datePicker, - timeSlotSelectionModal, + timeSlotModalQuestion, }, }; diff --git a/src/layouts/schedule/time-slot-selection-modal/time-slot-selection-modal.vue b/src/layouts/schedule/time-slot-modal-question/time-slot-modal-question.vue similarity index 78% rename from src/layouts/schedule/time-slot-selection-modal/time-slot-selection-modal.vue rename to src/layouts/schedule/time-slot-modal-question/time-slot-modal-question.vue index 17a1c19db..d59cdbf4f 100644 --- a/src/layouts/schedule/time-slot-selection-modal/time-slot-selection-modal.vue +++ b/src/layouts/schedule/time-slot-modal-question/time-slot-modal-question.vue @@ -3,24 +3,23 @@ ref="timeSlots" class="time-slots-modal" :headerText="dateSelectedReadableDate" - footerButtonText="Save time slot" + :footerButtonText="footerCloseButtonText" allowManualFooterDisableOverride - :isFooterDisabledManualOverride="currentlySelectedTimeSlot === null" + :isFooterDisabledManualOverride="selectedTimeSlot === null" :onModalOpenedCallback="onModalOpened" :onModalClosedCallback="onModalClosed" @footer-button-event="closeModal"> @@ -34,38 +33,45 @@ import buttonQuestion from "@/digital-components/button-question/button-question import { daysOfWeek, monthsOfYear } from "@/constants/scheduling.js"; export default { - name: "timeSlotSelectionModal", + name: "timeSlotModalQuestion", props: { modelValue: Object, + cmsWidgetName: String, dateAndTimeSlotData: Object, estimatedServiceMinutesMinimum: Number, estimatedServiceMinutesMaximum: Number, }, data() { return { - currentlySelectedTimeSlot: null, + selectedTimeSlot: null, }; }, watch: { modelValue() { - this.currentlySelectedTimeSlot = this.modelValue; + this.selectedTimeSlot = this.modelValue; }, }, computed: { + appointmentDurationTextFromCms() { + return this.getCmsContent(this.cmsWidgetName, "SubheaderText"); + }, + footerCloseButtonText() { + return this.getCmsContent(this.cmsWidgetName, "FooterText"); + }, dateSelectedReadableDate() { if (this.dateAndTimeSlotData === null) { return null; } // This conversion ensures we don't get get GMT induced date changes - let dateObject = new Date (`${this.dateAndTimeSlotData.dateString}T00:00:00`); + const dateObject = new Date (`${this.dateAndTimeSlotData.dateString}T00:00:00`); const weekdayName = daysOfWeek[dateObject.getDay()]; const month = monthsOfYear[dateObject.getMonth()]; const numberDayOfMonth = dateObject.getDate(); // Ex. Tuesday, April 23 return `${weekdayName}, ${month} ${numberDayOfMonth}`; }, - durationSubHeaderText() { - let durationSubHeaderText = "Duration: "; + appointmentDurationTextWithTime() { + let durationSubHeaderText = this.appointmentDurationTextFromCms + " "; if (this.estimatedServiceMinutesMaximum >= 120) { durationSubHeaderText += `${this.estimatedServiceMinutesMinimum / 60} - ${ this.estimatedServiceMinutesMaximum / 60} hours`; @@ -74,7 +80,7 @@ export default { } return durationSubHeaderText; }, - availableTimeslots() { + availableTimeSlots() { if (this.dateAndTimeSlotData === null) { return null; } @@ -100,13 +106,12 @@ export default { }, // fires any time the footer button is used, is fired before "onModalClosed" closeModal() { - this.$emit("update:modelValue", this.currentlySelectedTimeSlot); + this.$emit("update:modelValue", this.selectedTimeSlot); this.$refs["timeSlots"].closeModal(); - this.$emit("timeSlotSaved"); }, // fires any time the modal is closed, AFTER "closeModal" fires if footer button is used onModalClosed() { - this.currentlySelectedTimeSlot = this.modelValue; + this.selectedTimeSlot = this.modelValue; }, }, components: {