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

@@ -4,10 +4,14 @@ import { CAM_BASE } from "../utils/config";
const base_url = `${CAM_BASE}/api`;
const fetch_url = `http://100.82.205.44/api/fetch-config?id=Colour`;
console.log(fetch_url);
const fetchCameraSideConfig = async ({ queryKey }: { queryKey: string[] }) => {
const [, cameraSide] = queryKey;
const fetchUrl = `${base_url}/fetch-config?id=${cameraSide}`;
const response = await fetch(fetchUrl);
const response = await fetch(fetchUrl, {
signal: AbortSignal.timeout(500),
});
if (!response.ok) throw new Error("cannot react cameraSide ");
return response.json();
};
@@ -53,5 +57,6 @@ export const useFetchCameraConfig = (cameraSide: string) => {
isError: fetchedConfigQuery.isError,
updateCameraConfig: updateConfigMutation.mutate,
updateCameraConfigError: updateConfigMutation.error,
updateCameraConfigLoading: updateConfigMutation.isPending,
};
};