"use client"; import { useState, useEffect } from "react"; interface PropertyNavProps { sections: { id: string; label: string }[]; } export default function PropertyNav({ sections }: PropertyNavProps) { const [activeSection, setActiveSection] = useState(sections[0]?.id || ""); useEffect(() => { const handleScroll = () => { const scrollPosition = window.scrollY + 200; for (const section of sections) { const element = document.getElementById(section.id); if (element) { const { offsetTop, offsetHeight } = element; if (scrollPosition >= offsetTop && scrollPosition < offsetTop + offsetHeight) { setActiveSection(section.id); break; } } } }; window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); }, [sections]); const scrollToSection = (id: string) => { const element = document.getElementById(id); if (element) { const offset = 150; // Account for sticky header const elementPosition = element.getBoundingClientRect().top; const offsetPosition = elementPosition + window.pageYOffset - offset; window.scrollTo({ top: offsetPosition, behavior: "smooth" }); } }; return (