From 4b6d5ac4a027442c5a4fb164ef2bb9fc4323aaa2 Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Tue, 28 Mar 2023 22:13:03 +0100 Subject: [PATCH] Fix router --- src/App.tsx | 364 +++++++++++++++++------- src/components/Protected/index.tsx | 19 ++ src/components/ProtectedRoute/index.tsx | 13 - src/components/Public/index.tsx | 19 ++ src/components/PublicRoute/index.tsx | 11 - src/components/index.tsx | 8 +- 6 files changed, 305 insertions(+), 129 deletions(-) create mode 100644 src/components/Protected/index.tsx delete mode 100644 src/components/ProtectedRoute/index.tsx create mode 100644 src/components/Public/index.tsx delete mode 100644 src/components/PublicRoute/index.tsx diff --git a/src/App.tsx b/src/App.tsx index 365cc2a..1145618 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,10 +1,10 @@ import jwtDecode from 'jwt-decode'; import { useEffect } from 'react'; -import { Routes, Navigate } from 'react-router-dom'; +import { Routes, Route, Navigate } from 'react-router-dom'; import { useLazyQuery, useReactiveVar } from '@apollo/client'; import { - ProtectedRoute, - PublicRoute, + Protected, + Public, Navbar, Sidebar, Spinner, @@ -91,109 +91,271 @@ const App = () => { )} - + {role !== 'admin' ? ( ) : ( )} - - - - - - - - - - - - - - - - - - - - - - - -