- refactored NPED Login & logout

This commit is contained in:
2025-10-27 09:35:59 +00:00
parent 18534ceb2c
commit 251a2f5e7b
11 changed files with 76 additions and 76 deletions

View 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;
};