parent
081df029e0
commit
33decc2e2d
|
@ -1,19 +1,24 @@
|
||||||
import { useGo, useIsAuthenticated } from "@refinedev/core";
|
import {useGo, useIsAuthenticated} from "@refinedev/core";
|
||||||
|
import {useEffect} from "react";
|
||||||
|
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
const { isLoading, data } = useIsAuthenticated();
|
const {isLoading, data} = useIsAuthenticated();
|
||||||
|
|
||||||
const go = useGo();
|
const go = useGo();
|
||||||
|
|
||||||
if (isLoading) {
|
useEffect(() => {
|
||||||
return <>Checking Login Status</>;
|
if (!isLoading) {
|
||||||
}
|
if (data?.authenticated) {
|
||||||
|
go({to: "/dashboard", type: "replace"});
|
||||||
|
} else {
|
||||||
|
go({to: "/login", type: "replace"});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [isLoading, data]);
|
||||||
|
|
||||||
if (data?.authenticated) {
|
if (isLoading) {
|
||||||
go({ to: "/dashboard", type: "replace" });
|
return <>Checking Login Status</> || null;
|
||||||
} else {
|
}
|
||||||
go({ to: "/login", type: "replace" });
|
|
||||||
}
|
|
||||||
|
|
||||||
return <>Redirecting</>;
|
return (<>Redirecting</>) || null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue