'use client'; import { usePathname, useRouter } from 'next/navigation'; import { useCallback } from 'react'; export const useScrollNavigation = () => { const pathname = usePathname(); const router = useRouter(); const handleNavClick = useCallback((id: string) => { if (typeof window === 'undefined') return; if (pathname === '/') { const el = document.getElementById(id); if (el) { el.scrollIntoView({ behavior: 'smooth', block: 'start' }); } } else { localStorage.setItem('scrollToId', id); router.push('/'); } }, [pathname, router]); const scrollToSection = useCallback((id: string) => { const el = document.getElementById(id); if (el) { el.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }, []); return { handleNavClick, scrollToSection }; };