From 6eb0ba28679147d53c5d3e3e3bd55f8c798740c5 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Fri, 26 May 2023 09:06:01 -0400 Subject: [PATCH 1/5] 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) { From c9776cfa60abb02ef2914c66d5cd6ddb9cf02a76 Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Fri, 26 May 2023 17:05:05 -0400 Subject: [PATCH 2/5] CSR-1419: fix issue so matching zips will still save and close --- .../mobile-location-modal-questions.vue | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue index fa5c1eb62..78094e76b 100644 --- a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue +++ b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue @@ -202,6 +202,7 @@ export default { this.internalModel = deepClone(this.modelValue); }, onModalClosed() { + this.displayInvalidZipAlert = false; this.internalModel = deepClone(this.modelValue); this.resetValidation(); }, @@ -236,17 +237,6 @@ export default { }); }, async setMobileLocation() { - // START - TEMP CODE FROM A CAOUETTE 5/25/23 TO BE REMOVED BY EOD - let tempTest = false; - let internalModelAddressQuestions = this.internalModel.addressQuestions; - let modelValueAddressQuestions = this.modelValue.addressQuestions; - if (tempTest) { - // THIS WILL NEVER BE TRUE - console.warn(internalModelAddressQuestions); - console.warn(modelValueAddressQuestions); - } - // END - TEMP CODE FROM A CAOUETTE 5/25/23 TO BE REMOVED BY EOD - if ( this.internalModel.addressQuestions.zipCode !== this.modelValue.addressQuestions.zipCode @@ -272,22 +262,19 @@ export default { this.$emit("updated-serviceability", serviceabilityDetails.data); this.$emit("updated-contains-military-base", zipCodeData.containsMilitaryBase); - // Update the page level model - this.$emit("update:modelValue", this.internalModel); - if (this.onZipUpdateCallback) { await this.onZipUpdateCallback(serviceZipCode); } + // Update the page level model + this.$emit("update:modelValue", this.internalModel); this.closeModal(); } } else { - // START - TEMP CODE FROM A CAOUETTE 5/25/23 TO BE REMOVED BY EOD - if (tempTest) { - // THIS WILL NEVER BE TRUE - console.warn("the zips match and the exception was run"); - } - // END - TEMP CODE FROM A CAOUETTE 5/25/23 TO BE REMOVED BY EOD + // Update the page level model + this.$emit("update:modelValue", this.internalModel); + + this.closeModal(); } }, }, From 5d6f1069b3656828f9d313b0c182b29f9649c352 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Tue, 30 May 2023 09:31:50 -0400 Subject: [PATCH 3/5] 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: { From da4813182ee6686a6a64e16b727be205cb17070f Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Tue, 30 May 2023 09:45:31 -0400 Subject: [PATCH 4/5] CSR-1137 | Refactor appointmentDateAndTime object --- src/layouts/schedule/schedule.vue | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 796bc043c..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; @@ -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 ); From 212cda21aada6f204de50591dfe42b63442b6660 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Tue, 30 May 2023 10:18:33 -0400 Subject: [PATCH 5/5] CSR-1144 Persist Schedule Data --- src/layouts/schedule/schedule.vue | 14 ++++++++++---- .../time-slot-modal-question.vue | 5 +++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index ae2c4042c..3717248f7 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -127,9 +127,9 @@ export default { name: "schedule", data() { return { - selectedDate: null, + selectedDate: this.getSelectedDate(), selectedTimeSlotData: { - id: null, + id: this.getSelectedRouteCode(), isPremiumAppointment: null, }, selectableDatesData: [], @@ -219,7 +219,7 @@ export default { if (this.selectedDate === null) { return null; } - return this.selectableDatesData.days.find( + return this.selectableDatesData.days?.find( (selectableDate) => selectableDate.dateString === this.selectedDate.dateString ); }, @@ -230,6 +230,7 @@ export default { const timeSlotSelectedObject = this.getTimeSlotObjectFromTimeSlotId( this.selectedTimeSlotData.id ); + if (timeSlotSelectedObject) { return { date: this.selectedDate.dateString, @@ -277,6 +278,12 @@ export default { ).timeSlots; return timeSlots.find((timeSlot) => timeSlot.id === timeSlotId); }, + getSelectedDate() { + return store.getters.order.schedule.date; + }, + getSelectedRouteCode() { + return store.getters.order.schedule.routeCode; + }, timeSlotModalClosed() { // Clear the selectedDate if no timeSlot has been selected if (!this.selectedTimeSlotData.id) { @@ -344,7 +351,6 @@ export default { this.appointmentDateAndTime, false ); - navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal }); }, }, 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 a622dd875..62d052941 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 @@ -157,9 +157,10 @@ export default { return false; }, dateSelectedReadableDate() { - if (this.dateAndTimeSlotData === null) { + if (!this.dateAndTimeSlotData) { return null; } + // This conversion ensures we don't get get GMT induced date changes const dateObject = new Date(`${this.dateAndTimeSlotData.dateString}T00:00:00`); // Ex: Tuesday, April 22 @@ -170,7 +171,7 @@ export default { }); }, availableTimeSlots() { - if (this.dateAndTimeSlotData === null) { + if (!this.dateAndTimeSlotData) { return null; } if (this.appointmentType === AppointmentTypeStrings.DROP_OFF) {