import React from "react"; import { Link } from "react-router-dom"; import { IoIosArrowDown } from "react-icons/io"; import styles from './SidebarStyles/SidebarItem.module.css'; import SidebarSubmenu from "./SidebarSubmenu"; import { SidebarItemProps } from "./sidebarTypes"; const SidebarItem: React.FC = ({ item, isOpen, onToggle, isActive, isMinimized }) => { const Icon = item.icon as React.ComponentType>; const hasSubItems = item.submenu && item.submenu.length > 0; const isDisabled = item.moduleEnabled === false; const toggleSubmenu = (e: React.MouseEvent) => { if (isDisabled) { e.preventDefault(); return; } e.preventDefault(); e.stopPropagation(); onToggle(); }; const handleLinkClick = (e: React.MouseEvent) => { if (isDisabled) { e.preventDefault(); return; } // Allow normal navigation for the main link }; return (
  • {/* Icon - always visible */} {Icon && } {/* Text and arrow - hidden when minimized */} {!isMinimized && ( <> {item.name} {/* Arrow button separate from link */} {hasSubItems && ( )} )} {isMinimized && !isDisabled && ( )}
  • {hasSubItems && !isMinimized && !isDisabled && }
    ); }; export default SidebarItem;