feat: authorize routes added

This commit is contained in:
2025-08-16 00:01:03 +03:30
parent e9b43b9e53
commit 2ad191064e
7 changed files with 41 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
import { Suspense, type ReactNode } from 'react';
import { createBrowserRouter, type RouteObject } from 'react-router-dom';
import { appRoutes, type RouteConfig } from './config';
import { ProtectedRoute } from '@/components/ProtectedRoute';
/**
* A recursive function to map our custom route config to the format
@@ -18,10 +19,9 @@ function mapRoutes(routes: RouteConfig[]): RouteObject[] {
// element = <route.layout>{element}</route.layout>;
// }
// Conditionally wrap the element in the authentication guard
// if (route.authRequired) {
// element = <ProtectedRoute>{element}</ProtectedRoute>;
// }
if (route.authorize) {
element = <ProtectedRoute>{element}</ProtectedRoute>;
}
return {
path: route.path,