2025-08-29 10:07:59 +01:00
|
|
|
import { createContext, useContext, type SetStateAction } from "react";
|
2025-09-16 14:20:38 +01:00
|
|
|
import type { NPEDUser } from "../types/types";
|
2025-08-29 10:07:59 +01:00
|
|
|
|
|
|
|
|
type UserContextValue = {
|
2025-09-16 14:20:38 +01:00
|
|
|
user: NPEDUser | null;
|
2025-08-29 10:07:59 +01:00
|
|
|
setUser: React.Dispatch<SetStateAction<NPEDUser | null>>;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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>");
|
|
|
|
|
return ctx;
|
|
|
|
|
};
|