Refactored routing components for better organization and maintainability

This commit is contained in:
2025-12-17 16:07:01 +00:00
parent 775fce7900
commit dab49fd99c
5 changed files with 28 additions and 21 deletions

View File

@@ -1,7 +1,8 @@
import { useQuery } from "@tanstack/react-query";
import { CAMBASE } from "../../../utils/config";
import type { CameraID } from "../../../app/config/cameraConfig";
const targetDectionFeed = async (cameraFeedID: "A" | "B" | "C" | null) => {
const targetDectionFeed = async (cameraFeedID: CameraID | null) => {
const response = await fetch(`${CAMBASE}/TargetDetectionColour${cameraFeedID}-preview`, {
signal: AbortSignal.timeout(300000),
cache: "no-store",
@@ -12,7 +13,7 @@ const targetDectionFeed = async (cameraFeedID: "A" | "B" | "C" | null) => {
return response.blob();
};
const getVideoFeed = async (cameraFeedID: "A" | "B" | "C" | null) => {
const getVideoFeed = async (cameraFeedID: CameraID | null) => {
const response = await fetch(`${CAMBASE}/Camera${cameraFeedID}-preview`, {
signal: AbortSignal.timeout(300000),
cache: "no-store",
@@ -23,7 +24,7 @@ const getVideoFeed = async (cameraFeedID: "A" | "B" | "C" | null) => {
return response.blob();
};
export const useGetVideoFeed = (cameraFeedID: "A" | "B" | "C" | null, mode: string) => {
export const useGetVideoFeed = (cameraFeedID: CameraID | null, mode: string) => {
const targetDetectionQuery = useQuery({
queryKey: ["getfeed", cameraFeedID],
queryFn: () => targetDectionFeed(cameraFeedID),