import React, { useState } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faBook, faPlus, faFileImport, faCompass, faExchangeAlt, faCalendar, faClockRotateLeft, faCog, faDesktop, faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons'; export function Sidebar({ isOpen, onClose, onAddMangaClick }) { const [expandedMenus, setExpandedMenus] = useState({ mangas: true, // Par défaut, le menu Mangas est ouvert settings: false, system: false }); const menuItems = [ { icon: faBook, text: 'Mangas', id: 'mangas', subItems: [ { icon: faPlus, text: 'Ajouter un nouveau', onClick: () => onAddMangaClick() }, { icon: faFileImport, text: 'Import bibliothèque', href: '#' }, { icon: faCompass, text: 'Découvrir', href: '#' }, ] }, { icon: faExchangeAlt, text: 'Convertir CBR en CBZ', href: '#' }, { icon: faCalendar, text: 'Calendrier', href: '#' }, { icon: faClockRotateLeft, text: 'Activité', href: '#', badge: '3' }, { icon: faCog, text: 'Paramètres', id: 'settings', subItems: [ { text: 'Général', href: '#' }, { text: 'Dossiers', href: '#' }, { text: 'Scrappers', href: '#' }, { text: 'UI', href: '#' } ] }, { icon: faDesktop, text: 'Système', id: 'system', subItems: [ { text: 'Status', href: '#' }, { text: 'Backup', href: '#' }, { text: 'Logs', href: '#' }, { text: 'Updates', href: '#' } ] }, ]; const toggleMenu = (menuId) => { setExpandedMenus(prev => ({ ...prev, [menuId]: !prev[menuId] })); }; const MenuItem = ({ item }) => { const hasSubItems = item.subItems && item.subItems.length > 0; const isExpanded = item.id && expandedMenus[item.id]; const isActive = false; // À implémenter avec un vrai système de routing return (
{hasSubItems && isExpanded && (
{item.subItems.map((subItem, index) => ( { e.preventDefault(); if (subItem.onClick) { subItem.onClick(); } else if (subItem.href !== '#') { window.location.href = subItem.href; } }} className="block py-2 text-gray-300 hover:text-green-600 transition-colors duration-150" > {subItem.icon && ( )} {subItem.text} ))}
)}
); }; return ( ); }