diff --git a/frontend/src/app/update-batch/page.tsx b/frontend/src/app/update-batch/page.tsx index 35628c34..802d4fa6 100644 --- a/frontend/src/app/update-batch/page.tsx +++ b/frontend/src/app/update-batch/page.tsx @@ -24,6 +24,7 @@ const UpdateBatch: React.FC = () => { }); const [isUpdating, setIsUpdating] = useState(false); const [isRequestingIoT, setIsRequestingIoT] = useState(false); + const [transactionLocked, setTransactionLocked] = useState(false); const [transactionDetails, setTransactionDetails] = useState<{ hash: string; status: 'Confirmed' | 'Pending'; @@ -65,7 +66,10 @@ const UpdateBatch: React.FC = () => { const handleUpdate = async (e: React.FormEvent) => { e.preventDefault(); - if (!batch) return; + if (!batch) { + setTransactionLocked(false); + return; +} // RBAC Check: Verify user can update to this stage if (!canUpdateToStage(updateData.stage)) { @@ -111,6 +115,12 @@ const UpdateBatch: React.FC = () => { }; const handleRequestIoTVerification = async () => { + if (transactionLocked) { + toast.error("Transaction already in progress."); + return; +} + +setTransactionLocked(true); if (!batch || !batch.batchId) { toast.error('Please search for a batch first'); return; @@ -178,6 +188,7 @@ const UpdateBatch: React.FC = () => { toast.error('Failed to request IoT verification. Please try again.'); }finally { setIsRequestingIoT(false); + setTransactionLocked(false); } }; @@ -471,7 +482,7 @@ const handleCopyTransactionHash = async () => {