Refactor camera feed components and add sighting tables
- Updated mode settings in camera feed reducer to use "painter" - Renamed PlatePatch component to SightingPatch and updated imports - Removed obsolete PlatePatch component - Added SightingEntryTable and SightingExitTable components for displaying sighting data - Implemented useSightingEntryAndExit hook for fetching entry and exit sightings - Adjusted VideoFeedGridPainter for improved width calculation - Introduced DecodeReading type for better typing
This commit is contained in:
28
src/features/cameras/hooks/useSightingEntryAndExit.ts
Normal file
28
src/features/cameras/hooks/useSightingEntryAndExit.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { CAMBASE } from "../../../utils/config";
|
||||
|
||||
const fetchEntrySightings = async (cameraFeedID: string) => {
|
||||
const response = await fetch(`${CAMBASE}/EntrySightingCreator${cameraFeedID}-list-proto-sightings`);
|
||||
if (!response.ok) throw new Error("Cannot reach sighing entry endpoint");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const fetchExitSightings = async (cameraFeedID: string) => {
|
||||
const response = await fetch(`${CAMBASE}/ExitSightingCreator${cameraFeedID}-list-proto-sightings`);
|
||||
if (!response.ok) throw new Error("Cannot reach sighing exit endpoint");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const useSightingEntryAndExit = (cameraFeedID: string) => {
|
||||
const entryQuery = useQuery({
|
||||
queryKey: ["Entry Sightings", cameraFeedID],
|
||||
queryFn: () => fetchEntrySightings(cameraFeedID),
|
||||
});
|
||||
|
||||
const exitQuery = useQuery({
|
||||
queryKey: ["Exit Sightings", cameraFeedID],
|
||||
queryFn: () => fetchExitSightings(cameraFeedID),
|
||||
});
|
||||
|
||||
return { entryQuery, exitQuery };
|
||||
};
|
||||
Reference in New Issue
Block a user