diff --git a/Birdmap.API/ClientApp/src/App.tsx b/Birdmap.API/ClientApp/src/App.tsx index 62012d5..a798956 100644 --- a/Birdmap.API/ClientApp/src/App.tsx +++ b/Birdmap.API/ClientApp/src/App.tsx @@ -29,9 +29,11 @@ const theme = createMuiTheme({ function App() { const [authenticated, setAuthenticated] = useState(AuthService.isAuthenticated()); + const [isAdmin, setIsAdmin] = useState(AuthService.isAdmin()); const onAuthenticated = () => { setAuthenticated(AuthService.isAuthenticated()); + setIsAdmin(AuthService.isAdmin()); }; const AuthComponent = () => { @@ -57,9 +59,9 @@ function App() { - - - + + + @@ -71,22 +73,22 @@ export default App; const PublicRoute = ({ component: Component, ...rest }: { [x: string]: any, component: any}) => { return ( ( - + )} /> ); } -const PrivateRoute = ({ component: Component, authenticated: Authenticated, ...rest }: { [x: string]: any, component: any, authenticated: any }) => { +const PrivateRoute = ({ component: Component, authenticated: Authenticated, isAdmin: IsAdmin, ...rest }: { [x: string]: any, component: any, authenticated: any, isAdmin: any }) => { return ( ( Authenticated - ? + ? : )} /> ); }; -const DefaultLayout = ({ component: Component, authenticated: Authenticated, ...rest }: { [x: string]: any, component: any, authenticated: any }) => { +const DefaultLayout = ({ component: Component, authenticated: Authenticated, isAdmin: IsAdmin, ...rest }: { [x: string]: any, component: any, authenticated: any, isAdmin: any }) => { const classes = useDefaultLayoutStyles(); const [open, setOpen] = React.useState(false); const anchorRef = React.useRef(null); @@ -173,7 +175,7 @@ const DefaultLayout = ({ component: Component, authenticated: Authenticated, ... - + );