diff --git a/src/components/DataImport/ArtefactUploadView.jsx b/src/components/DataImport/ArtefactUploadView.jsx index e41d223..5a06d0c 100644 --- a/src/components/DataImport/ArtefactUploadView.jsx +++ b/src/components/DataImport/ArtefactUploadView.jsx @@ -1,4 +1,4 @@ -import { Button, Flex, Box, Text } from "@chakra-ui/react"; +import { Button, Flex, Box, Text, Field, Input } from "@chakra-ui/react"; import { useEffect, useRef, useState } from "react"; import { HiUpload } from "react-icons/hi"; import server from "../../networking"; @@ -8,12 +8,13 @@ import { IoArrowBackCircleSharp } from "react-icons/io5"; import PendingBatchCard from "./PendingBatchCard"; import hp1 from "../../assets/hp1.png"; -function ArtefactUploadView({ batch, setBatchID, onClose, fetchBatches, onBackToPending }) { +function ArtefactUploadView({ batch, setBatchID, fetchBatches, onBackToPending }) { const batchID = batch?.id; const fileInputRef = useRef(null); const [isSubmitting, setIsSubmitting] = useState(false); const [selectedFiles, setSelectedFiles] = useState([]); const [fileStatuses, setFileStatuses] = useState({}); + const [name, setName] = useState(batch?.name || ""); const handleButtonClick = () => { fileInputRef.current?.click(); @@ -58,6 +59,10 @@ function ArtefactUploadView({ batch, setBatchID, onClose, fetchBatches, onBackTo ToastWizard.standard("warning", "No Files Selected", "Please choose at least one file before uploading."); return; } + if (!batchID && !name.trim()) { + ToastWizard.standard("error", "Batch Name Required", "Please provide a name for the new batch."); + return; + } const formData = new FormData(); selectedFiles.forEach((file) => { @@ -67,6 +72,9 @@ function ArtefactUploadView({ batch, setBatchID, onClose, fetchBatches, onBackTo if (batchID) { formData.append("batchID", batchID); } + if (name) { + formData.append("name", name); + } setIsSubmitting(true); @@ -204,6 +212,11 @@ function ArtefactUploadView({ batch, setBatchID, onClose, fetchBatches, onBackTo ) } + + Batch Name + setName(e.target.value)} /> + + + {content.buttonText && + + } ) : ( {/* 1. Thumbnail */} - {batchName} + {content.name} - {displayMessage} | {timestamp} + {content.displayMessage || "No message"} | {content.timestamp || "Unknown Timestamp"} {/* 3. Progress */} - - + + - {progress}% + {content.progress}% @@ -118,23 +279,28 @@ function BatchCard({ batchName, displayMessage, timestamp, progress, isProcessin {/* 4. Status */} - {status.label} + {content.statusText || "Unknown"} {/* 5. Button */} - + {content.buttonText && + + } )} diff --git a/src/components/DataImport/ImportMenuDialog.jsx b/src/components/DataImport/ImportMenuDialog.jsx index 65be9a4..7419018 100644 --- a/src/components/DataImport/ImportMenuDialog.jsx +++ b/src/components/DataImport/ImportMenuDialog.jsx @@ -28,8 +28,7 @@ function ImportMenuDialog({ pendingBatches, fetchBatches }) { unmountOnExit > - + @@ -43,7 +42,6 @@ function ImportMenuDialog({ pendingBatches, fetchBatches }) { b.id === targetBatchID) || null} setBatchID={(id) => setTargetBatchID(id)} - onClose={handleClose} fetchBatches={fetchBatches} onBackToPending={() => setView("pendingList")} />} @@ -57,18 +55,14 @@ function ImportMenuDialog({ pendingBatches, fetchBatches }) { - Pending Batches + {pendingBatches.length === 0 ? "No pending batches": "Pending Batches"} - {pendingBatches.length === 0 ? ( - - No pending batches. - - ) : ( + {pendingBatches.length > 0 && ( {pendingBatches.map((batch) => ( nav('/figures')} fontSize={'md'}> Key Figures - } - {username && ( + + - )} + } {superuser === true && (