diff --git a/frontend/src/Navigation.tsx b/frontend/src/Navigation.tsx index f6d656751..c29aaf20d 100644 --- a/frontend/src/Navigation.tsx +++ b/frontend/src/Navigation.tsx @@ -476,8 +476,10 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) { /> {uploadModalState === 'ACTIVE' && ( setUploadModalState('INACTIVE')} > )} diff --git a/frontend/src/api/endpoints.ts b/frontend/src/api/endpoints.ts index 05c8f786f..4e7112d04 100644 --- a/frontend/src/api/endpoints.ts +++ b/frontend/src/api/endpoints.ts @@ -17,7 +17,7 @@ const endpoints = { TOKEN_ANALYTICS: '/api/get_token_analytics', FEEDBACK_ANALYTICS: '/api/get_feedback_analytics', LOGS: `/api/get_user_logs`, - MANAGE_SYNC: '/api/manage_sync' + MANAGE_SYNC: '/api/manage_sync', }, CONVERSATION: { ANSWER: '/api/answer', diff --git a/frontend/src/assets/DragFileUpload.svg b/frontend/src/assets/DragFileUpload.svg new file mode 100644 index 000000000..1b41d1930 --- /dev/null +++ b/frontend/src/assets/DragFileUpload.svg @@ -0,0 +1,4 @@ + + + + diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx index 7f06d6b1c..2614104e0 100644 --- a/frontend/src/conversation/Conversation.tsx +++ b/frontend/src/conversation/Conversation.tsx @@ -1,8 +1,10 @@ -import { Fragment, useEffect, useRef, useState } from 'react'; +import { Fragment, useCallback, useEffect, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useDispatch, useSelector } from 'react-redux'; import { useNavigate } from 'react-router-dom'; import Hero from '../Hero'; +import { useDropzone } from 'react-dropzone'; +import DragFileUpload from '../assets/DragFileUpload.svg'; import ArrowDown from '../assets/arrow-down.svg'; import newChatIcon from '../assets/openNewChat.svg'; import Send from '../assets/send.svg'; @@ -28,6 +30,8 @@ import { updateConversationId, updateQuery, } from './conversationSlice'; +import Upload from '../upload/Upload'; +import { ActiveState } from '../models/misc'; export default function Conversation() { const queries = useSelector(selectQueries); @@ -45,6 +49,47 @@ export default function Conversation() { const [isShareModalOpen, setShareModalState] = useState(false); const { t } = useTranslation(); const { isMobile } = useMediaQuery(); + const [uploadModalState, setUploadModalState] = + useState('INACTIVE'); + const [files, setFiles] = useState([]); + const [handleDragActive, setHandleDragActive] = useState(false); + + const onDrop = useCallback((acceptedFiles: File[]) => { + setUploadModalState('ACTIVE'); + setFiles(acceptedFiles); + setHandleDragActive(false); + }, []); + + const { getRootProps, getInputProps } = useDropzone({ + onDrop, + noClick: true, + multiple: true, + onDragEnter: () => { + setHandleDragActive(true); + }, + onDragLeave: () => { + setHandleDragActive(false); + }, + maxSize: 25000000, + accept: { + 'application/pdf': ['.pdf'], + 'text/plain': ['.txt'], + 'text/x-rst': ['.rst'], + 'text/x-markdown': ['.md'], + 'application/zip': ['.zip'], + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': + ['.docx'], + 'application/json': ['.json'], + 'text/csv': ['.csv'], + 'text/html': ['.html'], + 'application/epub+zip': ['.epub'], + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': [ + '.xlsx', + ], + 'application/vnd.openxmlformats-officedocument.presentationml.presentation': + ['.pptx'], + }, + }); const handleUserInterruption = () => { if (!eventInterrupt && status === 'loading') setEventInterrupt(true); @@ -323,7 +368,11 @@ export default function Conversation() {
-
+
+