From 1da061645edefa5cbdc4eb072838740bb5514df4 Mon Sep 17 00:00:00 2001 From: Nick Savage Date: Fri, 22 Nov 2024 06:31:55 -0500 Subject: [PATCH] frontend: skip landing page --- zettelkasten-front/src/App.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/zettelkasten-front/src/App.tsx b/zettelkasten-front/src/App.tsx index 1e0e3f82..07d92595 100644 --- a/zettelkasten-front/src/App.tsx +++ b/zettelkasten-front/src/App.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import { Admin } from "./pages/admin/AdminPage"; import LandingPage from "./landing/LandingPage"; import LoginForm from "./pages/LoginPage"; @@ -7,8 +7,19 @@ import RegisterPage from "./pages/RegisterPage"; import { Routes, Route } from "react-router-dom"; import PasswordReset from "./pages/PasswordReset"; import EmailValidation from "./pages/EmailValidation"; +import { useAuth } from "./contexts/AuthContext"; + +import { useNavigate } from "react-router-dom"; function App() { + const navigate = useNavigate(); + const { isAuthenticated } = useAuth(); + useEffect(() => { + if (isAuthenticated && location.pathname === "/") { + navigate("/app"); + } + }, [isAuthenticated, navigate]); // Add dependencies + return (