13 lines
247 B
TypeScript
13 lines
247 B
TypeScript
|
|
import {Navigate} from "react-router-dom";
|
||
|
|
import {useAuth} from "@/context/AuthContext";
|
||
|
|
|
||
|
|
export default function ProtectedRoute({children}: any) {
|
||
|
|
const {token} = useAuth();
|
||
|
|
|
||
|
|
if (!token) {
|
||
|
|
return <Navigate to="/" />;
|
||
|
|
}
|
||
|
|
|
||
|
|
return children;
|
||
|
|
}
|