+
{hourlySlots.map((tm, idx) => {
var formattedDate = moment(selectedDate).format("MM/DD/YY");
var fromTime = new Date(formattedDate + " " + from);
@@ -120,29 +199,66 @@ const DateTimePicker = ({ defaultDate, register, fieldNames, setValue, showCalen
var json = scheduleTemplate.custom_slots ?? "[]";
var custom_slots_obj = parseJsonSafely(json, {});
var custom_slots = custom_slots_obj[formattedDate] ?? [];
- custom_slots = custom_slots.map((slot) => ({ fromTime: new Date(slot.start), toTime: new Date(slot.end) }));
- var template_slots = Array.isArray(scheduleTemplate.slots) ? scheduleTemplate.slots.map((slot) => ({ fromTime: new Date(slot.start), toTime: new Date(slot.end) })) : [];
+ custom_slots = custom_slots.map((slot) => ({
+ fromTime: new Date(slot.start),
+ toTime: new Date(slot.end),
+ }));
+ var template_slots = Array.isArray(scheduleTemplate.slots)
+ ? scheduleTemplate.slots.map((slot) => ({
+ fromTime: new Date(slot.start),
+ toTime: new Date(slot.end),
+ }))
+ : [];
+
+ // --- NEW: Check if slot is booked ---
+ const slotBooked = isSlotBooked(slotTime);
return (
-
+ {/* Error message for invalid time range */}
+ {error && (
+
{error}
+ )}
+
-
-
From - {from}
+
+
From - {from}
Until - {to}
@@ -208,4 +336,4 @@ const DateTimePicker = ({ defaultDate, register, fieldNames, setValue, showCalen
);
};
-export default DateTimePicker;
\ No newline at end of file
+export default DateTimePicker;