portal-dashboard/app/routes/_index.tsx

25 lines
595 B
TypeScript
Raw Normal View History

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
}