'use client' import { useEffect, useState } from 'react' import type { Category } from '@/data/menu' type Props = { categories: Category[] lang: string } export default function BottomTabBar({ categories, lang }: Props) { const l = lang as 'tr' | 'en' const [activeId, setActiveId] = useState(categories[0]?.id ?? '') useEffect(() => { const observers: IntersectionObserver[] = [] categories.forEach((cat) => { const el = document.getElementById(cat.id) if (!el) return const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { setActiveId(cat.id) } }) }, { rootMargin: '-20% 0px -75% 0px', threshold: 0 } ) observer.observe(el) observers.push(observer) }) return () => { observers.forEach((obs) => obs.disconnect()) } }, [categories]) return ( ) }