21 lines
516 B
TypeScript
21 lines
516 B
TypeScript
"use client";
|
|
|
|
import { createContext, useContext } from "react";
|
|
|
|
interface IAMContextType {
|
|
isClientRole: boolean;
|
|
permissions: Record<string, string[]> | null;
|
|
defaultClientPermissions: Record<string, string[]>;
|
|
canSee: (modName: string) => boolean;
|
|
}
|
|
|
|
export const IAMContext = createContext<IAMContextType | null>(null);
|
|
|
|
export const useIAM = () => {
|
|
const context = useContext(IAMContext);
|
|
if (!context) {
|
|
throw new Error("useIAM must be used within an IAMProvider");
|
|
}
|
|
return context;
|
|
};
|