import { useMutation } from "@tanstack/react-query"; import { CAMBASE } from "../../../utils/config"; import type { ColourDetectionPayload } from "../../../types/types"; const sendColourDetectionData = async (colourData: ColourDetectionPayload) => { const regions = { regions: colourData.regions, }; const response = await fetch(`${CAMBASE}/TargetDetectionColour${colourData.cameraFeedID}-region-update`, { method: "POST", body: JSON.stringify(regions), }); if (!response.ok) throw new Error("Cannot send data to colour detection endpoint"); return response.json(); }; export const useColourDectection = () => { const colourMutation = useMutation({ mutationKey: ["colour detection"], mutationFn: (colourData: ColourDetectionPayload) => sendColourDetectionData(colourData), }); return { colourMutation }; };