- refactored NPED Login & logout
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
import { useEffect, useReducer, useState, type ReactNode } from "react";
|
||||
import type { DedupedSightings, NPEDUser, ReducedSightingType } from "../../types/types";
|
||||
import { NPEDUserContext } from "../NPEDUserContext";
|
||||
import type { DedupedSightings, ReducedSightingType } from "../../types/types";
|
||||
import { IntegrationsContext } from "../IntegrationsContext";
|
||||
import { useCameraBlackboard } from "../../hooks/useCameraBlackboard";
|
||||
import { initialState, reducer } from "../reducers/NPEDContextReducer";
|
||||
import { initialState, reducer } from "../reducers/IntegrationsContextReducer";
|
||||
|
||||
type NPEDUserProviderType = {
|
||||
type IntegrationsProviderType = {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export const NPEDUserProvider = ({ children }: NPEDUserProviderType) => {
|
||||
export const IntegrationsProvider = ({ children }: IntegrationsProviderType) => {
|
||||
const [state, dispatch] = useReducer(reducer, initialState);
|
||||
const { mutation } = useCameraBlackboard();
|
||||
const [user, setUser] = useState<NPEDUser | null>(null);
|
||||
const [sessionStarted, setSessionStarted] = useState(false);
|
||||
const [sessionList, setSessionList] = useState<ReducedSightingType[]>([]);
|
||||
const [sessionPaused, setSessionPaused] = useState(false);
|
||||
@@ -28,12 +27,10 @@ export const NPEDUserProvider = ({ children }: NPEDUserProviderType) => {
|
||||
};
|
||||
fetchData();
|
||||
}, []);
|
||||
console.log(savedSightings);
|
||||
|
||||
return (
|
||||
<NPEDUserContext.Provider
|
||||
<IntegrationsContext.Provider
|
||||
value={{
|
||||
user,
|
||||
setUser,
|
||||
setSessionStarted,
|
||||
sessionStarted,
|
||||
sessionList,
|
||||
@@ -42,9 +39,11 @@ export const NPEDUserProvider = ({ children }: NPEDUserProviderType) => {
|
||||
setSessionPaused,
|
||||
savedSightings,
|
||||
setSavedSightings,
|
||||
state,
|
||||
dispatch,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</NPEDUserContext.Provider>
|
||||
</IntegrationsContext.Provider>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user