chatbot-template/components/sidebar-list.tsx

33 lines
830 B
TypeScript

import { getChats, removeChat } from '@/app/actions'
import { SidebarItem } from '@/components/sidebar-item'
export interface SidebarListProps {
userId?: string
}
export async function SidebarList({ userId }: SidebarListProps) {
const chats = await getChats(userId)
return (
<div className="flex-1 overflow-auto">
{chats?.length ? (
<div className="space-y-2 px-2">
{chats.map(chat => (
<SidebarItem
key={chat.id}
title={chat.title}
href={`/chat/${chat.id}`}
id={chat.id}
removeChat={removeChat}
/>
))}
</div>
) : (
<div className="p-8 text-center">
<p className="text-sm text-muted-foreground">No chat history</p>
</div>
)}
</div>
)
}