import React, { useState } from 'react' import { MessageSquare, Book, Mic, Settings, LogOut, Database, ChevronRight, ChevronLeft, Menu, Globe, DownloadCloud, User } from 'lucide-react' import { Logo } from '../Logo' import { useLanguage } from '../../contexts/LanguageContext' import { UserInfoDisplay } from '../UserInfoDisplay' export type ViewType = 'chat' | 'knowledge' | 'notebooks' | 'settings' | string; export interface NavItem { id: ViewType; icon: React.ElementType; label: string; } interface SidebarRailProps { currentView: ViewType; onViewChange: (view: ViewType) => void; onLogout?: () => void; onOpenSettings?: () => void; currentUser?: any; navItems: NavItem[]; appMode?: 'workspace' | 'admin'; onSwitchMode?: () => void; } export const SidebarRail: React.FC = ({ currentView, onViewChange, onLogout, currentUser, navItems, appMode, onSwitchMode }) => { const [isExpanded, setIsExpanded] = useState(false) const { language, setLanguage, t } = useLanguage() const handleLanguageCycle = () => { const langs = ['zh', 'en', 'ja'] as const const currentIndex = langs.indexOf(language as any) const nextIndex = (currentIndex + 1) % langs.length setLanguage(langs[nextIndex]) } return (
{/* Header / Logo */}
{isExpanded && appMode && ( {appMode === 'admin' ? 'Admin' : 'Workspace'} )} {isExpanded && ( )}
{/* Current User Display - only when expanded */} {isExpanded && currentUser && (
)} {/* Navigation items */}
{navItems.map((item) => { // Determine active tab based on current route const isActive = currentView === item.id; return ( ) })}
{/* Footer / Settings / Toggle */}
{/* Toggle Button (When collapsed, show here to expand) */} {!isExpanded && ( )} {/* Settings Button */} {/* App Switcher for Admins */} {currentUser?.isAdmin && onSwitchMode && ( )} {/* Language Switcher */} {/* Logout Button */}
) }