diff --git a/client-app/src/components/OrcaDashboardComponent.js b/client-app/src/components/OrcaDashboardComponent.js index e9db5e8e..3d077336 100644 --- a/client-app/src/components/OrcaDashboardComponent.js +++ b/client-app/src/components/OrcaDashboardComponent.js @@ -18,7 +18,7 @@ const OrcaDashboardComponent = () => { const isSectionsEmpty = sections.length === 0; const [sameCriteria, setSameCriteria] = useState(false); const [previewContent, setPreviewContent] = useState(""); - const [showPreviewModal, setShowPreviewModal] = useState(false); + const [showPreviewModal, setShowPreviewModal] = useState(false); const onFileSelected = (event) => { const selectedFile = event.target.files[0]; @@ -26,6 +26,11 @@ const OrcaDashboardComponent = () => { alert("Invalid file type. Please upload a .txt file."); return; } + + if (uploadedFiles.includes(selectedFile.name)) { + alert(`The file "${selectedFile.name}" has already been uploaded.`); + return; + } setSelectedFile(selectedFile); }; @@ -69,10 +74,10 @@ const OrcaDashboardComponent = () => { const formatSpecifyLines = () => { const line = specifyLines[0]; - return line.value === "WHOLE" || line.value === "SELECT" - ? line.value + return line.value === "WHOLE" || line.value === "SELECT" + ? line.value : `${line.value} ${line.lineNumber}`; - }; + }; const onUpload = () => { if (!selectedFile) { @@ -80,6 +85,11 @@ const OrcaDashboardComponent = () => { return; } + if (uploadedFiles.includes(selectedFile.name)) { + alert(`The file "${selectedFile.name}" has already been uploaded.`); + return; + } + const formData = new FormData(); formData.append("file", selectedFile); @@ -109,7 +119,7 @@ const OrcaDashboardComponent = () => { file_path: filePath.toString(), search_terms: searchTerms, sections: sections, - specify_lines: formatSpecifyLines() + specify_lines: formatSpecifyLines(), }; axios @@ -203,14 +213,14 @@ const OrcaDashboardComponent = () => { file_path: filePath.toString(), search_terms: searchTerms, sections: sections, - specify_lines: formatSpecifyLines() + specify_lines: formatSpecifyLines(), }; axios .post(`${config.apiBaseUrl}/preview`, data) .then((response) => { - setPreviewContent(response.data.document_content); - setShowPreviewModal(true); + setPreviewContent(response.data.document_content); + setShowPreviewModal(true); }) .catch((error) => { if (error.response && error.response.status === 404) { @@ -354,28 +364,32 @@ const OrcaDashboardComponent = () => { - + {showPreviewModal && ( -
- {previewContent} -+
{previewContent}