"use client"; import React, { useState, useRef, useEffect } from "react"; import { FaAngleDown } from "react-icons/fa"; import { ProductDropdown, SolutionsDropdown, ResourcesDropdown } from "./dropdowns"; import MobileMenu from "./MobileMenu"; // Import the MobileMenu component const Navbar: React.FC = () => { const [showProduct, setShowProduct] = useState(false); const [showSolutions, setShowSolutions] = useState(false); const [showResources, setShowResources] = useState(false); const [activeTab, setActiveTab] = useState(null); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const navbarRef = useRef(null); // Reference for the navbar const toggleDropdown = (tab: string) => { if (activeTab === tab) { setActiveTab(null); setShowProduct(false); setShowSolutions(false); setShowResources(false); } else { setActiveTab(tab); setShowProduct(tab === "product"); setShowSolutions(tab === "solutions"); setShowResources(tab === "resources"); } }; const toggleMobileMenu = () => { setMobileMenuOpen(!mobileMenuOpen); }; // Close dropdowns when clicking outside the navbar useEffect(() => { const handleClickOutside = (event: MouseEvent) => { if (navbarRef.current && !navbarRef.current.contains(event.target as Node)) { setActiveTab(null); setShowProduct(false); setShowSolutions(false); setShowResources(false); } }; document.addEventListener("mousedown", handleClickOutside); return () => { document.removeEventListener("mousedown", handleClickOutside); }; }, []); return (
Logo {/* Desktop Menu */}
    {/* Product Menu */}
  • toggleDropdown("product")} > Product {activeTab === "product" && ( )}
  • {/* Solutions Menu */}
  • toggleDropdown("solutions")} > Solutions {activeTab === "solutions" && ( )}
  • {/* Pricing */}
  • Pricing
  • {/* Resources Menu */}
  • toggleDropdown("resources")} > Resources {activeTab === "resources" && ( )}
  • AI Agents
{/* Hamburger Icon for Mobile View */}
{/* Action Buttons */}
{/* Dropdowns for Desktop View */}
{showProduct && (
)} {showSolutions && (
)} {showResources && (
)}
{/* Mobile Menu */} {mobileMenuOpen && }
); }; export default Navbar;