GRAB X APOTEK X Hospital PORTAL
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { Container, Alert, AlertTitle } from '@mui/material';
|
||||
import useAuth from '@/hooks/useAuth';
|
||||
import Page404 from '@/pages/Page404';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -9,9 +11,10 @@ type RoleBasedGuardProp = {
|
||||
};
|
||||
|
||||
const useCurrentRole = () => {
|
||||
// Logic here to get current user role
|
||||
const role = 'admin';
|
||||
return role;
|
||||
// Fetch the role from useAuth
|
||||
const { user } = useAuth();
|
||||
const formattedRoleName = user?.role.name || ''; // Default to empty string if role is undefined
|
||||
return formattedRoleName;
|
||||
};
|
||||
|
||||
export default function RoleBasedGuard({ accessibleRoles, children }: RoleBasedGuardProp) {
|
||||
|
||||
Reference in New Issue
Block a user