File size: 501 Bytes
a0c836f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import { Navigate, Outlet } from "react-router-dom"
import { useAuth } from "../auth/AuthContext"
export default function ProtectedRoute() {
const { isAuthenticated, loading } = useAuth()
if (loading) {
return (
<div style={{
width: "100%", height: "100vh", display: "flex",
alignItems: "center", justifyContent: "center", color: "#64748b",
}}>
Loading…
</div>
)
}
return isAuthenticated ? <Outlet /> : <Navigate to="/login" replace />
}
|