import { Chat } from '@/lib/types' import { type Session } from '@auth/nextjs/types' import { kv } from '@vercel/kv' import { Sidebar as SidebarIcon } from 'lucide-react' import { SidebarItem } from './sidebar-item' import { auth } from '@/auth' import { NextChat } from '@/components/icons' import { Button } from '@/components/ui/button' import { Sheet, SheetContent, SheetTrigger } from '@/components/ui/sheet' export interface SidebarProps {} export async function Sidebar({}: SidebarProps) { const session = await auth() return (
Chatbot
{/* @ts-ignore */}
) } async function SidebarList({ session }: { session?: Session }) { const results: Chat[] = await getChats(session?.user?.email ?? '') return results.map(c => ( )) } async function getChats(userId: string) { try { const pipeline = kv.pipeline() const chats: string[] = await kv.zrange(`user:chat:${userId}`, 0, -1) for (const chat of chats) { pipeline.hgetall(chat) } const results = await pipeline.exec() return results as Chat[] } catch (error) { return [] } }