import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Menu, X, Phone } from "lucide-react"; import { useLocation, useNavigate } from "react-router-dom"; const Navigation = () => { const [isOpen, setIsOpen] = useState(false); const location = useLocation(); const navigate = useNavigate(); const handleContactClick = (e: React.MouseEvent) => { e.preventDefault(); // If we're already on the home page, just scroll to contact section if (location.pathname === '/') { const contactSection = document.getElementById('contact'); if (contactSection) { contactSection.scrollIntoView({ behavior: 'smooth' }); } } else { // Navigate to home page and then scroll to contact section navigate('/'); // Use setTimeout to ensure the page has loaded before scrolling setTimeout(() => { const contactSection = document.getElementById('contact'); if (contactSection) { contactSection.scrollIntoView({ behavior: 'smooth' }); } }, 100); } }; const navItems = [ { name: "Home", href: "/" }, { name: "What We Do", href: "/what-we-do" }, { name: "Methods", href: "/methods" }, { name: "Employee Notices", href: "/employee-notice" }, { name: "Contact", href: "/#contact" }, ]; return ( ); }; export default Navigation;