- 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
29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
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 };
|
|
};
|