23 lines
981 B
TypeScript
23 lines
981 B
TypeScript
|
|
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;
|
||
|
|
};
|