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;
|
2025-08-22 10:38:28 +01:00
|
|
|
side: string;
|
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;
|
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;
|
|
|
|
|
};
|