MCPcopy Create free account
hub / github.com/bsoc-bitbyte/busify / AdminProtectedRoute

Function AdminProtectedRoute

frontend/src/components/AdminProtectedRoutes.tsx:10–35  ·  view source on GitHub ↗
({
  children,
})

Source from the content-addressed store, hash-verified

8};
9
10const AdminProtectedRoute: React.FC<AdminProtectedRoutetypes> = ({
11 children,
12}) => {
13 const {user, isloading} = useAuthStore();
14
15 if (isloading) {
16 return (
17 <Box
18 sx={{
19 display: 'flex',
20 justifyContent: 'center',
21 alignItems: 'center',
22 height: '70vh',
23 }}
24 >
25 <CircularProgress size={100} />
26 </Box>
27 );
28 }
29
30 if (user?.role !== 'admin') {
31 toast.error('Your role should be Admin to continue');
32 return <Navigate to="/" />;
33 }
34 return <>{children}</>;
35};
36
37export default AdminProtectedRoute;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected