handled correct time slots

This commit is contained in:
Pramod Mahajan 2025-05-10 12:31:25 +05:30
parent 19e4962ef8
commit 349d2a62ff

View File

@ -121,13 +121,19 @@ const TimePicker = ({ label, onChange, interval = 10, value,checkInTime,checkOut
useEffect(() => {
if (isOpen && time && slotRefs.current[time]) {
const selectedSlot = slotRefs.current[time];
selectedSlot.scrollIntoView({
if (isOpen) {
const slots = generateTimeSlots();
const targetTime = slots.find(slot => slot.time === time && slot.isSelectable)
? time
: (slots.find(slot => slot.isSelectable)?.time || null);
if (targetTime && slotRefs.current[targetTime]) {
slotRefs.current[targetTime].scrollIntoView({
behavior: "smooth",
block: "center",
});
}
}
}, [isOpen, time]);