Merge branch 'develop' into feature/CSR-1109

This commit is contained in:
Leah Schumann 2023-05-31 07:02:49 -04:00
commit 4e6d9b654a
3 changed files with 39 additions and 60 deletions

View file

@ -127,9 +127,9 @@ export default {
name: "schedule", name: "schedule",
data() { data() {
return { return {
selectedDate: null, selectedDate: this.getSelectedDate(),
selectedTimeSlotData: { selectedTimeSlotData: {
id: null, id: this.getSelectedRouteCode(),
isPremiumAppointment: null, isPremiumAppointment: null,
}, },
selectableDatesData: [], selectableDatesData: [],
@ -219,7 +219,7 @@ export default {
if (this.selectedDate === null) { if (this.selectedDate === null) {
return null; return null;
} }
return this.selectableDatesData.days.find( return this.selectableDatesData.days?.find(
(selectableDate) => selectableDate.dateString === this.selectedDate.dateString (selectableDate) => selectableDate.dateString === this.selectedDate.dateString
); );
}, },
@ -230,12 +230,14 @@ export default {
const timeSlotSelectedObject = this.getTimeSlotObjectFromTimeSlotId( const timeSlotSelectedObject = this.getTimeSlotObjectFromTimeSlotId(
this.selectedTimeSlotData.id this.selectedTimeSlotData.id
); );
if (timeSlotSelectedObject) { if (timeSlotSelectedObject) {
return { return {
date: this.selectedDate.dateString, date: this.selectedDate.dateString,
startTime: timeSlotSelectedObject.startTime, startTime: timeSlotSelectedObject.startTime,
endTime: timeSlotSelectedObject.endTime, endTime: timeSlotSelectedObject.endTime,
id: this.selectedTimeSlotData.id, routeCode: this.selectedTimeSlotData.id,
jobMaxMinutes: this.selectableDatesData.estimatedServiceMinutesMaximum,
}; };
} else { } else {
return null; return null;
@ -276,6 +278,12 @@ export default {
).timeSlots; ).timeSlots;
return timeSlots.find((timeSlot) => timeSlot.id === timeSlotId); return timeSlots.find((timeSlot) => timeSlot.id === timeSlotId);
}, },
getSelectedDate() {
return store.getters.order.schedule.date;
},
getSelectedRouteCode() {
return store.getters.order.schedule.routeCode;
},
timeSlotModalClosed() { timeSlotModalClosed() {
// Clear the selectedDate if no timeSlot has been selected // Clear the selectedDate if no timeSlot has been selected
if (!this.selectedTimeSlotData.id) { if (!this.selectedTimeSlotData.id) {
@ -320,11 +328,11 @@ export default {
// Ex: April 25 // Ex: April 25
return dateObject.toLocaleDateString("en-us", { month: "short", day: "numeric" }); return dateObject.toLocaleDateString("en-us", { month: "short", day: "numeric" });
}, },
// Expected input: "HH:MM:SS" // Expected input: "HH:MM"
getDisplayTextForMilitaryTime(militaryTimeInput, shouldTrimMinutesIfEmpty = false) { getDisplayTextForMilitaryTime(militaryTimeInput, shouldTrimMinutesIfEmpty = false) {
let hours = parseInt(militaryTimeInput.split(":")[0]); let hours = parseInt(militaryTimeInput.split(":")[0]);
const minutes = militaryTimeInput.split(":")[1]; const minutes = militaryTimeInput.split(":")[1];
let meridianNotation = hours > 11 ? "PM" : "AM"; const meridianNotation = hours > 11 ? "PM" : "AM";
if (hours > 12) { if (hours > 12) {
hours -= 12; hours -= 12;
} }
@ -338,18 +346,11 @@ export default {
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
}, },
async forwardButtonAction() { async forwardButtonAction() {
//TODO: replace properties with real values once they are available
await this.dispatchStoreAction( await this.dispatchStoreAction(
this.storeActions.SAVE_SCHEDULE, this.storeActions.SAVE_SCHEDULE,
{ this.appointmentDateAndTime,
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",
},
false false
); );
navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal }); navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal });
}, },
}, },

View file

@ -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"; import timeSlotModalListButton from "./time-slot-modal-list-button/time-slot-modal-list-button";
// TODO: Move this somewhere more global // 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 { defineRule, useField } from "vee-validate";
import { errorMessages } from "@/constants/error-messages"; import { errorMessages } from "@/constants/error-messages";
import { required } from "@/helpers/validation-rules"; import { required } from "@/helpers/validation-rules";
@ -80,7 +79,6 @@ export default {
data() { data() {
return { return {
selectedTimeSlotId: null, selectedTimeSlotId: null,
isSelectedAppointmentPremium: null,
timeSlotModalListButton: timeSlotModalListButton, timeSlotModalListButton: timeSlotModalListButton,
}; };
}, },
@ -96,7 +94,7 @@ export default {
// Run component validation that is used at parent level // Run component validation that is used at parent level
this.handleChange(this.modelValue.id); this.handleChange(this.modelValue.id);
}, },
dateAndTimeSlotData(newValue, oldValue) { availableTimeSlots(newValue) {
this.autoSelectTimeSlotIfOnlyOneIsAvailable(newValue); this.autoSelectTimeSlotIfOnlyOneIsAvailable(newValue);
}, },
}, },
@ -159,9 +157,10 @@ export default {
return false; return false;
}, },
dateSelectedReadableDate() { dateSelectedReadableDate() {
if (this.dateAndTimeSlotData === null) { if (!this.dateAndTimeSlotData) {
return null; return null;
} }
// This conversion ensures we don't get get GMT induced date changes // This conversion ensures we don't get get GMT induced date changes
const dateObject = new Date(`${this.dateAndTimeSlotData.dateString}T00:00:00`); const dateObject = new Date(`${this.dateAndTimeSlotData.dateString}T00:00:00`);
// Ex: Tuesday, April 22 // Ex: Tuesday, April 22
@ -172,7 +171,7 @@ export default {
}); });
}, },
availableTimeSlots() { availableTimeSlots() {
if (this.dateAndTimeSlotData === null) { if (!this.dateAndTimeSlotData) {
return null; return null;
} }
if (this.appointmentType === AppointmentTypeStrings.DROP_OFF) { if (this.appointmentType === AppointmentTypeStrings.DROP_OFF) {
@ -190,34 +189,33 @@ export default {
}, },
// fires any time the footer button is used, is fired before "onModalClosed" // fires any time the footer button is used, is fired before "onModalClosed"
closeModal() { 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.selectedTimeSlotId = this.removePremiumFlagFromInput(this.selectedTimeSlotId);
this.isSelectedAppointmentPremium = true; isSelectedAppointmentPremium = true;
} else {
this.isSelectedAppointmentPremium = false;
} }
const selectedTimeSlotData = { const selectedTimeSlotData = {
id: this.selectedTimeSlotId, id: this.selectedTimeSlotId,
isPremiumAppointment: this.isSelectedAppointmentPremium, isPremiumAppointment: isSelectedAppointmentPremium,
}; };
this.$emit("update:modelValue", selectedTimeSlotData); this.$emit("update:modelValue", selectedTimeSlotData);
this.$refs["timeSlots"].closeModal(); this.$refs["timeSlots"].closeModal();
}, },
// fires any time the modal is closed, AFTER "closeModal" fires if footer button is used // fires any time the modal is closed, AFTER "closeModal" fires if footer button is used
onModalClosed() { onModalClosed() {
this.isSelectedAppointmentPremium = this.modelValue.isPremiumAppointment; // Reset component state to parent's state
if (this.isSelectedAppointmentPremium) { if (this.modelValue.isPremiumAppointment) {
this.selectedTimeSlotId = this.addPremiumFlagToInput(this.modelValue.id); this.selectedTimeSlotId = this.addPremiumFlagToInput(this.modelValue.id);
} else { } else {
this.selectedTimeSlotId = this.modelValue.id; this.selectedTimeSlotId = this.modelValue.id;
} }
this.$emit("time-slot-modal-closed"); this.$emit("time-slot-modal-closed");
}, },
// Expected input: "HH:MM:SS" // Expected input: "HH:MM"
getDisplayTextForMilitaryTime(militaryTimeInput) { getDisplayTextForMilitaryTime(militaryTimeInput) {
let hours = parseInt(militaryTimeInput.split(":")[0]); let hours = parseInt(militaryTimeInput.split(":")[0]);
const minutes = militaryTimeInput.split(":")[1]; const minutes = militaryTimeInput.split(":")[1];
let meridianNotation = hours > 11 ? "PM" : "AM"; const meridianNotation = hours > 11 ? "PM" : "AM";
if (hours > 12) { if (hours > 12) {
hours -= 12; hours -= 12;
} }
@ -286,24 +284,17 @@ export default {
}, },
}; };
}, },
autoSelectTimeSlotIfOnlyOneIsAvailable(newdateAndTimeSlotDataValue) { autoSelectTimeSlotIfOnlyOneIsAvailable(newAvailableTimeSlotsValue) {
const numberOfOptions = newdateAndTimeSlotDataValue?.timeSlots.length; const numberOfOptions = newAvailableTimeSlotsValue?.length;
if ( if (numberOfOptions === 1) {
numberOfOptions === 1 && this.selectedTimeSlotId = newAvailableTimeSlotsValue[0].value;
!(
this.appointmentType === AppointmentTypeStrings.MOBILE &&
this.premiumAppointmentFee &&
newdateAndTimeSlotDataValue.timeSlots[0].offerPremium
)
) {
this.selectedTimeSlotId = newdateAndTimeSlotDataValue.timeSlots[0].id;
} }
}, },
addPremiumFlagToInput(timeSlotId) { addPremiumFlagToInput(timeSlotId) {
return (timeSlotId += PREMIUM_TIME_SLOT_ID_FLAG); return (timeSlotId += PREMIUM_TIME_SLOT_ID_FLAG);
}, },
removePremiumFlagFromInput(timeSlotId) { 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: { components: {

View file

@ -202,6 +202,7 @@ export default {
this.internalModel = deepClone(this.modelValue); this.internalModel = deepClone(this.modelValue);
}, },
onModalClosed() { onModalClosed() {
this.displayInvalidZipAlert = false;
this.internalModel = deepClone(this.modelValue); this.internalModel = deepClone(this.modelValue);
this.resetValidation(); this.resetValidation();
}, },
@ -236,17 +237,6 @@ export default {
}); });
}, },
async setMobileLocation() { 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 ( if (
this.internalModel.addressQuestions.zipCode !== this.internalModel.addressQuestions.zipCode !==
this.modelValue.addressQuestions.zipCode this.modelValue.addressQuestions.zipCode
@ -272,22 +262,19 @@ export default {
this.$emit("updated-serviceability", serviceabilityDetails.data); this.$emit("updated-serviceability", serviceabilityDetails.data);
this.$emit("updated-contains-military-base", zipCodeData.containsMilitaryBase); this.$emit("updated-contains-military-base", zipCodeData.containsMilitaryBase);
// Update the page level model
this.$emit("update:modelValue", this.internalModel);
if (this.onZipUpdateCallback) { if (this.onZipUpdateCallback) {
await this.onZipUpdateCallback(serviceZipCode); await this.onZipUpdateCallback(serviceZipCode);
} }
// Update the page level model
this.$emit("update:modelValue", this.internalModel);
this.closeModal(); this.closeModal();
} }
} else { } else {
// START - TEMP CODE FROM A CAOUETTE 5/25/23 TO BE REMOVED BY EOD // Update the page level model
if (tempTest) { this.$emit("update:modelValue", this.internalModel);
// THIS WILL NEVER BE TRUE
console.warn("the zips match and the exception was run"); this.closeModal();
}
// END - TEMP CODE FROM A CAOUETTE 5/25/23 TO BE REMOVED BY EOD
} }
}, },
}, },