"use client" import * as React from "react" import { BookOpen, Cable, FileStack, Undo2, MessageCircleMore, Settings2, SquareLibrary, SquareTerminal, AlertCircle, Info, ExternalLink, Trash2, Podcast, type LucideIcon, } from "lucide-react" import { Logo } from "@/components/Logo"; import { NavMain } from "@/components/sidebar/nav-main" import { NavProjects } from "@/components/sidebar/nav-projects" import { NavSecondary } from "@/components/sidebar/nav-secondary" import { NavUser } from "@/components/sidebar/nav-user" import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, } from "@/components/ui/sidebar" // Map of icon names to their components export const iconMap: Record = { BookOpen, Cable, FileStack, Undo2, MessageCircleMore, Settings2, SquareLibrary, SquareTerminal, AlertCircle, Info, ExternalLink, Trash2, Podcast } const defaultData = { user: { name: "Surf", email: "m@example.com", avatar: "/icon-128.png", }, navMain: [ { title: "Researcher", url: "#", icon: "SquareTerminal", isActive: true, items: [], }, { title: "Documents", url: "#", icon: "FileStack", items: [ { title: "Upload Documents", url: "#", }, { title: "Manage Documents", url: "#", }, ], }, { title: "Connectors", url: "#", icon: "Cable", items: [ { title: "Add Connector", url: "#", }, { title: "Manage Connectors", url: "#", }, ], }, { title: "Research Synthesizer's", url: "#", icon: "SquareLibrary", items: [ { title: "Podcast Creator", url: "#", }, { title: "Presentation Creator", url: "#", }, ], }, ], navSecondary: [ { title: "SEARCH SPACE", url: "#", icon: "LifeBuoy", }, ], RecentChats: [ { name: "Design Engineering", url: "#", icon: "MessageCircleMore", id: 1001, }, { name: "Sales & Marketing", url: "#", icon: "MessageCircleMore", id: 1002, }, { name: "Travel", url: "#", icon: "MessageCircleMore", id: 1003, }, ], } interface AppSidebarProps extends React.ComponentProps { user?: { name: string email: string avatar: string } navMain?: { title: string url: string icon: string isActive?: boolean items?: { title: string url: string }[] }[] navSecondary?: { title: string url: string icon: string // Changed to string (icon name) }[] RecentChats?: { name: string url: string icon: string // Changed to string (icon name) id?: number search_space_id?: number actions?: { name: string icon: string onClick: () => void }[] }[] } export function AppSidebar({ user = defaultData.user, navMain = defaultData.navMain, navSecondary = defaultData.navSecondary, RecentChats = defaultData.RecentChats, ...props }: AppSidebarProps) { // Process navMain to resolve icon names to components const processedNavMain = React.useMemo(() => { return navMain.map(item => ({ ...item, icon: iconMap[item.icon] || SquareTerminal // Fallback to SquareTerminal if icon not found })) }, [navMain]) // Process navSecondary to resolve icon names to components const processedNavSecondary = React.useMemo(() => { return navSecondary.map(item => ({ ...item, icon: iconMap[item.icon] || Undo2 // Fallback to Undo2 if icon not found })) }, [navSecondary]) // Process RecentChats to resolve icon names to components const processedRecentChats = React.useMemo(() => { return RecentChats?.map(item => ({ ...item, icon: iconMap[item.icon] || MessageCircleMore // Fallback to MessageCircleMore if icon not found })) || []; }, [RecentChats]) return (
SurfSense beta v0.0.7
{processedRecentChats.length > 0 && }
) }