From 352172487ad70da77a51a170266ba530253808ef Mon Sep 17 00:00:00 2001 From: april Date: Mon, 8 Jan 2024 10:28:06 -0600 Subject: [PATCH] Redirect from root to dashboard/login --- web/app/routes/_index.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/web/app/routes/_index.tsx b/web/app/routes/_index.tsx index a67e866..a29a2bb 100644 --- a/web/app/routes/_index.tsx +++ b/web/app/routes/_index.tsx @@ -1,5 +1,18 @@ -import { Outlet } from "@remix-run/react"; +import { useAuth } from "@/util/auth"; +import { Outlet, useNavigate } from "@remix-run/react"; +import { useEffect } from "react"; export default function Tailfin() { + const { user, loading } = useAuth(); + const navigate = useNavigate(); + + useEffect(() => { + if (!loading && !user) { + navigate("/login"); + } else { + navigate("/logbook"); + } + }, [user, loading, navigate]); + return ; }