diff --git a/ui/src/App.tsx b/ui/src/App.tsx index c883797..322f4c0 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -26,7 +26,7 @@ export const App = () => { + } diff --git a/ui/src/components/ProtectedRoute.tsx b/ui/src/components/ProtectedRoute.tsx index ffd179e..64042e6 100644 --- a/ui/src/components/ProtectedRoute.tsx +++ b/ui/src/components/ProtectedRoute.tsx @@ -1,6 +1,7 @@ import { ReactNode, useEffect } from "react"; import { useSession } from "../contexts/SessionContext"; import { useNavigate } from "react-router-dom"; + interface ProtectedRouteProps { children: ReactNode; to?: string; @@ -9,11 +10,16 @@ interface ProtectedRouteProps { export const ProtectedRoute = ({ children, to }: ProtectedRouteProps) => { const { session } = useSession(); const navigate = useNavigate(); - useEffect(() => { - let timer = setTimeout(() => { + const timer = setTimeout(() => { if (!session) { - navigate(to ?? "/landing"); + const isFirstTimeUser = + localStorage.getItem("xtablo-has-seen-landing-page") === null; + if (isFirstTimeUser) { + navigate("/landing"); + } else { + navigate(to ?? "/login"); + } } }, 300); return () => clearTimeout(timer); diff --git a/ui/src/pages/landing.tsx b/ui/src/pages/landing.tsx index 75e43f4..535b13a 100644 --- a/ui/src/pages/landing.tsx +++ b/ui/src/pages/landing.tsx @@ -5,6 +5,7 @@ import logo from "../assets/icon.jpg"; import { Header } from "../components/header"; export const LandingPage = () => { + localStorage.setItem("xtablo-has-seen-landing-page", "true"); return ( <>