import React from 'react'; import { Link } from 'react-router-dom'; import { cn } from '../../lib/utils'; import { FiChevronLeft } from 'react-icons/fi'; import { IconType } from 'react-icons'; interface NavSubItem { id: string; path: string; label: string; icon: IconType; description?: string; gradient?: string; } interface NavItemType { id: string; path: string; label: string; icon: IconType; description?: string; gradient?: string; iconBg?: string; subItems?: NavSubItem[]; } interface NavigationState { [key: string]: boolean; } interface NavItemProps { item: NavItemType; isActive: (path: string) => boolean; isCollapsed: boolean; expandedSections?: NavigationState; onToggleSection?: (sectionId: string) => void; } /** * Navigation item component for the sidebar */ const NavItem = React.memo( ({ item, isActive, isCollapsed, expandedSections = {}, onToggleSection }) => { const Icon = item.icon; const active = isActive(item.path); const hasSubItems = item.subItems && item.subItems.length > 0; const isExpanded = expandedSections[item.id]; if (item.id === 'help' || item.id === 'telegram') { const href = item.id === 'help' ? 'https://docs.hashgraphonline.com' : item.path; return (
{!isCollapsed && (
{item.label}
{item.description && (
{item.description}
)}
)}
); } if (hasSubItems) { const handleToggle = () => { onToggleSection?.(item.id); }; return (
{isExpanded && !isCollapsed && item.subItems && (
{item.subItems.map((subItem) => ( {isActive(subItem.path) && (
)}
{subItem.label}
{subItem.description && (
{subItem.description}
)}
))}
)}
); } return ( {active && (
)}
{!isCollapsed && (
{item.label}
{item.description && (
{item.description}
)}
)} ); } ); NavItem.displayName = 'NavItem'; export default NavItem;