diff --git a/apps/visr/src/components/AbortButton.tsx b/apps/visr/src/components/AbortButton.tsx index bfa3fcb..648134b 100644 --- a/apps/visr/src/components/AbortButton.tsx +++ b/apps/visr/src/components/AbortButton.tsx @@ -1,12 +1,26 @@ import { Button } from "@mui/material"; +import { useEffect, useState } from "react"; import { setWorkerState, type WorkerRequest } from "../utils/api"; +import { useScanEvents } from "../hooks/scanEvents"; const AbortButton = () => { + const [disabled, setDisabled] = useState(true); + const scanEvent = useScanEvents(); + useEffect(() => { + if (!scanEvent) return; + if (scanEvent.status == "running") { + setDisabled(false); + } + if (scanEvent.status == "finished" || scanEvent.status == "failed") { + setDisabled(true); + } + }, [scanEvent]); return (