36 lines
932 B
TypeScript
36 lines
932 B
TypeScript
import { createBrowserRouter, Navigate } from 'react-router-dom'
|
|
import { Layout } from './components/Layout'
|
|
import { AuthGuard } from './components/AuthGuard'
|
|
import { Login } from './pages/Login'
|
|
import { Dashboard } from './pages/Dashboard'
|
|
import { Users } from './pages/Users'
|
|
import { Profile } from './pages/Profile'
|
|
|
|
export const router = createBrowserRouter([
|
|
{ path: '/login', element: <Login /> },
|
|
{
|
|
path: '/',
|
|
element: <Layout />,
|
|
children: [
|
|
{ index: true, element: <Dashboard /> },
|
|
{
|
|
path: 'users',
|
|
element: (
|
|
<AuthGuard allowedRoles={['admin', 'system_admin']} requireAuth>
|
|
<Users />
|
|
</AuthGuard>
|
|
),
|
|
},
|
|
{
|
|
path: 'profile',
|
|
element: (
|
|
<AuthGuard requireAuth>
|
|
<Profile />
|
|
</AuthGuard>
|
|
),
|
|
},
|
|
],
|
|
},
|
|
{ path: '*', element: <Navigate to="/" replace /> },
|
|
])
|