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",
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,12 +230,14 @@ export default {
const timeSlotSelectedObject = this.getTimeSlotObjectFromTimeSlotId(
this.selectedTimeSlotData.id
);
if (timeSlotSelectedObject) {
return {
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;
@ -276,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) {
@ -320,11 +328,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,18 +346,11 @@ 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
);
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";
// 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);
},
},
@ -159,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
@ -172,7 +171,7 @@ export default {
});
},
availableTimeSlots() {
if (this.dateAndTimeSlotData === null) {
if (!this.dateAndTimeSlotData) {
return null;
}
if (this.appointmentType === AppointmentTypeStrings.DROP_OFF) {
@ -190,34 +189,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 +284,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: {

View file

@ -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();
}
},
},