CASH-814 | Styling, cleanup, auto select, CMS integration
This commit is contained in:
parent
7bb1060d91
commit
c1a5dcdeef
4 changed files with 40 additions and 45 deletions
|
|
@ -407,7 +407,7 @@ export default {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-bottom: 1px solid black;
|
border-bottom: 1px solid black;
|
||||||
line-height: 1px;
|
line-height: 1px;
|
||||||
margin: 10px 0 20px;
|
margin: 20px 0 20px;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
|
|
|
||||||
|
|
@ -481,7 +481,7 @@ describe("date-picker.vue", () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const spy = jest.spyOn(wrapper.vm, "setCalendarData");
|
const spy = jest.spyOn(wrapper.vm, "setCalendarData");
|
||||||
|
wrapper.vm.$refs.timeSlotModalQuestion.initializeComponent = jest.fn();
|
||||||
wrapper.vm.$nextTick();
|
wrapper.vm.$nextTick();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,7 @@
|
||||||
dropoffCmsWidgetName="DropOffTimeSlotModal"
|
dropoffCmsWidgetName="DropOffTimeSlotModal"
|
||||||
sameDayDropOffCmsWidgetName="SameDayDropOffTimeSlotModal"
|
sameDayDropOffCmsWidgetName="SameDayDropOffTimeSlotModal"
|
||||||
overnightDropOffCmsWidgetName="OvernightDropOffTimeSlotModal"
|
overnightDropOffCmsWidgetName="OvernightDropOffTimeSlotModal"
|
||||||
|
dropOffOrPickATimeQuestionCmsWidgetName="DropOffOrPickATimeQuestionWidget"
|
||||||
:selectedDate="selectedDate"
|
:selectedDate="selectedDate"
|
||||||
:appointmentType="appointmentType"
|
:appointmentType="appointmentType"
|
||||||
:premiumAppointmentFee="premiumAppointmentFee"
|
:premiumAppointmentFee="premiumAppointmentFee"
|
||||||
|
|
@ -292,6 +293,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
initializeComponent(initialData) {
|
initializeComponent(initialData) {
|
||||||
this.setCalendarData(initialData);
|
this.setCalendarData(initialData);
|
||||||
|
this.$refs.timeSlotModalQuestion.initializeComponent();
|
||||||
},
|
},
|
||||||
fireDateSelectedEvent(event, date) {
|
fireDateSelectedEvent(event, date) {
|
||||||
// Ignore if arrow key selected radioButton
|
// Ignore if arrow key selected radioButton
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
<buttonQuestion
|
<buttonQuestion
|
||||||
v-if="isDropOffAppointmentAvailable"
|
v-if="isDropOffAppointmentAvailable"
|
||||||
v-model="selectedAnswerForDropOff"
|
v-model="selectedAnswerForDropOff"
|
||||||
questionText="Choose an option:"
|
:questionText="dropOffOrPickATimeQuestionLabelText"
|
||||||
:answers="answersForDropOffQuestion"
|
:answers="answersForDropOffQuestion"
|
||||||
isRequired
|
isRequired
|
||||||
insertOrLabelBeforeFinalOption
|
insertOrLabelBeforeFinalOption
|
||||||
|
|
@ -142,6 +142,7 @@ export default {
|
||||||
dropoffCmsWidgetName: String,
|
dropoffCmsWidgetName: String,
|
||||||
sameDayDropOffCmsWidgetName: String,
|
sameDayDropOffCmsWidgetName: String,
|
||||||
overnightDropOffCmsWidgetName: String,
|
overnightDropOffCmsWidgetName: String,
|
||||||
|
dropOffOrPickATimeQuestionCmsWidgetName: String,
|
||||||
appointmentType: String,
|
appointmentType: String,
|
||||||
timeSlotsForSelectedDate: Object,
|
timeSlotsForSelectedDate: Object,
|
||||||
premiumAppointmentFee: Object,
|
premiumAppointmentFee: Object,
|
||||||
|
|
@ -154,7 +155,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selectedRouteCode: this.getSelectedRouteCode(),
|
selectedRouteCode: null,
|
||||||
timeSlotModalListButton: timeSlotModalListButton,
|
timeSlotModalListButton: timeSlotModalListButton,
|
||||||
waitListRequested: this.getWaitListRequestedFromStore(),
|
waitListRequested: this.getWaitListRequestedFromStore(),
|
||||||
selectedAnswerForDropOff: null,
|
selectedAnswerForDropOff: null,
|
||||||
|
|
@ -193,7 +194,11 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
supplementalInformationBlock() {
|
supplementalInformationBlock() {
|
||||||
let appointmentTypeCmsWidgetName;
|
let appointmentTypeCmsWidgetName;
|
||||||
if (this.appointmentType === AppointmentTypeStrings.IN_SHOP) {
|
|
||||||
|
if (this.appointmentType === AppointmentTypeStrings.IN_SHOP_OR_DROP_OFF) {
|
||||||
|
// This is planned to be used again for drop-off
|
||||||
|
// Leaving this here with that in mind, move logic from the final else in here
|
||||||
|
// and only apply it when a dropoff slot is selected
|
||||||
return null;
|
return null;
|
||||||
} else if (this.appointmentType === AppointmentTypeStrings.MOBILE) {
|
} else if (this.appointmentType === AppointmentTypeStrings.MOBILE) {
|
||||||
appointmentTypeCmsWidgetName = this.selectedRouteCode?.includes(
|
appointmentTypeCmsWidgetName = this.selectedRouteCode?.includes(
|
||||||
|
|
@ -224,9 +229,16 @@ export default {
|
||||||
cmsWidgetFieldMappings.MODAL_CLOSE_BUTTON
|
cmsWidgetFieldMappings.MODAL_CLOSE_BUTTON
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
dropOffOrPickATimeQuestionLabelText() {
|
||||||
|
return this.getCmsContent(this.dropOffOrPickATimeQuestionCmsWidgetName, "QuestionText");
|
||||||
|
},
|
||||||
|
pickATimeButtonLabelText() {
|
||||||
|
return this.getCmsContent(this.dropOffOrPickATimeQuestionCmsWidgetName, "Answers")[0]
|
||||||
|
.Text;
|
||||||
|
},
|
||||||
premiumAppointmentButtonText() {
|
premiumAppointmentButtonText() {
|
||||||
return this.getCmsContent(
|
return this.getCmsContent(
|
||||||
this.mobilePremiumCmsWidgetName,
|
this.dropOffOrPickATimeQuestionCmsWidgetName,
|
||||||
cmsWidgetFieldMappings.TIME_SLOT_BUTTON
|
cmsWidgetFieldMappings.TIME_SLOT_BUTTON
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
@ -311,7 +323,7 @@ export default {
|
||||||
durationTextBlockCopy() {
|
durationTextBlockCopy() {
|
||||||
if (this.appointmentType === AppointmentTypeStrings.MOBILE) {
|
if (this.appointmentType === AppointmentTypeStrings.MOBILE) {
|
||||||
return null;
|
return null;
|
||||||
} else if (this.appointmentType === AppointmentTypeStrings.IN_SHOP) {
|
} else if (this.appointmentType === AppointmentTypeStrings.IN_SHOP_OR_DROP_OFF) {
|
||||||
if (this.selectedRouteCode?.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF)) {
|
if (this.selectedRouteCode?.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF)) {
|
||||||
return this.overnightDropoffDurationText;
|
return this.overnightDropoffDurationText;
|
||||||
} else if (this.selectedRouteCode?.includes(RouteCodeFlags.ALL_DAY_DROP_OFF)) {
|
} else if (this.selectedRouteCode?.includes(RouteCodeFlags.ALL_DAY_DROP_OFF)) {
|
||||||
|
|
@ -354,9 +366,7 @@ export default {
|
||||||
if (this.appointmentType === AppointmentTypeStrings.MOBILE) {
|
if (this.appointmentType === AppointmentTypeStrings.MOBILE) {
|
||||||
return this.getAvailableTimeSlotsForMobile(this.timeSlotsForSelectedDate.timeSlots);
|
return this.getAvailableTimeSlotsForMobile(this.timeSlotsForSelectedDate.timeSlots);
|
||||||
} else {
|
} else {
|
||||||
return this.getAvailableTimeSlotsForInshopOrDropOff(
|
return this.getAvailableTimeSlotsForInshop(this.timeSlotsForSelectedDate.timeSlots);
|
||||||
this.timeSlotsForSelectedDate.timeSlots
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
answersForDropOffQuestion() {
|
answersForDropOffQuestion() {
|
||||||
|
|
@ -387,7 +397,7 @@ export default {
|
||||||
) {
|
) {
|
||||||
dropOffQuestionAnswers.push({
|
dropOffQuestionAnswers.push({
|
||||||
value: PICK_A_TIME_BUTTON_VALUE,
|
value: PICK_A_TIME_BUTTON_VALUE,
|
||||||
buttonLabel: "Pick a time",
|
buttonLabel: this.pickATimeButtonLabelText,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return dropOffQuestionAnswers;
|
return dropOffQuestionAnswers;
|
||||||
|
|
@ -426,8 +436,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isDropOffAppointmentAvailable() {
|
isDropOffAppointmentAvailable() {
|
||||||
console.log("its running");
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
this.answersForDropOffQuestion !== null &&
|
this.answersForDropOffQuestion !== null &&
|
||||||
this.answersForDropOffQuestion.length !== 0 &&
|
this.answersForDropOffQuestion.length !== 0 &&
|
||||||
|
|
@ -442,6 +450,9 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
initializeComponent() {
|
||||||
|
this.setSelectedRouteCodeFromParent();
|
||||||
|
},
|
||||||
async setSelectedTimeSlot() {
|
async setSelectedTimeSlot() {
|
||||||
this.$emit(
|
this.$emit(
|
||||||
"update:modelValue",
|
"update:modelValue",
|
||||||
|
|
@ -474,26 +485,6 @@ export default {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getAvailableTimeSlotsForInshopOrDropOff(timeSlotsForSelectedDate) {
|
|
||||||
const availableTimeSlots = timeSlotsForSelectedDate.map((timeSlot) => {
|
|
||||||
let buttonLabelValue;
|
|
||||||
if (timeSlot.id.includes(RouteCodeFlags.ALL_DAY_DROP_OFF)) {
|
|
||||||
buttonLabelValue = this.dropoffButtonText;
|
|
||||||
} else if (timeSlot.id.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF)) {
|
|
||||||
buttonLabelValue = this.overnightDropoffButtonText;
|
|
||||||
} else if (this.isSameDay) {
|
|
||||||
buttonLabelValue = this.sameDayDropoffButtonText;
|
|
||||||
} else {
|
|
||||||
buttonLabelValue = militaryToTwelveHourTime(timeSlot.startTime);
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
value: timeSlot.id,
|
|
||||||
buttonLabel: buttonLabelValue,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return availableTimeSlots;
|
|
||||||
},
|
|
||||||
getAvailableTimeSlotsForMobile(timeSlotsForSelectedDate) {
|
getAvailableTimeSlotsForMobile(timeSlotsForSelectedDate) {
|
||||||
const availableTimeSlots = timeSlotsForSelectedDate.map((timeSlot) => {
|
const availableTimeSlots = timeSlotsForSelectedDate.map((timeSlot) => {
|
||||||
const readableTime = `${militaryToTwelveHourTime(timeSlot.startTime)} - ${militaryToTwelveHourTime(
|
const readableTime = `${militaryToTwelveHourTime(timeSlot.startTime)} - ${militaryToTwelveHourTime(
|
||||||
|
|
@ -529,27 +520,27 @@ export default {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getSelectedRouteCode() {
|
setSelectedRouteCodeFromParent() {
|
||||||
let selectedRouteCode;
|
|
||||||
if (!this.modelValue?.timeSlot) {
|
if (!this.modelValue?.timeSlot) {
|
||||||
selectedRouteCode = null;
|
return;
|
||||||
}
|
}
|
||||||
|
const routeCodeFromParent = this.modelValue.timeSlot.routeCode;
|
||||||
if (this.modelValue?.isPremiumAppointment) {
|
if (this.modelValue?.isPremiumAppointment) {
|
||||||
selectedRouteCode = this.addPremiumFlagToInput(
|
// Mobile Only
|
||||||
this.modelValue?.timeSlot?.routeCode
|
this.selectedAnswerForTimeSlots = this.addPremiumFlagToInput(routeCodeFromParent);
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
selectedRouteCode = this.modelValue?.timeSlot?.routeCode;
|
if (this.isDropOffRouteCode(routeCodeFromParent)) {
|
||||||
|
this.selectedAnswerForDropOff = routeCodeFromParent;
|
||||||
|
} else {
|
||||||
|
this.selectedAnswerForDropOff = PICK_A_TIME_BUTTON_VALUE;
|
||||||
|
this.selectedAnswerForTimeSlots = routeCodeFromParent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectedRouteCode;
|
|
||||||
},
|
},
|
||||||
getWaitListRequestedFromStore() {
|
getWaitListRequestedFromStore() {
|
||||||
return store.getters.order.customer?.waitListRequested;
|
return store.getters.order.customer?.waitListRequested;
|
||||||
},
|
},
|
||||||
autoSelectTimeSlotIfOnlyOneIsAvailable() {
|
autoSelectTimeSlotIfOnlyOneIsAvailable() {
|
||||||
console.log(this.timeSlotsForSelectedDate.timeSlots?.length);
|
|
||||||
const numberOfOptions = this.timeSlotsForSelectedDate.timeSlots?.length;
|
const numberOfOptions = this.timeSlotsForSelectedDate.timeSlots?.length;
|
||||||
if (numberOfOptions === 1) {
|
if (numberOfOptions === 1) {
|
||||||
if (this.availableTimeSlots.length > 0) {
|
if (this.availableTimeSlots.length > 0) {
|
||||||
|
|
@ -570,7 +561,6 @@ export default {
|
||||||
if (routeCodeIncludesPremium) {
|
if (routeCodeIncludesPremium) {
|
||||||
routeCode = this.removePremiumFlagFromInput(routeCode);
|
routeCode = this.removePremiumFlagFromInput(routeCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeSlot = this.timeSlotsForSelectedDate?.timeSlots?.find(
|
const timeSlot = this.timeSlotsForSelectedDate?.timeSlots?.find(
|
||||||
(slot) => slot.id == routeCode
|
(slot) => slot.id == routeCode
|
||||||
);
|
);
|
||||||
|
|
@ -611,6 +601,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isDropOffRouteCode(routeCode) {
|
isDropOffRouteCode(routeCode) {
|
||||||
|
if (!routeCode) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
routeCode.includes(RouteCodeFlags.ALL_DAY_DROP_OFF) ||
|
routeCode.includes(RouteCodeFlags.ALL_DAY_DROP_OFF) ||
|
||||||
routeCode.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF)
|
routeCode.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue