Download admin/src/auth/ProtectedRoute.tsx from Abhisingh-18/Labour-Connect: direct link, hf CLI and curl.
- Browser
- Download file 548 Bytes
-
https://huggingface.co/Abhisingh-18/Labour-Connect/resolve/main/admin/src/auth/ProtectedRoute.tsx
- Command line
-
hf download hf://Abhisingh-18/Labour-Connect/admin/src/auth/ProtectedRoute.tsx
-
curl -L -o ProtectedRoute.tsx https://huggingface.co/Abhisingh-18/Labour-Connect/resolve/main/admin/src/auth/ProtectedRoute.tsx
548 Bytes
| import { Box, CircularProgress } from "@mui/material"; | |
| import { Navigate, Outlet } from "react-router-dom"; | |
| import { useAuth } from "./AuthContext"; | |
| export default function ProtectedRoute() { | |
| const { user, loading } = useAuth(); | |
| if (loading) { | |
| return ( | |
| <Box | |
| sx={{ | |
| height: "100vh", | |
| display: "grid", | |
| placeItems: "center", | |
| }} | |
| > | |
| <CircularProgress /> | |
| </Box> | |
| ); | |
| } | |
| if (!user) return <Navigate to="/login" replace />; | |
| return <Outlet />; | |
| } | |