"use client"; import { ExternalLink, Folder, type LucideIcon, MoreHorizontal, Share, Trash2 } from "lucide-react"; import { useRouter } from "next/navigation"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { SidebarGroup, SidebarGroupLabel, SidebarMenu, SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, useSidebar, } from "@/components/ui/sidebar"; // Map of icon names to their components const actionIconMap: Record = { ExternalLink, Folder, Share, Trash2, MoreHorizontal, }; interface ChatAction { name: string; icon: string; onClick: () => void; } export function NavProjects({ chats, }: { chats: { name: string; url: string; icon: LucideIcon; id?: number; search_space_id?: number; actions?: ChatAction[]; }[]; }) { const { isMobile } = useSidebar(); const router = useRouter(); const searchSpaceId = chats[0]?.search_space_id || ""; return ( Recent Chats {chats.map((item, index) => ( {item.name} More {item.actions ? ( // Use the actions provided by the item item.actions.map((action, actionIndex) => { const ActionIcon = actionIconMap[action.icon] || Folder; return ( {action.name} ); }) ) : ( // Default actions if none provided <> View Chat Delete Chat )} ))} router.push(`/dashboard/${searchSpaceId}/chats`)}> View All Chats ); }