Files
Mav-Mobile-UI/src/context/NPEDUserContext.ts

18 lines
541 B
TypeScript
Raw Normal View History

2025-08-29 10:07:59 +01:00
import { createContext, useContext, type SetStateAction } from "react";
2025-08-29 14:55:37 +01:00
import type { NPEDCameraConfig, NPEDUser } from "../types/types";
2025-08-29 10:07:59 +01:00
type UserContextValue = {
2025-08-29 14:55:37 +01:00
user: NPEDCameraConfig | 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;
};