GRAB X APOTEK X Hospital PORTAL
This commit is contained in:
@@ -11,12 +11,16 @@ import Register from '@/pages/auth/Register';
|
||||
import VerifyCode from '@/pages/auth/VerifyCode';
|
||||
import { AuthProvider } from '@/contexts/LaravelAuthContext';
|
||||
import AuthGuard from '@/guards/AuthGuard';
|
||||
import useAuth from '@/hooks/useAuth';
|
||||
import RoleBasedGuard from '@/guards/RoleBasedGuard';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const Loadable = (Component: ElementType) => (props: any) => {
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
const { pathname } = useLocation();
|
||||
const {user} = useAuth();
|
||||
const formattedRoleName = user?.role.name;
|
||||
|
||||
return (
|
||||
<Suspense fallback={<LoadingScreen isDashboard={pathname.includes('/dashboard')} />}>
|
||||
@@ -74,11 +78,19 @@ export default function Router() {
|
||||
{ element: <Navigate to="/dashboard" replace />, index: true },
|
||||
{
|
||||
path: 'dashboard',
|
||||
element: <Dashboard />,
|
||||
element: (
|
||||
<RoleBasedGuard accessibleRoles={['hospital-admin']}>
|
||||
<Dashboard />
|
||||
</RoleBasedGuard>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/detail/:id',
|
||||
element: <DetailClaimReport />,
|
||||
element: (
|
||||
<RoleBasedGuard accessibleRoles={['hospital-admin']}>
|
||||
<DetailClaimReport />
|
||||
</RoleBasedGuard>
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -95,18 +107,54 @@ export default function Router() {
|
||||
{ element: <Navigate to="/claim" replace />, index: true },
|
||||
{
|
||||
path: 'claim',
|
||||
element: <Claim />,
|
||||
element: (
|
||||
<RoleBasedGuard accessibleRoles={['hospital-admin']}>
|
||||
<Claim />
|
||||
</RoleBasedGuard>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/claim/detail/:id',
|
||||
element: <DetailClaim />,
|
||||
element: (
|
||||
<RoleBasedGuard accessibleRoles={['hospital-admin']}>
|
||||
<DetailClaim />
|
||||
</RoleBasedGuard>
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
path: '/',
|
||||
element: (
|
||||
<AuthProvider>
|
||||
<AuthGuard>
|
||||
<DashboardLayout />
|
||||
</AuthGuard>
|
||||
</AuthProvider>
|
||||
),
|
||||
children: [
|
||||
{ element: <Navigate to="/prescription-orders" replace />, index: true },
|
||||
{
|
||||
path: 'prescription-orders',
|
||||
element: (
|
||||
<RoleBasedGuard accessibleRoles={['admin-apotek', 'cs-lms']}>
|
||||
<DashboardApotek />
|
||||
</RoleBasedGuard>
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
path: '*',
|
||||
element: <LogoOnlyLayout />,
|
||||
element: (
|
||||
<AuthProvider>
|
||||
<AuthGuard>
|
||||
<LogoOnlyLayout />
|
||||
</AuthGuard>
|
||||
</AuthProvider>
|
||||
),
|
||||
children: [
|
||||
{ path: '404', element: <NotFound /> },
|
||||
{ path: '*', element: <Navigate to="/404" replace /> },
|
||||
@@ -123,6 +171,7 @@ const ForgetPassword = Loadable(lazy(() => import('@/pages/auth/ForgetPassword')
|
||||
// Dashboard
|
||||
const Dashboard = Loadable(lazy(() => import('@/pages/Dashboard')));
|
||||
const Claim = Loadable(lazy(() => import('@/pages/Claim')));
|
||||
const DashboardApotek = Loadable(lazy(() => import('@/pages/DashboardApotek')));
|
||||
const NotFound = Loadable(lazy(() => import('@/pages/Page404')));
|
||||
|
||||
const DetailClaimReport = Loadable(lazy(()=> import('@/sections/dashboard/Detail')));
|
||||
|
||||
Reference in New Issue
Block a user