From 6eb0ba28679147d53c5d3e3e3bd55f8c798740c5 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Fri, 26 May 2023 09:06:01 -0400 Subject: [PATCH] CSR-1137 | Final refactor --- src/layouts/schedule/schedule.vue | 2 +- .../time-slot-modal-question.vue | 20 ++++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 37bdc8622..5e68ef0ee 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -320,7 +320,7 @@ export default { // Ex: April 25 return dateObject.toLocaleDateString("en-us", { month: "short", day: "numeric" }); }, - // Expected input: "HH:MM:SS" + // Expected input: "HH:MM" getDisplayTextForMilitaryTime(militaryTimeInput, shouldTrimMinutesIfEmpty = false) { let hours = parseInt(militaryTimeInput.split(":")[0]); const minutes = militaryTimeInput.split(":")[1]; 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 079df757d..24bb0e0eb 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 @@ -44,7 +44,6 @@ import buttonQuestion from "@/digital-components/button-question/button-question import timeSlotModalListButton from "./time-slot-modal-list-button/time-slot-modal-list-button"; // TODO: Move this somewhere more global -import { DAYS_OF_WEEK, MONTHS_OF_YEAR } from "@/digital-components/date-picker/mixins/constants.js"; import { defineRule, useField } from "vee-validate"; import { errorMessages } from "@/constants/error-messages"; import { required } from "@/helpers/validation-rules"; @@ -96,7 +95,7 @@ export default { // Run component validation that is used at parent level this.handleChange(this.modelValue.id); }, - dateAndTimeSlotData(newValue, oldValue) { + availableTimeSlots(newValue) { this.autoSelectTimeSlotIfOnlyOneIsAvailable(newValue); }, }, @@ -213,7 +212,7 @@ export default { } this.$emit("time-slot-modal-closed"); }, - // Expected input: "HH:MM:SS" + // Expected input: "HH:MM" getDisplayTextForMilitaryTime(militaryTimeInput) { let hours = parseInt(militaryTimeInput.split(":")[0]); const minutes = militaryTimeInput.split(":")[1]; @@ -286,17 +285,10 @@ export default { }, }; }, - autoSelectTimeSlotIfOnlyOneIsAvailable(newdateAndTimeSlotDataValue) { - const numberOfOptions = newdateAndTimeSlotDataValue?.timeSlots.length; - if ( - numberOfOptions === 1 && - !( - this.appointmentType === AppointmentTypeStrings.MOBILE && - this.premiumAppointmentFee && - newdateAndTimeSlotDataValue.timeSlots[0].offerPremium - ) - ) { - this.selectedTimeSlotId = newdateAndTimeSlotDataValue.timeSlots[0].id; + autoSelectTimeSlotIfOnlyOneIsAvailable(newAvailableTimeSlotsValue) { + const numberOfOptions = newAvailableTimeSlotsValue?.length; + if (numberOfOptions === 1) { + this.selectedTimeSlotId = newAvailableTimeSlotsValue[0].value; } }, addPremiumFlagToInput(timeSlotId) {