Checkpoint before trying to simplify
This commit is contained in:
parent
48654309de
commit
c0b02c8c00
3 changed files with 63 additions and 48 deletions
|
|
@ -4,7 +4,7 @@ const AppointmentTypeStrings = {
|
||||||
DROP_OFF: "Dropoff",
|
DROP_OFF: "Dropoff",
|
||||||
};
|
};
|
||||||
|
|
||||||
const PREMIUM_TIME_SLOT_ID_FLAG = "-premium";
|
const PREMIUM_TIME_SLOT_ID_FLAG = "-PREMIUM";
|
||||||
|
|
||||||
const PREMIUM_FEE_PART_TYPE = "EARLY BIRD";
|
const PREMIUM_FEE_PART_TYPE = "EARLY BIRD";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,17 +24,17 @@
|
||||||
<timeSlotModalQuestion
|
<timeSlotModalQuestion
|
||||||
ref="timeSlotModalQuestion"
|
ref="timeSlotModalQuestion"
|
||||||
customComponentId="timeSlotModalQuestion"
|
customComponentId="timeSlotModalQuestion"
|
||||||
|
v-model="selectedTimeSlot"
|
||||||
cmsWidgetName="TimeSlotModalQuestion"
|
cmsWidgetName="TimeSlotModalQuestion"
|
||||||
mobilePremiumCmsWidgetName="MobilePremiumTimeSlotModal"
|
mobilePremiumCmsWidgetName="MobilePremiumTimeSlotModal"
|
||||||
mobileCmsWidgetName="MobileTimeSlotModal"
|
mobileCmsWidgetName="MobileTimeSlotModal"
|
||||||
dropoffCmsWidgetName="DropOffTimeSlotModal"
|
dropoffCmsWidgetName="DropOffTimeSlotModal"
|
||||||
sameDayDropOffCmsWidgetName="SameDayDropOffTimeSlotModal"
|
sameDayDropOffCmsWidgetName="SameDayDropOffTimeSlotModal"
|
||||||
overnightDropOffCmsWidgetName="OvernightDropOffTimeSlotModal"
|
overnightDropOffCmsWidgetName="OvernightDropOffTimeSlotModal"
|
||||||
v-model="selectedTimeSlot"
|
|
||||||
:selectedDate="selectedDate"
|
:selectedDate="selectedDate"
|
||||||
:appointmentType="appointmentType"
|
:appointmentType="appointmentType"
|
||||||
:premiumAppointmentFee="mobilePremiumAppointmentFee"
|
:premiumAppointmentFee="mobilePremiumAppointmentFee"
|
||||||
:dateAndTimeSlotData="timeSlotsForSelectedDate"
|
:timeSlotsForSelectedDate="timeSlotsForSelectedDate"
|
||||||
:estimatedServiceMinutesMinimum="selectableDatesData.estimatedServiceMinutesMinimum"
|
:estimatedServiceMinutesMinimum="selectableDatesData.estimatedServiceMinutesMinimum"
|
||||||
:estimatedServiceMinutesMaximum="selectableDatesData.estimatedServiceMinutesMaximum"
|
:estimatedServiceMinutesMaximum="selectableDatesData.estimatedServiceMinutesMaximum"
|
||||||
@time-slot-modal-closed="timeSlotModalClosed"
|
@time-slot-modal-closed="timeSlotModalClosed"
|
||||||
|
|
@ -293,18 +293,22 @@ export default {
|
||||||
splitCopyOnCMSPlaceHolder,
|
splitCopyOnCMSPlaceHolder,
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
const serviceLocation = store.getters.order.serviceLocation;
|
const serviceLocation = store.getters.order.serviceLocation;
|
||||||
|
|
||||||
const serviceLocationPreReqs =
|
const serviceLocationPreReqs =
|
||||||
serviceLocation.zipCode &&
|
serviceLocation.zipCode &&
|
||||||
serviceLocation.zipCodeCtu &&
|
serviceLocation.zipCodeCtu &&
|
||||||
serviceLocation.appointmentType &&
|
serviceLocation.appointmentType &&
|
||||||
(serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE ||
|
(serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE ||
|
||||||
serviceLocation.provider.providerNumber);
|
serviceLocation.provider.providerNumber);
|
||||||
|
|
||||||
const paymentInfo = store.getters.payment.isInsurance !== null;
|
const paymentInfo = store.getters.payment.isInsurance !== null;
|
||||||
const supportingItems = store.getters.lineItems.supportingItems !== null;
|
const supportingItems = store.getters.lineItems.supportingItems !== null;
|
||||||
|
|
||||||
const damageInfo =
|
const damageInfo =
|
||||||
store.getters.order.damage.isRepair ||
|
store.getters.order.damage.isRepair ||
|
||||||
(store.getters.order.lineItems?.glassParts != null &&
|
(store.getters.order.lineItems?.glassParts != null &&
|
||||||
store.getters.order.lineItems.glassParts.length > 0);
|
store.getters.order.lineItems.glassParts.length > 0);
|
||||||
|
|
||||||
return serviceLocationPreReqs && paymentInfo && supportingItems && damageInfo;
|
return serviceLocationPreReqs && paymentInfo && supportingItems && damageInfo;
|
||||||
},
|
},
|
||||||
async getAvailableDatesMethod(startDate, endDate) {
|
async getAvailableDatesMethod(startDate, endDate) {
|
||||||
|
|
@ -327,14 +331,19 @@ export default {
|
||||||
openInshopTimeSlotsModal() {
|
openInshopTimeSlotsModal() {
|
||||||
this.$refs["timeSlotModalQuestion"].openModal();
|
this.$refs["timeSlotModalQuestion"].openModal();
|
||||||
},
|
},
|
||||||
getSelectedTimeSlot() {
|
|
||||||
return store.getters.order.schedule;
|
|
||||||
},
|
|
||||||
getSelectedDate() {
|
getSelectedDate() {
|
||||||
return store.getters.order.schedule.date;
|
return store.getters.order.schedule.date;
|
||||||
},
|
},
|
||||||
getSelectedRouteCode() {
|
getSelectedTimeSlot() {
|
||||||
return store.getters.order.schedule.routeCode;
|
const supportingItems = this.getSupportingItems();
|
||||||
|
const isPremiumAppointment = !!supportingItems.filter(
|
||||||
|
(lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE
|
||||||
|
).length > 0;
|
||||||
|
|
||||||
|
const selectedTimeSlot = store.getters.order.schedule;
|
||||||
|
selectedTimeSlot.isPremiumAppointment = isPremiumAppointment
|
||||||
|
|
||||||
|
return selectedTimeSlot;
|
||||||
},
|
},
|
||||||
getSupportingItems() {
|
getSupportingItems() {
|
||||||
return store.getters.lineItems.supportingItems;
|
return store.getters.lineItems.supportingItems;
|
||||||
|
|
@ -376,8 +385,8 @@ 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"
|
|
||||||
getDisplayTextForMilitaryTime(militaryTimeInput, shouldTrimMinutesIfEmpty = false) {
|
getDisplayTextForMilitaryTime(militaryTimeInput, shouldTrimMinutesIfEmpty = false) {
|
||||||
|
// Expected input: "HH:MM"
|
||||||
let hours = parseInt(militaryTimeInput.split(":")[0]);
|
let hours = parseInt(militaryTimeInput.split(":")[0]);
|
||||||
const minutes = militaryTimeInput.split(":")[1];
|
const minutes = militaryTimeInput.split(":")[1];
|
||||||
const meridianNotation = hours > 11 ? "PM" : "AM";
|
const meridianNotation = hours > 11 ? "PM" : "AM";
|
||||||
|
|
@ -395,6 +404,10 @@ export default {
|
||||||
},
|
},
|
||||||
forwardButtonAction() {
|
forwardButtonAction() {
|
||||||
this.updateSupportingItems();
|
this.updateSupportingItems();
|
||||||
|
|
||||||
|
// Remove the isPremiumAppointment flag to ensure it never gets into the store
|
||||||
|
delete this.selectedTimeSlot.isPremiumAppointment;
|
||||||
|
|
||||||
this.dispatchStoreAction(this.storeActions.SAVE_SCHEDULE, this.selectedTimeSlot, false);
|
this.dispatchStoreAction(this.storeActions.SAVE_SCHEDULE, this.selectedTimeSlot, false);
|
||||||
|
|
||||||
this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD, this.$route);
|
this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD, this.$route);
|
||||||
|
|
@ -455,6 +468,7 @@ export default {
|
||||||
endTime: null,
|
endTime: null,
|
||||||
jobMaxMinutes: null,
|
jobMaxMinutes: null,
|
||||||
jobMinMinutes: null,
|
jobMinMinutes: null,
|
||||||
|
isPremiumAppointment: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
:answers="availableTimeSlots"
|
:answers="availableTimeSlots"
|
||||||
groupName="chooseTimeSlot"
|
groupName="chooseTimeSlot"
|
||||||
textPosition="text-center"
|
textPosition="text-center"
|
||||||
v-model="selectedTimeSlotId"
|
v-model="selectedRouteCode"
|
||||||
isRequired
|
isRequired
|
||||||
validationRules="time-slot-required" />
|
validationRules="time-slot-required" />
|
||||||
<div
|
<div
|
||||||
|
|
@ -84,17 +84,7 @@ export default {
|
||||||
name: "time-slot-modal-question",
|
name: "time-slot-modal-question",
|
||||||
emits: ["update:modelValue"],
|
emits: ["update:modelValue"],
|
||||||
props: {
|
props: {
|
||||||
modelValue: {
|
modelValue: Object,
|
||||||
type: Object,
|
|
||||||
default: () => ({
|
|
||||||
routeCode: null,
|
|
||||||
date: null,
|
|
||||||
startTime: null,
|
|
||||||
endTime: null,
|
|
||||||
jobMaxMinutes: null,
|
|
||||||
jobMinMinutes: null,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
cmsWidgetName: String,
|
cmsWidgetName: String,
|
||||||
mobileCmsWidgetName: String,
|
mobileCmsWidgetName: String,
|
||||||
mobilePremiumCmsWidgetName: String,
|
mobilePremiumCmsWidgetName: String,
|
||||||
|
|
@ -102,7 +92,7 @@ export default {
|
||||||
sameDayDropOffCmsWidgetName: String,
|
sameDayDropOffCmsWidgetName: String,
|
||||||
overnightDropOffCmsWidgetName: String,
|
overnightDropOffCmsWidgetName: String,
|
||||||
appointmentType: String,
|
appointmentType: String,
|
||||||
dateAndTimeSlotData: Object,
|
timeSlotsForSelectedDate: Object,
|
||||||
premiumAppointmentFee: Object,
|
premiumAppointmentFee: Object,
|
||||||
estimatedServiceMinutesMinimum: Number,
|
estimatedServiceMinutesMinimum: Number,
|
||||||
estimatedServiceMinutesMaximum: Number,
|
estimatedServiceMinutesMaximum: Number,
|
||||||
|
|
@ -113,7 +103,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isModalOpened: false,
|
isModalOpened: false,
|
||||||
selectedValue: null,
|
selectedRouteCode: this.getSelectedRouteCode(),
|
||||||
timeSlotModalListButton: timeSlotModalListButton,
|
timeSlotModalListButton: timeSlotModalListButton,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
@ -150,14 +140,8 @@ export default {
|
||||||
modalName() {
|
modalName() {
|
||||||
return "timeSlots";
|
return "timeSlots";
|
||||||
},
|
},
|
||||||
selectedTimeSlotId: {
|
modal() {
|
||||||
get: function () {
|
return this.$refs[this.modalName];
|
||||||
return this.modelValue?.routeCode;
|
|
||||||
},
|
|
||||||
set: function (newValue) {
|
|
||||||
// Button Question only supports Number, or String data types so we must convert to the full object before emitting
|
|
||||||
this.selectedValue = this.getSelectedTimeSlotObject(newValue);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
supplementalInformationBlock() {
|
supplementalInformationBlock() {
|
||||||
let appointmentTypeCmsWidgetName;
|
let appointmentTypeCmsWidgetName;
|
||||||
|
|
@ -295,21 +279,21 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isSameDay() {
|
isSameDay() {
|
||||||
if (!this.dateAndTimeSlotData) {
|
if (!this.timeSlotsForSelectedDate) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedDate = this.dateAndTimeSlotData.date;
|
const selectedDate = this.timeSlotsForSelectedDate.date;
|
||||||
const todaysDate = new Date().toISOString().split("T")[0];
|
const todaysDate = new Date().toISOString().split("T")[0];
|
||||||
return selectedDate === todaysDate;
|
return selectedDate === todaysDate;
|
||||||
},
|
},
|
||||||
dateSelectedReadableDate() {
|
dateSelectedReadableDate() {
|
||||||
if (!this.dateAndTimeSlotData) {
|
if (!this.timeSlotsForSelectedDate) {
|
||||||
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 = convertDateStringToDate(this.dateAndTimeSlotData.date);
|
const dateObject = convertDateStringToDate(this.timeSlotsForSelectedDate.date);
|
||||||
// Ex: Tuesday, April 22
|
// Ex: Tuesday, April 22
|
||||||
return dateObject.toLocaleDateString("en-us", {
|
return dateObject.toLocaleDateString("en-us", {
|
||||||
weekday: "long",
|
weekday: "long",
|
||||||
|
|
@ -318,21 +302,18 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
availableTimeSlots() {
|
availableTimeSlots() {
|
||||||
if (!this.dateAndTimeSlotData) {
|
if (!this.timeSlotsForSelectedDate) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.appointmentType === AppointmentTypeStrings.DROP_OFF) {
|
if (this.appointmentType === AppointmentTypeStrings.DROP_OFF) {
|
||||||
return this.getAvailableTimeSlotsForDropOff(this.dateAndTimeSlotData.timeSlots);
|
return this.getAvailableTimeSlotsForDropOff(this.timeSlotsForSelectedDate.timeSlots);
|
||||||
} else if (this.appointmentType === AppointmentTypeStrings.MOBILE) {
|
} else if (this.appointmentType === AppointmentTypeStrings.MOBILE) {
|
||||||
return this.getAvailableTimeSlotsForMobile(this.dateAndTimeSlotData.timeSlots);
|
return this.getAvailableTimeSlotsForMobile(this.timeSlotsForSelectedDate.timeSlots);
|
||||||
} else {
|
} else {
|
||||||
return this.getAvailableTimeSlotsForInshop(this.dateAndTimeSlotData.timeSlots);
|
return this.getAvailableTimeSlotsForInshop(this.timeSlotsForSelectedDate.timeSlots);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modal() {
|
|
||||||
return this.$refs[this.modalName];
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openModal() {
|
openModal() {
|
||||||
|
|
@ -348,7 +329,7 @@ export default {
|
||||||
this.$emit("time-slot-modal-closed");
|
this.$emit("time-slot-modal-closed");
|
||||||
},
|
},
|
||||||
async setSelectedTimeSlot() {
|
async setSelectedTimeSlot() {
|
||||||
this.$emit("update:modelValue", this.selectedValue);
|
this.$emit("update:modelValue", this.getSelectedTimeSlotObject(this.selectedRouteCode));
|
||||||
this.closeModal();
|
this.closeModal();
|
||||||
},
|
},
|
||||||
getRelevantDropOffCmsWidgetNameForSelectedTimeSlot(
|
getRelevantDropOffCmsWidgetNameForSelectedTimeSlot(
|
||||||
|
|
@ -416,6 +397,7 @@ export default {
|
||||||
getPremiumAppointmentTimeSlot(timeSlotData) {
|
getPremiumAppointmentTimeSlot(timeSlotData) {
|
||||||
const formattedPrice =
|
const formattedPrice =
|
||||||
"+$" + this.getTotalLineItemPrice(this.premiumAppointmentFee).toFixed(2);
|
"+$" + this.getTotalLineItemPrice(this.premiumAppointmentFee).toFixed(2);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// Unique value is required for each <input> and the premium appoinment shares a timeSlot ID
|
// Unique value is required for each <input> and the premium appoinment shares a timeSlot ID
|
||||||
value: this.addPremiumFlagToInput(timeSlotData.id),
|
value: this.addPremiumFlagToInput(timeSlotData.id),
|
||||||
|
|
@ -426,31 +408,49 @@ export default {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
getSelectedRouteCode() {
|
||||||
|
if (!this.modelValue?.routeCode) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.modelValue?.isPremiumAppointment) {
|
||||||
|
return this.addPremiumFlagToInput(this.modelValue?.routeCode);
|
||||||
|
} else {
|
||||||
|
return this.modelValue?.routeCode;
|
||||||
|
}
|
||||||
|
},
|
||||||
autoSelectTimeSlotIfOnlyOneIsAvailable(newAvailableTimeSlotsValue) {
|
autoSelectTimeSlotIfOnlyOneIsAvailable(newAvailableTimeSlotsValue) {
|
||||||
const numberOfOptions = newAvailableTimeSlotsValue?.length;
|
const numberOfOptions = newAvailableTimeSlotsValue?.length;
|
||||||
if (numberOfOptions === 1) {
|
if (numberOfOptions === 1) {
|
||||||
this.selectedTimeSlotId = newAvailableTimeSlotsValue[0].value;
|
this.selectedRouteCode = newAvailableTimeSlotsValue[0].value;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addPremiumFlagToInput(timeSlotId) {
|
addPremiumFlagToInput(timeSlotId) {
|
||||||
return (timeSlotId += PREMIUM_TIME_SLOT_ID_FLAG);
|
return (timeSlotId += PREMIUM_TIME_SLOT_ID_FLAG);
|
||||||
},
|
},
|
||||||
removePremiumFlagFromInput(timeSlotId) {
|
removePremiumFlagFromInput(timeSlotId) {
|
||||||
return timeSlotId.substring(0, timeSlotId.length - PREMIUM_TIME_SLOT_ID_FLAG.length);
|
return timeSlotId.replace(PREMIUM_TIME_SLOT_ID_FLAG, "");
|
||||||
},
|
},
|
||||||
getSelectedTimeSlotObject(timeSlotId) {
|
getSelectedTimeSlotObject(timeSlotId) {
|
||||||
const timeSlot = this.dateAndTimeSlotData?.timeSlots?.find(
|
console.log(timeSlotId)
|
||||||
|
const timeSlotIdIncludesPremium = timeSlotId?.includes(PREMIUM_TIME_SLOT_ID_FLAG);
|
||||||
|
if (timeSlotIdIncludesPremium) {
|
||||||
|
timeSlotId = this.removePremiumFlagFromInput(timeSlotId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeSlot = this.timeSlotsForSelectedDate?.timeSlots?.find(
|
||||||
(timeSlot) => timeSlot.id == timeSlotId
|
(timeSlot) => timeSlot.id == timeSlotId
|
||||||
);
|
);
|
||||||
|
|
||||||
if (timeSlot) {
|
if (timeSlot) {
|
||||||
return {
|
return {
|
||||||
date: this.dateAndTimeSlotData.date,
|
date: this.timeSlotsForSelectedDate.date,
|
||||||
routeCode: timeSlot.id,
|
routeCode: timeSlot.id,
|
||||||
startTime: timeSlot.startTime,
|
startTime: timeSlot.startTime,
|
||||||
endTime: timeSlot.endTime,
|
endTime: timeSlot.endTime,
|
||||||
jobMaxMinutes: this.estimatedServiceMinutesMaximum.toString(),
|
jobMaxMinutes: this.estimatedServiceMinutesMaximum.toString(),
|
||||||
jobMinMinutes: this.estimatedServiceMinutesMinimum.toString(),
|
jobMinMinutes: this.estimatedServiceMinutesMinimum.toString(),
|
||||||
|
isPremiumAppointment: timeSlotIdIncludesPremium ? true : false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -461,6 +461,7 @@ export default {
|
||||||
routeCode: null,
|
routeCode: null,
|
||||||
jobMaxMinutes: null,
|
jobMaxMinutes: null,
|
||||||
jobMinMinutes: null,
|
jobMinMinutes: null,
|
||||||
|
isPremiumAppointment: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue