From eff6ce851f8584ff3da954081041cf18cc488dd9 Mon Sep 17 00:00:00 2001 From: Davor Date: Thu, 19 May 2022 18:38:32 +0200 Subject: [PATCH] added ProtectedRoute for /users --- src/App.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index d556ce1..b9797b0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { Helmet } from 'react-helmet'; -import { Routes, Route, Navigate } from 'react-router-dom'; +import { Routes, Route, Navigate, Outlet } from 'react-router-dom'; import { Toaster } from 'react-hot-toast'; import { useAuth } from 'src/services/auth'; @@ -10,10 +10,14 @@ import { LoginCallback } from './modules/login/LoginCallback'; // eslint-disable-next-line @typescript-eslint/no-unused-vars function App() { - const { authToken, currentUser } = useAuth(); + const { authToken, currentUser, isAdmin } = useAuth(); const redirectToLogin = !authToken || !currentUser?.app_roles; + const ProtectedRoute = () => { + return isAdmin ? : ; + }; + return ( <> @@ -38,7 +42,9 @@ function App() { } /> - } /> + }> + } /> + } />