2023-06-15 12:52:46 +03:00
|
|
|
/* eslint-disable */
|
2023-06-11 00:59:16 +03:00
|
|
|
"use client";
|
|
|
|
import { UUID } from "crypto";
|
2023-06-11 15:34:36 +03:00
|
|
|
import { useEffect } from "react";
|
2023-06-15 12:52:46 +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 { 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(() => {
|
2023-06-15 12:52:46 +03:00
|
|
|
if (!chatId) {
|
|
|
|
resetChat();
|
|
|
|
}
|
2023-06-11 15:34:36 +03:00
|
|
|
fetchChat(chatId);
|
2023-06-20 10:54:23 +03:00
|
|
|
}, []);
|
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>
|
|
|
|
);
|
|
|
|
}
|