2023-06-11 00:59:16 +03:00
|
|
|
"use client";
|
2023-06-13 17:33:41 +03:00
|
|
|
import PageHeading from "@/lib/components/ui/PageHeading";
|
|
|
|
import useChatsContext from "@/lib/context/ChatsProvider/hooks/useChatsContext";
|
2023-06-11 00:59:16 +03:00
|
|
|
import { UUID } from "crypto";
|
2023-06-11 15:34:36 +03:00
|
|
|
import { useEffect } from "react";
|
2023-06-11 00:59:16 +03:00
|
|
|
import { ChatInput, ChatMessages } from "../components";
|
|
|
|
|
|
|
|
interface ChatPageProps {
|
2023-06-11 15:34:36 +03:00
|
|
|
params: {
|
|
|
|
chatId: UUID;
|
2023-06-11 00:59:16 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function ChatPage({ params }: ChatPageProps) {
|
2023-06-11 15:34:36 +03:00
|
|
|
const chatId: UUID | undefined = params.chatId;
|
2023-06-11 00:59:16 +03:00
|
|
|
|
2023-06-11 15:34:36 +03:00
|
|
|
const { fetchChat, resetChat } = useChatsContext();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
// if (chatId)
|
|
|
|
if (!chatId) resetChat();
|
|
|
|
fetchChat(chatId);
|
|
|
|
}, [fetchChat, chatId]);
|
2023-06-11 00:59:16 +03:00
|
|
|
|
|
|
|
return (
|
2023-06-11 11:44:23 +03:00
|
|
|
<main className="flex flex-col w-full pt-10">
|
|
|
|
<section className="flex flex-col flex-1 items-center w-full h-full min-h-screen">
|
2023-06-11 00:59:16 +03:00
|
|
|
<PageHeading
|
|
|
|
title="Chat with your brain"
|
|
|
|
subtitle="Talk to a language model about your uploaded data"
|
|
|
|
/>
|
2023-06-11 11:44:23 +03:00
|
|
|
<div className="relative h-full w-full flex flex-col flex-1 items-center">
|
|
|
|
<div className="h-full flex-1 w-full flex flex-col items-center">
|
2023-06-11 15:34:36 +03:00
|
|
|
<ChatMessages />
|
2023-06-11 11:44:23 +03:00
|
|
|
</div>
|
2023-06-11 15:34:36 +03:00
|
|
|
<ChatInput />
|
2023-06-11 11:44:23 +03:00
|
|
|
</div>
|
2023-06-11 00:59:16 +03:00
|
|
|
</section>
|
|
|
|
</main>
|
|
|
|
);
|
|
|
|
}
|