import React, { useState } from 'react'; import { Link, useLocation, useNavigate } from 'react-router-dom'; import { useAppSelector, useAppDispatch } from '../../store/hooks'; import { Home, Users, Briefcase, FileText, Headphones, BarChart3, Settings, Wallet, BookOpen, ShoppingBag, Award, HelpCircle, Menu, X, Sun, Moon, LogOut, Building, Handshake, Target, TrendingUp, Package, User } from 'lucide-react'; import { RootState } from '../../store'; import { toggleTheme } from '../../store/slices/themeSlice'; import { logout } from '../../store/slices/authSlice'; import { cn } from '../../utils/cn'; import toast from 'react-hot-toast'; const navigation = [ { name: 'Dashboard', href: '/dashboard', icon: Home }, { name: 'Product Management', href: '/product-management', icon: Package }, { name: 'Sales Management', href: '/sales-management', icon: ShoppingBag }, { name: 'Reseller Requests', href: '/resellers', icon: Users }, { name: 'Approved Resellers', href: '/approved-resellers', icon: Handshake }, // { name: 'Deals', href: '/deals', icon: Briefcase }, { name: 'Commissions', href: '/commissions', icon: Wallet }, { name: 'Training', href: '/training', icon: BookOpen }, { name: 'Support', href: '/support', icon: Headphones }, { name: 'Analytics', href: '/analytics', icon: BarChart3 }, { name: 'Reports', href: '/reports', icon: FileText }, { name: 'Performance', href: '/performance', icon: TrendingUp }, { name: 'Marketplace', href: '/marketplace', icon: ShoppingBag }, { name: 'Certifications', href: '/certifications', icon: Award }, { name: 'Knowledge Base', href: '/knowledge-base', icon: HelpCircle }, { name: 'Settings', href: '/settings', icon: Settings }, ]; const Sidebar: React.FC = () => { const [isCollapsed, setIsCollapsed] = useState(false); const location = useLocation(); const navigate = useNavigate(); const dispatch = useAppDispatch(); const { theme } = useAppSelector((state: RootState) => state.theme); const { user } = useAppSelector((state: RootState) => state.auth); const handleLogout = () => { dispatch(logout()); toast.success('Logged out successfully'); // Wait a bit for Redux state to update, then navigate setTimeout(() => { navigate('/login'); }, 100); }; return (
{/* Header */}
{!isCollapsed && (
Cloudtopiaa
)}
{/* Navigation */} {/* User Profile & Actions */}
{/* Theme Toggle */}
{!isCollapsed && ( Theme )}
{/* User Profile */} {user && (
{`${user.firstName[0]}${user.lastName[0]}`}
{!isCollapsed && (

{`${user.firstName} ${user.lastName}`}

{user.email}

)}
)}
); }; export default Sidebar;