Spaces:
Running
Running
import ChatInterface from '../../../components/ChatInterface'; | |
import { auth, sessionUser } from '@/auth'; | |
import { dbGetChat } from '@/lib/db/functions'; | |
import { redirect } from 'next/navigation'; | |
import { revalidatePath } from 'next/cache'; | |
import TopPrompt from '@/components/chat/TopPrompt'; | |
interface ChatServerProps { | |
chatId: string; | |
} | |
export default async function ChatServer({ chatId }: ChatServerProps) { | |
const chat = await dbGetChat(chatId); | |
const { id: userId } = await sessionUser(); | |
if (!chat) { | |
revalidatePath('/'); | |
redirect('/'); | |
} | |
return ( | |
<div className="w-[1600px] max-w-full mx-auto flex flex-col space-y-4 items-center"> | |
<TopPrompt chat={chat} userId={userId} /> | |
<ChatInterface chat={chat} userId={userId} /> | |
</div> | |
); | |
} | |