"use client"; import React, { useState, useEffect } from "react"; import Link from "next/link"; interface MenuItem { label: string; href: string; submenu?: MenuItem[]; } interface MobileMenuProps { isOpen: boolean; onClose: () => void; menuItems: MenuItem[]; } const MobileMenu: React.FC = ({ isOpen, onClose, menuItems }) => { const [expandedItems, setExpandedItems] = useState<{ [key: string]: boolean }>({}); // Disable body scroll when menu is open useEffect(() => { if (isOpen) { document.body.style.overflow = "hidden"; } else { document.body.style.overflow = ""; } return () => { document.body.style.overflow = ""; }; }, [isOpen]); const toggleSubmenu = (path: string) => { setExpandedItems((prev) => ({ ...prev, [path]: !prev[path], })); }; const handleLinkClick = () => { onClose(); }; // Recursive component for rendering menu items with nested submenus const renderMenuItem = (item: MenuItem, index: number, parentPath: string = "", level: number = 0) => { const currentPath = parentPath ? `${parentPath}-${index}` : `${index}`; const hasSubmenu = item.submenu && item.submenu.length > 0; const isExpanded = expandedItems[currentPath]; return (
  • {hasSubmenu ? ( <> {item.label} ) : ( {item.label} )}
    {/* Submenu with accordion animation - supports nested submenus */} {hasSubmenu && ( )}
  • ); }; return ( <> {/* Mobile Menu Slide Panel */}
    logo
    {/* Overlay */}
    ); }; export default MobileMenu;