project setup

This commit is contained in:
Sone
2025-11-02 10:08:56 +01:00
commit 568838003e
174 changed files with 27100 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import { useAuthContext } from "@/auth/AuthContext";
import { RoleEnum } from "@/constants/roleEnum";
export const useRoleAccess = () => {
const { user } = useAuthContext();
const currentRole = user?.role;
const isUser = currentRole === RoleEnum.USER;
const isAdmin =
currentRole === RoleEnum.ADMIN || currentRole === RoleEnum.MANAGER;
const isManager = currentRole === RoleEnum.MANAGER;
return {
currentRole,
isUser,
isAdmin,
isManager,
hasAccess: (level: RoleEnum) => {
const hierarchy = [RoleEnum.USER, RoleEnum.ADMIN, RoleEnum.MANAGER];
return (
currentRole !== undefined &&
hierarchy.indexOf(currentRole) >= hierarchy.indexOf(level)
);
},
};
};