This commit is contained in:
2026-03-10 20:43:02 +01:00
parent 10b3f989c8
commit 34dc53a8e9
11 changed files with 564 additions and 0 deletions

50
src/app/chat/page.tsx Normal file
View File

@@ -0,0 +1,50 @@
import { auth } from '@clerk/nextjs/server'
import { redirect } from 'next/navigation'
import { asc, desc, eq } from 'drizzle-orm'
import { db } from '~/server/db'
import { chatMessage, chatSession } from '~/server/dbschema/schema'
import ChatInterface from './_components/ChatInterface'
export default async function ChatPage() {
const { userId } = await auth()
if (!userId) redirect('/')
let session = await db
.select()
.from(chatSession)
.where(eq(chatSession.userId, userId))
.orderBy(desc(chatSession.createdAt))
.limit(1)
.then((r) => r[0])
if (!session) {
const [created] = await db.insert(chatSession).values({ userId }).returning()
session = created
}
if (!session) redirect('/')
const messages = await db
.select()
.from(chatMessage)
.where(eq(chatMessage.sessionId, session.id))
.orderBy(asc(chatMessage.createdAt))
return (
<div className="container max-w-2xl mx-auto h-screen pt-10 pb-4 flex flex-col">
<div className="flex flex-col flex-1 bg-background border rounded-lg overflow-hidden">
<div className="p-4 border-b flex items-center justify-between">
<div>
<h1 className="text-lg font-semibold">AI Recruiter</h1>
<p className="text-xs text-muted-foreground">
Chat with Gregor's AI assistant
</p>
</div>
</div>
<div className="flex-1 overflow-hidden">
<ChatInterface sessionId={session.id} initialMessages={messages} />
</div>
</div>
</div>
)
}