first commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { Outlet, useNavigate } from "react-router-dom";
|
||||
import { useEffect } from "react";
|
||||
|
||||
const PrivateRoute = () => {
|
||||
const navigate = useNavigate();
|
||||
const token = document.cookie
|
||||
.split("; ")
|
||||
.find((row) => row.startsWith("token="))
|
||||
?.split("=")[1];
|
||||
|
||||
useEffect(() => {
|
||||
if (!token) {
|
||||
navigate("/humic-20242025-2");
|
||||
}
|
||||
}, [navigate, token]);
|
||||
|
||||
return token ? <Outlet /> : null;
|
||||
};
|
||||
|
||||
export default PrivateRoute;
|
||||
Reference in New Issue
Block a user