"use client"; import { FolderOpen, PenSquare } from "lucide-react"; import { useTranslations } from "next-intl"; import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { cn } from "@/lib/utils"; import type { ChatItem, NavItem, PageUsage, SearchSpace, User } from "../../types/layout.types"; import { ChatListItem } from "./ChatListItem"; import { NavSection } from "./NavSection"; import { PageUsageDisplay } from "./PageUsageDisplay"; import { SidebarCollapseButton } from "./SidebarCollapseButton"; import { SidebarHeader } from "./SidebarHeader"; import { SidebarSection } from "./SidebarSection"; import { SidebarUserProfile } from "./SidebarUserProfile"; interface SidebarProps { searchSpace: SearchSpace | null; isCollapsed?: boolean; onToggleCollapse?: () => void; navItems: NavItem[]; onNavItemClick?: (item: NavItem) => void; chats: ChatItem[]; sharedChats?: ChatItem[]; activeChatId?: number | null; onNewChat: () => void; onChatSelect: (chat: ChatItem) => void; onChatDelete?: (chat: ChatItem) => void; onChatArchive?: (chat: ChatItem) => void; onViewAllSharedChats?: () => void; onViewAllPrivateChats?: () => void; user: User; onSettings?: () => void; onManageMembers?: () => void; onUserSettings?: () => void; onLogout?: () => void; pageUsage?: PageUsage; theme?: string; setTheme?: (theme: "light" | "dark" | "system") => void; className?: string; } export function Sidebar({ searchSpace, isCollapsed = false, onToggleCollapse, navItems, onNavItemClick, chats, sharedChats = [], activeChatId, onNewChat, onChatSelect, onChatDelete, onChatArchive, onViewAllSharedChats, onViewAllPrivateChats, user, onSettings, onManageMembers, onUserSettings, onLogout, pageUsage, theme, setTheme, className, }: SidebarProps) { const t = useTranslations("sidebar"); return (
{/* Header - search space name or collapse button when collapsed */} {isCollapsed ? (
{})} />
) : (
{})} />
)} {/* New chat button */}
{isCollapsed ? ( {t("new_chat")} ) : ( )}
{/* Chat sections - fills available space */} {isCollapsed ? (
) : (
{/* Shared Chats Section - takes only space needed, max 50% */} {t("view_all_shared_chats") || "View all shared chats"} ) : undefined } > {sharedChats.length > 0 ? (
4 ? "pb-8" : ""}`} > {sharedChats.slice(0, 20).map((chat) => ( onChatSelect(chat)} onArchive={() => onChatArchive?.(chat)} onDelete={() => onChatDelete?.(chat)} /> ))}
{/* Gradient fade indicator when more than 4 items */} {sharedChats.length > 4 && (
)}
) : (

{t("no_shared_chats")}

)} {/* Private Chats Section - fills remaining space */} {t("view_all_private_chats") || "View all private chats"} ) : undefined } > {chats.length > 0 ? (
4 ? "pb-8" : ""}`} > {chats.slice(0, 20).map((chat) => ( onChatSelect(chat)} onArchive={() => onChatArchive?.(chat)} onDelete={() => onChatDelete?.(chat)} /> ))}
{/* Gradient fade indicator when more than 4 items */} {chats.length > 4 && (
)}
) : (

{t("no_chats")}

)}
)} {/* Footer */}
{/* Platform navigation */} {navItems.length > 0 && ( )} {pageUsage && !isCollapsed && ( )}
); }