portal-dashboard/app/routes/_index.tsx

26 lines
624 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() {
const {isLoading, data} = useIsAuthenticated();
const go = useGo();
2024-03-13 13:40:25 +00:00
useEffect(() => {
if (!isLoading) {
if (data?.authenticated) {
go({to: "/dashboard", type: "replace"});
} else {
go({to: "/login", type: "replace"});
}
}
}, [isLoading, data]);
2024-03-13 13:40:25 +00:00
if (isLoading) {
return <>Checking Login Status</> || null;
}
return (<>Redirecting</>) || null;
2024-03-05 16:56:17 +00:00
}