Files
Mav-Mobile-UI/src/context/SightingFeedContext.ts

33 lines
1021 B
TypeScript
Raw Normal View History

2025-08-29 10:07:59 +01:00
import { createContext, useContext } from "react";
2025-09-16 14:20:38 +01:00
import type { SightingType } from "../types/types";
2025-08-20 08:27:05 +01:00
type SightingFeedContextType = {
2025-09-16 14:20:38 +01:00
sightings: (SightingType | null | undefined)[];
2025-08-20 08:27:05 +01:00
selectedRef: number | null;
setSelectedRef: (ref: number | null) => void;
2025-09-16 14:20:38 +01:00
// effectiveSelected: SightingType | null;
mostRecent: SightingType | null;
side: string | undefined;
2025-09-12 08:21:52 +01:00
selectedSighting: SightingType | null;
2025-09-16 14:20:38 +01:00
setSelectedSighting: (sighting: SightingType | SightingType | null) => void;
2025-09-12 08:21:52 +01:00
setSightingModalOpen: (isSightingModalOpen: boolean) => void;
isSightingModalOpen: boolean;
isError: boolean;
isLoading: boolean;
data: SightingType | undefined;
sessionStarted: boolean;
2025-08-20 08:27:05 +01:00
};
2025-08-29 10:07:59 +01:00
export const SightingFeedContext = createContext<
SightingFeedContextType | undefined
>(undefined);
2025-08-20 08:27:05 +01:00
export const useSightingFeedContext = () => {
const ctx = useContext(SightingFeedContext);
if (!ctx)
throw new Error(
"useSightingFeedContext must be used within SightingFeedProvider"
);
return ctx;
};