Files
Mav-Mobile-UI/src/hooks/useCameraZoom.ts

23 lines
609 B
TypeScript
Raw Normal View History

import { useMutation } from "@tanstack/react-query";
import { CAM_BASE } from "../utils/config";
import type { ZoomInOptions } from "../types/types";
async function zoomIn(options: ZoomInOptions) {
const response = await fetch(
`${CAM_BASE}/Ip${options.camera}-command?magnification=${options.multiplier}x`
);
if (!response.ok) {
throw new Error("Cannot reach camera zoom endpoint");
}
return;
}
export const useCameraZoom = () => {
const mutation = useMutation({
mutationKey: ["zoomIn"],
mutationFn: (options: ZoomInOptions) => zoomIn(options),
});
return { mutation };
};