2024-03-20 17:19:53 +00:00
|
|
|
import {useGo, useIsAuthenticated} from "@refinedev/core";
|
|
|
|
import {useEffect} from "react";
|
2024-03-05 16:56:17 +00:00
|
|
|
|
|
|
|
export default function Index() {
|
2024-03-20 17:19:53 +00:00
|
|
|
const {isLoading, data} = useIsAuthenticated();
|
2024-03-07 14:04:59 +00:00
|
|
|
|
2024-03-20 17:19:53 +00:00
|
|
|
const go = useGo();
|
2024-03-13 13:40:25 +00:00
|
|
|
|
2024-03-20 17:19:53 +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
|
|
|
|
2024-03-20 17:19:53 +00:00
|
|
|
if (isLoading) {
|
|
|
|
return <>Checking Login Status</> || null;
|
|
|
|
}
|
2024-03-07 14:04:59 +00:00
|
|
|
|
2024-03-20 17:19:53 +00:00
|
|
|
return (<>Redirecting</>) || null;
|
2024-03-05 16:56:17 +00:00
|
|
|
}
|