()
| 37 | console.log("currentJobId", currentJobId); |
| 38 | |
| 39 | const fetchJobStatus = async () => { |
| 40 | try { |
| 41 | console.log("calling fetchJobStatus"); |
| 42 | const response = await axios.get<{ |
| 43 | status: string; |
| 44 | result: { positions: PositionInfo[] }; |
| 45 | events: EventType[]; |
| 46 | }>(`http://localhost:3001/api/crew/${currentJobId}`); |
| 47 | const { status, events: fetchedEvents, result } = response.data; |
| 48 | |
| 49 | console.log("status update", response.data); |
| 50 | |
| 51 | setEvents(fetchedEvents); |
| 52 | if (result) { |
| 53 | console.log("setting job result", result); |
| 54 | console.log("setting job positions", result.positions); |
| 55 | setPositionInfoList(result.positions || []); |
| 56 | } |
| 57 | |
| 58 | if (status === "COMPLETE" || status === "ERROR") { |
| 59 | if (intervalId) { |
| 60 | clearInterval(intervalId); |
| 61 | } |
| 62 | setRunning(false); |
| 63 | toast.success(`Job ${status.toLowerCase()}.`); |
| 64 | } |
| 65 | } catch (error) { |
| 66 | if (intervalId) { |
| 67 | clearInterval(intervalId); |
| 68 | } |
| 69 | setRunning(false); |
| 70 | toast.error("Failed to get job status."); |
| 71 | console.error(error); |
| 72 | } |
| 73 | }; |
| 74 | |
| 75 | if (currentJobId !== "") { |
| 76 | intervalId = setInterval(fetchJobStatus, 1000) as unknown as number; |
nothing calls this directly
no outgoing calls
no test coverage detected