Add video feed feature with related components and hooks

- Implemented VideoFeed component to display sightings.
- Created useSightingList and useVideoFeed hooks for data fetching and state management.
- Added AppProviders for context management.
- Updated Dashboard to include VideoFeed.
- Introduced types for sightings in utils/types.tsx.
- Added Header and Footer components for layout.
- Configured React Query for data handling.
This commit is contained in:
2025-12-19 16:04:06 +00:00
parent c38e3439e2
commit 276dcd26ed
18 changed files with 194 additions and 5 deletions

View File

@@ -0,0 +1,32 @@
import { useQuery } from "@tanstack/react-query";
import { cambase } from "../../../app/config";
import { useEffect, useRef } from "react";
const fetchVideoFeed = async (refId: number) => {
const response = await fetch(`${cambase}/mergedHistory/sightingSummary?mostRecentRef=${refId}`);
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.json();
};
export const useVideoFeed = () => {
const currentRefId = useRef<number>(-1);
const videoFeedQuery = useQuery({
queryKey: ["videoFeed"],
queryFn: () => fetchVideoFeed(currentRefId.current),
refetchInterval: 1000,
refetchOnWindowFocus: false,
retry: false,
staleTime: 0,
});
useEffect(() => {
if (videoFeedQuery.data?.ref !== -1) {
currentRefId.current = videoFeedQuery?.data?.ref;
}
}, [videoFeedQuery.data]);
return { videoFeedQuery };
};