- added session sighting component
- add new session paused state and stop adding to session when true
This commit is contained in:
@@ -5,17 +5,16 @@ type UserContextValue = {
|
||||
user: NPEDUser | null;
|
||||
setUser: React.Dispatch<SetStateAction<NPEDUser | null>>;
|
||||
sessionStarted: boolean;
|
||||
sessionPaused: boolean;
|
||||
setSessionPaused: React.Dispatch<SetStateAction<boolean>>;
|
||||
setSessionStarted: React.Dispatch<SetStateAction<boolean>>;
|
||||
sessionList: ReducedSightingType[];
|
||||
setSessionList: React.Dispatch<SetStateAction<ReducedSightingType[]>>;
|
||||
};
|
||||
|
||||
export const NPEDUserContext = createContext<UserContextValue | undefined>(
|
||||
undefined
|
||||
);
|
||||
export const NPEDUserContext = createContext<UserContextValue | undefined>(undefined);
|
||||
export const useNPEDContext = () => {
|
||||
const ctx = useContext(NPEDUserContext);
|
||||
if (!ctx)
|
||||
throw new Error("useNPEDContext must be used within <NPEDUserProvider>");
|
||||
if (!ctx) throw new Error("useNPEDContext must be used within <NPEDUserProvider>");
|
||||
return ctx;
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@ export const NPEDUserProvider = ({ children }: NPEDUserProviderType) => {
|
||||
const [user, setUser] = useState<NPEDUser | null>(null);
|
||||
const [sessionStarted, setSessionStarted] = useState(false);
|
||||
const [sessionList, setSessionList] = useState<ReducedSightingType[]>([]);
|
||||
const [sessionPaused, setSessionPaused] = useState(false);
|
||||
|
||||
return (
|
||||
<NPEDUserContext.Provider
|
||||
@@ -20,6 +21,8 @@ export const NPEDUserProvider = ({ children }: NPEDUserProviderType) => {
|
||||
sessionStarted,
|
||||
sessionList,
|
||||
setSessionList,
|
||||
sessionPaused,
|
||||
setSessionPaused,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
||||
Reference in New Issue
Block a user