import { useQuery } from "@tanstack/react-query"; import { CAMBASE } from "../../../utils/config"; const getfeed = async (cameraFeedID: "A" | "B" | "C" | null) => { const response = await fetch(`${CAMBASE}/TargetDetectionColour${cameraFeedID}-preview`, { signal: AbortSignal.timeout(300000), cache: "no-store", }); if (!response.ok) { throw new Error(`Cannot reach endpoint (${response.status})`); } return response.blob(); }; export const useGetVideoFeed = (cameraFeedID: "A" | "B" | "C" | null) => { const videoQuery = useQuery({ queryKey: ["getfeed", cameraFeedID], queryFn: () => getfeed(cameraFeedID), refetchInterval: 500, }); return { videoQuery }; };