first commit
This commit is contained in:
commit
c9fb67e751
423 files changed
+53287
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import React from "react";
|
||||
import { Navigate, Outlet, useLocation } from "react-router-dom";
|
||||
import { useAuth } from "../contexts/AuthContext";
|
||||
|
||||
export const PrivateRoute: React.FC = () => {
|
||||
const { isAuthenticated } = useAuth();
|
||||
const location = useLocation();
|
||||
|
||||
return isAuthenticated ? (
|
||||
<Outlet />
|
||||
) : (
|
||||
<Navigate to="/login" state={{ from: location }} replace />
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user