import React from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { Link, useLocation } from 'react-router-dom'; import { useAuth } from '../context/AuthContext'; import logo from '../assets/logo.png'; const Layout = ({ children }) => { const { user } = useAuth(); const location = useLocation(); const isLanding = location.pathname === '/'; const [isMobileMenuOpen, setIsMobileMenuOpen] = React.useState(false); const navItems = [ { name: 'Product', href: '#ai-agent' }, { name: 'How it Flows', href: '#how-it-works' }, { name: 'Templates', href: '#templates' }, { name: 'Pricing', href: '#pricing' } ]; const [activeSection, setActiveSection] = React.useState('#ai-agent'); React.useEffect(() => { if (!isLanding) return; const timer = setTimeout(() => { const observerOptions = { root: null, rootMargin: '-30% 0px -60% 0px', threshold: 0 }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { if (entry.target.id === 'hero') { setActiveSection('#ai-agent'); } else { setActiveSection(`#${entry.target.id}`); } } }); }, observerOptions); const sectionsToObserve = ['hero', 'ai-agent', 'how-it-works', 'templates', 'pricing']; sectionsToObserve.forEach(id => { const el = document.getElementById(id); if (el) observer.observe(el); }); return () => observer.disconnect(); }, 100); return () => clearTimeout(timer); }, [isLanding]); return (
{/* TopNavBar */} {/* Page Content */}
{children}
{/* Footer */}
); }; export default Layout;