import React from 'react'; import { useNavigate, useLocation, Link } from 'react-router-dom'; import { Home, Library, Users, Disc, Radio, Settings, LogOut, ShoppingBag, GraduationCap, BarChart2, Shield, Box, MessageSquare, Cloud, Layers, Globe, Cpu, Heart, ListMusic, CreditCard, DollarSign, Terminal } from 'lucide-react'; import { NavItem } from '../../types'; import { useAuthStore } from '@/features/auth/store/authStore'; interface SidebarProps { currentView?: string; onNavigate?: (viewId: string) => void; onLogout?: () => void; } const navItems: { section: string; items: NavItem[] }[] = [ { section: 'My Studio', items: [ { id: 'dashboard', label: 'Command Center', icon: }, { id: 'studio', label: 'Cloud Files', icon: }, { id: 'tracks', label: 'Projects', icon: }, { id: 'gear', label: 'Gear Locker', icon: }, { id: 'analytics', label: 'Performance', icon: }, ] }, { section: 'Veza Network', items: [ { id: 'social', label: 'Community Feed', icon: }, { id: 'marketplace', label: 'Marketplace', icon: }, { id: 'live', label: 'Live Sessions', icon: , badge: 3 }, { id: 'chat', label: 'Channels', icon: , badge: 12 }, { id: 'education', label: 'Academy', icon: }, ] }, { section: 'Commerce', items: [ { id: 'sell', label: 'Seller Dashboard', icon: }, { id: 'wishlist', label: 'Wishlist', icon: }, { id: 'purchases', label: 'Purchases', icon: }, ] }, { section: 'Library', items: [ { id: 'playlists', label: 'Playlists', icon: }, { id: 'queue', label: 'Play Queue', icon: }, ] }, { section: 'System', items: [ { id: 'developer', label: 'Developer API', icon: }, { id: 'admin', label: 'Admin Panel', icon: }, ] } ]; // Mapping des IDs de navigation vers les routes React Router const routeMap: Record = { dashboard: '/dashboard', studio: '/dashboard', tracks: '/library', gear: '/dashboard', analytics: '/analytics', social: '/dashboard', marketplace: '/marketplace', live: '/dashboard', chat: '/chat', education: '/dashboard', sell: '/marketplace', wishlist: '/marketplace', purchases: '/marketplace', playlists: '/playlists', queue: '/dashboard', developer: '/dashboard', admin: '/admin', settings: '/settings', }; export const Sidebar: React.FC = ({ currentView, onNavigate, onLogout }) => { const navigate = useNavigate(); const location = useLocation(); const { logout } = useAuthStore(); // Déterminer la vue actuelle depuis l'URL const activeView = currentView || Object.keys(routeMap).find( key => routeMap[key] === location.pathname ) || 'dashboard'; const handleLogout = () => { logout(); navigate('/login'); // Appeler onLogout si fourni (pour compatibilité) if (onLogout) { onLogout(); } }; return ( ); };