Updated loading states and error states accross app

This commit is contained in:
2025-10-06 14:21:56 +01:00
parent ad0ffa6df6
commit f275f50383
25 changed files with 377 additions and 101 deletions

View File

@@ -3,9 +3,11 @@ import { useQuery } from "@tanstack/react-query";
import { CAM_BASE } from "../utils/config";
const apiUrl = CAM_BASE;
// const fetch_url = `http://100.82.205.44/Colour-preview`;
async function fetchSnapshot(cameraSide: string) {
const response = await fetch(`${apiUrl}/${cameraSide}-preview`);
const response = await fetch(`${apiUrl}/${cameraSide}-preview`, {
signal: AbortSignal.timeout(500),
});
if (!response.ok) {
throw new Error("Cannot reach endpoint");
}
@@ -75,9 +77,5 @@ export function useGetOverviewSnapshot(side: string) {
};
}, [drawImage]);
if (isError) {
console.error("Snapshot error:", error);
}
return { canvasRef, isError, isPending };
return { canvasRef, isError, error, isPending };
}