- added session sighting component

- add new session paused state and stop adding to session when true
This commit is contained in:
2025-10-24 12:10:10 +01:00
parent b58181e551
commit c83122cd52
6 changed files with 84 additions and 56 deletions

View File

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

View File

@@ -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}