handled correct time slots

This commit is contained in:
Pramod Mahajan 2025-05-10 12:31:25 +05:30 committed by Vikas Nale
parent 2fbd7462d5
commit ea0c3b5ca7

View File

@ -120,15 +120,21 @@ const TimePicker = ({ label, onChange, interval = 10, value,checkInTime,checkOut
}, [value, interval, onChange]); }, [value, interval, onChange]);
useEffect(() => { useEffect(() => {
if (isOpen && time && slotRefs.current[time]) { if (isOpen) {
const selectedSlot = slotRefs.current[time]; const slots = generateTimeSlots();
selectedSlot.scrollIntoView({ 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", behavior: "smooth",
block: "center", block: "center",
}); });
} }
}, [isOpen, time]); }
}, [isOpen, time]);
return ( return (