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

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