Refactor camera feed handling to support dynamic camera IDs and improve context management

This commit is contained in:
2025-12-17 14:19:23 +00:00
parent cc8b3a5691
commit 775fce7900
19 changed files with 211 additions and 248 deletions

View File

@@ -1,6 +1,7 @@
import { useQuery, useMutation } from "@tanstack/react-query";
import { CAMBASE } from "../../../utils/config";
import type { CameraZoomConfig } from "../../../types/types";
import type { CameraID } from "../../../app/config/cameraConfig";
const fetchZoomLevel = async (cameraFeedID: string) => {
const response = await fetch(`${CAMBASE}/api/fetch-config?id=Camera${cameraFeedID}-onvif-controller`);
@@ -34,7 +35,7 @@ const postZoomLevel = async (zoomConfig: CameraZoomConfig) => {
return response.json();
};
export const useCameraZoom = (cameraFeedID: "A" | "B" | "C") => {
export const useCameraZoom = (cameraFeedID: CameraID) => {
const cameraZoomQuery = useQuery({
queryKey: ["cameraZoom", cameraFeedID],
queryFn: () => fetchZoomLevel(cameraFeedID),