chatbot-template/components/sidebar-list.tsx
2023-06-16 20:39:18 +04:00

37 lines
1,008 B
TypeScript

import { getChats, removeChat, shareChat } from '@/app/actions'
import { SidebarActions } from '@/components/sidebar-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 =>
chat && (
<SidebarItem key={chat?.id} chat={chat}>
<SidebarActions
chat={chat}
removeChat={removeChat}
shareChat={shareChat}
/>
</SidebarItem>
)
)}
</div>
) : (
<div className="p-8 text-center">
<p className="text-sm text-muted-foreground">No chat history</p>
</div>
)}
</div>
)
}