portal-dashboard/app/routes/_index.tsx

26 lines
546 B
TypeScript
Raw Normal View History

2024-03-13 13:40:25 +00:00
import Login from "./login";
import { useGo, useIsAuthenticated } from "@refinedev/core";
import { useEffect } from "react";
2024-03-05 16:56:17 +00:00
export default function Index() {
2024-03-13 13:40:25 +00:00
const { isLoading, data } = useIsAuthenticated();
2024-03-13 13:40:25 +00:00
const go = useGo();
useEffect(() => {
if (!isLoading && data?.authenticated) {
go({ to: "/dashboard", type: "replace" });
}
}, [isLoading, data]);
if (isLoading) {
return <>Checking Login Status</> || null;
}
if (data?.authenticated) {
return <>Redirecting</> || null;
}
2024-03-13 13:40:25 +00:00
return <Login />;
2024-03-05 16:56:17 +00:00
}