- refactored NPED Login & logout
This commit is contained in:
22
src/context/IntegrationsContext.ts
Normal file
22
src/context/IntegrationsContext.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user