mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-17 11:21:35 +03:00
d2cab9332f
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate): --------- Co-authored-by: Stan Girard <girard.stanislas@gmail.com>
100 lines
3.1 KiB
TypeScript
100 lines
3.1 KiB
TypeScript
"use client";
|
|
|
|
import { UUID } from "crypto";
|
|
import { useEffect } from "react";
|
|
|
|
import { AddBrainModal } from "@/lib/components/AddBrainModal";
|
|
import { useBrainCreationContext } from "@/lib/components/AddBrainModal/brainCreation-provider";
|
|
import PageHeader from "@/lib/components/PageHeader/PageHeader";
|
|
import { UploadDocumentModal } from "@/lib/components/UploadDocumentModal/UploadDocumentModal";
|
|
import { useChatContext } from "@/lib/context";
|
|
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
|
|
import { useKnowledgeToFeedContext } from "@/lib/context/KnowledgeToFeedProvider/hooks/useKnowledgeToFeedContext";
|
|
import { useCustomDropzone } from "@/lib/hooks/useDropzone";
|
|
import { ButtonType } from "@/lib/types/QuivrButton";
|
|
import { cn } from "@/lib/utils";
|
|
|
|
import { ActionsBar } from "./components/ActionsBar";
|
|
import { ChatDialogueArea } from "./components/ChatDialogueArea/ChatDialogue";
|
|
import { useChatNotificationsSync } from "./hooks/useChatNotificationsSync";
|
|
import styles from "./page.module.scss";
|
|
|
|
const SelectedChatPage = (): JSX.Element => {
|
|
const { getRootProps } = useCustomDropzone();
|
|
|
|
const { setShouldDisplayFeedCard, shouldDisplayFeedCard } =
|
|
useKnowledgeToFeedContext();
|
|
const { setIsBrainCreationModalOpened } = useBrainCreationContext();
|
|
|
|
const { currentBrain, setCurrentBrainId } = useBrainContext();
|
|
const { messages } = useChatContext();
|
|
|
|
useChatNotificationsSync();
|
|
|
|
const buttons: ButtonType[] = [
|
|
{
|
|
label: "Create brain",
|
|
color: "primary",
|
|
onClick: () => {
|
|
setIsBrainCreationModalOpened(true);
|
|
},
|
|
iconName: "brain",
|
|
},
|
|
{
|
|
label: "Add knowledge",
|
|
color: "primary",
|
|
onClick: () => {
|
|
setShouldDisplayFeedCard(true);
|
|
},
|
|
iconName: "uploadFile",
|
|
hidden: !currentBrain?.max_files,
|
|
},
|
|
{
|
|
label: "Manage current brain",
|
|
color: "primary",
|
|
onClick: () => {
|
|
window.location.href = `/studio/${currentBrain?.id}`;
|
|
},
|
|
iconName: "edit",
|
|
},
|
|
];
|
|
|
|
useEffect(() => {
|
|
if (!currentBrain && messages.length > 0) {
|
|
setCurrentBrainId(messages[messages.length - 1].brain_id as UUID);
|
|
}
|
|
}, [messages]);
|
|
|
|
return (
|
|
<div className={styles.main_container}>
|
|
<div className={styles.page_header}>
|
|
<PageHeader iconName="chat" label="Thread" buttons={buttons} />
|
|
</div>
|
|
<div
|
|
className={styles.chat_page_container}
|
|
{...(shouldDisplayFeedCard ? {} : getRootProps())}
|
|
>
|
|
<div
|
|
className={cn(
|
|
"flex flex-col flex-1 items-center justify-stretch w-full h-full overflow-hidden",
|
|
"dark:bg-black transition-colors ease-out duration-500"
|
|
)}
|
|
>
|
|
<div
|
|
className={`flex flex-col flex-1 w-full max-w-4xl h-full dark:shadow-primary/25 overflow-hidden`}
|
|
>
|
|
<div className="flex flex-1 flex-col overflow-y-auto">
|
|
<ChatDialogueArea />
|
|
</div>
|
|
<ActionsBar />
|
|
</div>
|
|
</div>
|
|
<UploadDocumentModal />
|
|
<AddBrainModal />
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default SelectedChatPage;
|