import React, { useState } from 'react'; import { LayoutDashboard, MessageSquare, Users, TrendingUp, Target, Zap, CheckSquare, BarChart2, ShoppingBag, Wrench, Award, ClipboardCheck, Shield, Menu, X, ChevronRight, User, Sparkles, } from 'lucide-react'; import { ViewState } from '../types'; interface SidebarProps { currentView: ViewState; onNavigate: (view: ViewState) => void; isAdmin: boolean; userName?: string; userEmail?: string; } interface NavItem { id: ViewState; label: string; icon: React.ReactNode; disabled?: boolean; comingSoon?: boolean; adminOnly?: boolean; } const navItems: NavItem[] = [ { id: ViewState.DASHBOARD, label: 'Dashboard', icon: }, { id: ViewState.CONTROL_CENTER, label: 'Control Center', icon: }, { id: ViewState.CONVERSATIONS, label: 'Conversations', icon: }, { id: ViewState.CONTACTS, label: 'Contacts', icon: }, { id: ViewState.OPPORTUNITIES, label: 'Opportunities', icon: }, { id: ViewState.GET_LEADS, label: 'Get Leads', icon: }, { id: ViewState.AUTOMATIONS, label: 'Automations', icon: }, { id: ViewState.TODO_LIST, label: 'To-Do List', icon: }, { id: ViewState.REPORTING, label: 'Reporting', icon: }, { id: ViewState.MARKETPLACE, label: 'Town Hall', icon: }, { id: ViewState.EXTERNAL_TOOLS, label: 'External Tools', icon: }, { id: ViewState.LEADERBOARD, label: 'Leaderboard', icon: , disabled: true, comingSoon: true }, { id: ViewState.QUIZ, label: 'Performance Quiz', icon: }, { id: ViewState.ADMIN, label: 'Admin', icon: , adminOnly: true }, ]; export const Sidebar: React.FC = ({ currentView, onNavigate, isAdmin, userName, userEmail, }) => { const [isMobileOpen, setIsMobileOpen] = useState(false); const toggleMobile = () => setIsMobileOpen(!isMobileOpen); const handleNavClick = (itemId: ViewState, disabled?: boolean) => { if (disabled) return; onNavigate(itemId); setIsMobileOpen(false); }; // Filter out admin-only items for non-admin users const visibleNavItems = navItems.filter(item => !item.adminOnly || isAdmin); const renderNavItem = (item: NavItem) => { const isActive = currentView === item.id; const isDisabled = item.disabled; return ( handleNavClick(item.id, item.disabled)} disabled={isDisabled} className={` w-full flex items-center gap-3 px-4 py-3 rounded-xl text-left transition-all duration-200 group relative ${isActive ? 'bg-indigo-600 text-white shadow-lg shadow-indigo-600/30' : isDisabled ? 'text-slate-500 cursor-not-allowed' : 'text-slate-300 hover:bg-slate-800 hover:text-white' } `} > {item.icon} {item.label} {item.comingSoon && ( Soon )} {isActive && ( )} ); }; const sidebarContent = ( <> {/* Logo */} C CRESync {/* Navigation */} {visibleNavItems.map(renderNavItem)} {/* User Profile Section */} {userName ? ( <> {userName} {userEmail && ( {userEmail} )} > ) : ( Not signed in )} > ); return ( <> {/* Mobile Hamburger Button */} {isMobileOpen ? : } {/* Mobile Overlay */} {isMobileOpen && ( setIsMobileOpen(false)} /> )} {/* Sidebar - Desktop */} {/* Sidebar - Mobile */} > ); };
{userName}
{userEmail}
Not signed in