Qassure-frontend/src/routes/index.tsx

49 lines
1.3 KiB
TypeScript

import { Routes, Route } from 'react-router-dom';
import type { ReactElement } from 'react';
import NotFound from '@/pages/NotFound';
import ProtectedRoute from '@/pages/ProtectedRoute';
import TenantProtectedRoute from '@/pages/TenantProtectedRoute';
import { publicRoutes } from './public-routes';
import { superAdminRoutes } from './super-admin-routes';
import { tenantAdminRoutes } from './tenant-admin-routes';
// App Routes Component
export const AppRoutes = (): ReactElement => {
return (
<Routes>
{/* Public Routes */}
{publicRoutes.map((route) => (
<Route key={route.path} path={route.path} element={route.element} />
))}
{/* Super Admin Routes */}
{superAdminRoutes.map((route) => (
<Route
key={route.path}
path={route.path}
element={<ProtectedRoute>{route.element}</ProtectedRoute>}
/>
))}
{/* Tenant Admin Routes */}
{tenantAdminRoutes.map((route) => (
<Route
key={route.path}
path={route.path}
element={<TenantProtectedRoute>{route.element}</TenantProtectedRoute>}
/>
))}
{/* 404 - Catch all route */}
<Route
path="*"
element={
<ProtectedRoute>
<NotFound />
</ProtectedRoute>
}
/>
</Routes>
);
};