portal-dashboard/app/routes/_index.tsx

20 lines
399 B
TypeScript
Raw Permalink Normal View History

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