diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 37bdc8622..ae2c4042c 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -235,7 +235,8 @@ export default { date: this.selectedDate.dateString, startTime: timeSlotSelectedObject.startTime, endTime: timeSlotSelectedObject.endTime, - id: this.selectedTimeSlotData.id, + routeCode: this.selectedTimeSlotData.id, + jobMaxMinutes: this.selectableDatesData.estimatedServiceMinutesMaximum, }; } else { return null; @@ -320,11 +321,11 @@ 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]; - let meridianNotation = hours > 11 ? "PM" : "AM"; + const meridianNotation = hours > 11 ? "PM" : "AM"; if (hours > 12) { hours -= 12; } @@ -338,15 +339,9 @@ export default { this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); }, async forwardButtonAction() { - //TODO: replace properties with real values once they are available await this.dispatchStoreAction( this.storeActions.SAVE_SCHEDULE, - { - date: "2023-07-04T00:00:00", - startTime: "2023-07-04T12:00:00", - endTime: "2023-07-04T17:00:00", - routeCode: "03341-01820-S-B*20232*11 AM", - }, + this.appointmentDateAndTime, false ); 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..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 @@ -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"; @@ -80,7 +79,6 @@ export default { data() { return { selectedTimeSlotId: null, - isSelectedAppointmentPremium: null, timeSlotModalListButton: timeSlotModalListButton, }; }, @@ -96,7 +94,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); }, }, @@ -190,34 +188,33 @@ 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; } 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]; - let meridianNotation = hours > 11 ? "PM" : "AM"; + const meridianNotation = hours > 11 ? "PM" : "AM"; if (hours > 12) { hours -= 12; } @@ -286,24 +283,17 @@ 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) { 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: {