### What problem does this PR solve? feat: Add RetrievalDocuments to SearchPage #2247 feat: Click on the link in the reference to display the pdf drawer #2247 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import MessageItem from '@/components/message-item';
|
||||
import DocumentPreviewer from '@/components/pdf-previewer';
|
||||
import { MessageType } from '@/constants/chat';
|
||||
import { Drawer, Flex, Spin } from 'antd';
|
||||
import { Flex, Spin } from 'antd';
|
||||
import {
|
||||
useClickDrawer,
|
||||
useCreateConversationBeforeUploadDocument,
|
||||
useGetFileIcon,
|
||||
useGetSendButtonDisabled,
|
||||
@@ -13,6 +11,8 @@ import {
|
||||
import { buildMessageItemReference } from '../utils';
|
||||
|
||||
import MessageInput from '@/components/message-input';
|
||||
import PdfDrawer from '@/components/pdf-drawer';
|
||||
import { useClickDrawer } from '@/components/pdf-drawer/hooks';
|
||||
import {
|
||||
useFetchNextConversation,
|
||||
useGetChatSearchParams,
|
||||
@@ -96,18 +96,12 @@ const ChatContainer = () => {
|
||||
}
|
||||
></MessageInput>
|
||||
</Flex>
|
||||
<Drawer
|
||||
title="Document Previewer"
|
||||
onClose={hideModal}
|
||||
open={visible}
|
||||
width={'50vw'}
|
||||
>
|
||||
<DocumentPreviewer
|
||||
documentId={documentId}
|
||||
chunk={selectedChunk}
|
||||
visible={visible}
|
||||
></DocumentPreviewer>
|
||||
</Drawer>
|
||||
<PdfDrawer
|
||||
visible={visible}
|
||||
hideModal={hideModal}
|
||||
documentId={documentId}
|
||||
chunk={selectedChunk}
|
||||
></PdfDrawer>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -23,7 +23,6 @@ import {
|
||||
useSendMessageWithSse,
|
||||
} from '@/hooks/logic-hooks';
|
||||
import { IConversation, IDialog, Message } from '@/interfaces/database/chat';
|
||||
import { IChunk } from '@/interfaces/database/knowledge';
|
||||
import { getFileExtension } from '@/utils';
|
||||
import { useMutationState } from '@tanstack/react-query';
|
||||
import { get } from 'lodash';
|
||||
@@ -545,30 +544,6 @@ export const useRenameConversation = () => {
|
||||
};
|
||||
};
|
||||
|
||||
export const useClickDrawer = () => {
|
||||
const { visible, showModal, hideModal } = useSetModalState();
|
||||
const [selectedChunk, setSelectedChunk] = useState<IChunk>({} as IChunk);
|
||||
const [documentId, setDocumentId] = useState<string>('');
|
||||
|
||||
const clickDocumentButton = useCallback(
|
||||
(documentId: string, chunk: IChunk) => {
|
||||
showModal();
|
||||
setSelectedChunk(chunk);
|
||||
setDocumentId(documentId);
|
||||
},
|
||||
[showModal],
|
||||
);
|
||||
|
||||
return {
|
||||
clickDocumentButton,
|
||||
visible,
|
||||
showModal,
|
||||
hideModal,
|
||||
selectedChunk,
|
||||
documentId,
|
||||
};
|
||||
};
|
||||
|
||||
export const useGetSendButtonDisabled = () => {
|
||||
const { dialogId, conversationId } = useGetChatSearchParams();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user