Migrate to React Router

This commit is contained in:
2025-10-02 18:35:29 +03:00
Unverified
parent 2995bc96ac
commit aa1fb8c518
14 changed files with 514 additions and 54 deletions
+21
View File
@@ -0,0 +1,21 @@
import { useEffect } from "react";
import { useAppState } from "./app/ui/state";
import { useNavigate } from "react-router-dom";
interface ProtectedRouteProps {
children: React.ReactNode;
}
export default function ProtectedRoute({ children }: ProtectedRouteProps) {
const { user } = useAppState();
const navigate = useNavigate();
useEffect(() => {
if (!user.authToken) {
navigate("/login");
return;
}
}, [user.authToken, user.currentUser, navigate]);
return <>{children}</>;
}