MSP-3074 add roles
This commit is contained in:
1 parent
5a29bfc7f6
commit
9c1b859971
36 files changed
+1063
-100
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import {useMemo} from 'react';
|
||||
import {useAppSelector} from "./redux.ts";
|
||||
import {PermissionKeys} from "../types/roles.type.ts";
|
||||
|
||||
export const useRole = () => {
|
||||
const {profile} = useAppSelector((state: any) => state.profileReducer);
|
||||
const role: string = useMemo(() => profile && profile.role, [profile]);
|
||||
|
||||
const hasPermission = (permission: PermissionKeys) => {
|
||||
const userPermission = profile.permissions || [];
|
||||
return userPermission.includes(permission);
|
||||
};
|
||||
|
||||
return {role, hasPermission};
|
||||
};
|
||||
|
||||
export default useRole;
|
||||
Reference in new issue
Block a user