From dd502e41ba57aba95bc8e7d983f46b14f5f937bd Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Mon, 8 May 2023 15:47:37 -0400 Subject: [PATCH] CSR-1137 | Finished time slot selection for in shop --- src/layouts/schedule/schedule.vue | 130 +++++------------- .../time-slot-selection-modal.vue | 38 ++++- 2 files changed, 63 insertions(+), 105 deletions(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 5a7211f43..7bdda50d6 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -25,11 +25,11 @@ + v-model="selectedTimeSlotId" + :dateAndTimeSlotData="DateAndTimeSlotDataForTimeslotModal" + :estimatedServiceMinutesMinimum="selectableDatesData.estimatedServiceMinutesMinimum" + :estimatedServiceMinutesMaximum="selectableDatesData.estimatedServiceMinutesMaximum" + @timeSlotSaved="updateAppointmentDateAndTime" /> selectableDate.dateString === this.selectedDate.dateString); + } }, methods: { doesCopyContainRouterLink, @@ -219,10 +140,13 @@ export default { const newShopTimeSlots = newShopTimeSlotsResponse.data; // console.log("newShopTimeSlots ", newShopTimeSlots) + // ADD API CALL RESULTS TO EXISTING DATE DATA this.selectableDatesData = this.selectableDatesData.concat( this.convertApiResponse(newShopTimeSlots.days) ); + this.selectableDatesData.estimatedServiceMinutesMaximum = newShopTimeSlots.estimatedServiceMinutesMaximum; + this.selectableDatesData.estimatedServiceMinutesMinimum = newShopTimeSlots.estimatedServiceMinutesMinimum; console.log("this.selectableDatesData is now: ", this.selectableDatesData); // RETURN AGGREGATE DATE DATA @@ -241,9 +165,19 @@ 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; + }, + getTimeSlotObjectFromTimeSlotId(timeSlotId) { + let timeSlots = this.selectableDatesData.find(selectableDate => selectableDate.dateString === this.selectedDate.dateString).timeSlots; + return timeSlots.find(timeSlot => timeSlot.id === timeSlotId); + }, backButtonAction() { this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); }, diff --git a/src/layouts/schedule/time-slot-selection-modal/time-slot-selection-modal.vue b/src/layouts/schedule/time-slot-selection-modal/time-slot-selection-modal.vue index 9763b5359..17a1c19db 100644 --- a/src/layouts/schedule/time-slot-selection-modal/time-slot-selection-modal.vue +++ b/src/layouts/schedule/time-slot-selection-modal/time-slot-selection-modal.vue @@ -17,7 +17,7 @@ class="mb-5" /> { + let hours = timeslot.startTime.split(":")[0]; + let minutes = timeslot.startTime.split(":")[1]; + let meridianNotation = "AM"; + if (timeslot.startTime.split(":")[0] > 12) { + hours -= 12; + meridianNotation = "PM"; + } + let readableTime = `${hours}:${minutes} ${meridianNotation}`; + return { + value: timeslot.id, + buttonLabel: readableTime, + }; + }); + }, }, methods: { openModal() { @@ -78,7 +101,8 @@ export default { // fires any time the footer button is used, is fired before "onModalClosed" closeModal() { this.$emit("update:modelValue", this.currentlySelectedTimeSlot); - this.$refs["timeSlots"].closeModal("test"); + this.$refs["timeSlots"].closeModal(); + this.$emit("timeSlotSaved"); }, // fires any time the modal is closed, AFTER "closeModal" fires if footer button is used onModalClosed() {