'use client'
import { useRouter } from 'next/navigation'
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '~/components/ui/dialog'
import ChatInterface from '~/app/chat/_components/ChatInterface'

type DBMessage = {
	id: string
	role: 'user' | 'assistant'
	content: string
}

interface ChatModalProps {
	sessionId?: string
	// initialMessages: DBMessage[]
}

export default function ChatModal({ sessionId }: ChatModalProps) {
	const router = useRouter()

	return (
		<Dialog modal={true} open onOpenChange={() => router.back()}>
			<DialogContent className="w-full max-w-full rounded-none sm:max-w-full h-[100svh] lg:max-w-3xl lg:rounded-xl lg:h-[80vh] flex flex-col p-0 gap-0">
				<DialogHeader className="p-4 border-b shrink-0">
					<DialogTitle>Talk To My AI-Assistant</DialogTitle>
				</DialogHeader>
				<div className="flex-1 overflow-hidden min-h-0">
					<ChatInterface sessionId={sessionId} />
				</div>
			</DialogContent>
		</Dialog>
	)
}
