diff --git a/frontend/src/components/SourceDropdown.tsx b/frontend/src/components/SourceDropdown.tsx index a3f1b38d..e274c8f4 100644 --- a/frontend/src/components/SourceDropdown.tsx +++ b/frontend/src/components/SourceDropdown.tsx @@ -1,9 +1,11 @@ -import React from 'react'; +import React, { useState } from 'react'; import Trash from '../assets/trash.svg'; import Arrow2 from '../assets/dropdown-arrow.svg'; -import { Doc } from '../models/misc'; +import { Doc, ActiveState } from '../models/misc'; import { useDispatch } from 'react-redux'; import { useTranslation } from 'react-i18next'; +import ConfirmationModal from '../modals/ConfirmationModal'; + type Props = { options: Doc[] | null; selectedDocs: Doc | null; @@ -30,6 +32,10 @@ function SourceDropdown({ import.meta.env.VITE_EMBEDDINGS_NAME || 'huggingface_sentence-transformers/all-mpnet-base-v2'; + const [deleteModalState, setDeleteModalState] = + useState('INACTIVE'); + const [documentToDelete, setDocumentToDelete] = useState(null); + const handleEmptyDocumentSelect = () => { dispatch(setSelectedDocs(null)); setIsDocsListOpen(false); @@ -50,6 +56,25 @@ function SourceDropdown({ document.removeEventListener('mousedown', handleClickOutside); }; }, []); + + const confirmDelete = (option: Doc) => { + setDocumentToDelete(option); + setDeleteModalState('ACTIVE'); + }; + + const handleConfirmedDelete = () => { + if (documentToDelete) { + handleDeleteClick(documentToDelete); + setDeleteModalState('INACTIVE'); + setDocumentToDelete(null); + } + }; + + const handleCancelDelete = () => { + setDeleteModalState('INACTIVE'); + setDocumentToDelete(null); + }; + return (
)} + ); }