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

23 lines
981 B
TypeScript
Raw Normal View History

2025-10-27 09:35:59 +00:00
import { createContext, useContext, type ActionDispatch, type SetStateAction } from "react";
import type { DedupedSightings, NPEDACTION, NPEDSTATE, ReducedSightingType } from "../types/types";
type IntegrationsValue = {
sessionStarted: boolean;
sessionPaused: boolean;
setSessionPaused: React.Dispatch<SetStateAction<boolean>>;
setSessionStarted: React.Dispatch<SetStateAction<boolean>>;
sessionList: ReducedSightingType[];
setSessionList: React.Dispatch<SetStateAction<ReducedSightingType[]>>;
savedSightings: DedupedSightings;
setSavedSightings: React.Dispatch<SetStateAction<DedupedSightings>>;
state: NPEDSTATE;
dispatch: ActionDispatch<[action: NPEDACTION]>;
};
export const IntegrationsContext = createContext<IntegrationsValue | undefined>(undefined);
export const useIntegrationsContext = () => {
const ctx = useContext(IntegrationsContext);
if (!ctx) throw new Error("useNPEDContext must be used within <IntegrationsProvider>");
return ctx;
};