Revert "fix: route redirection issue"

This reverts commit 9a8a7ee978.
This commit is contained in:
Derrick Hammer 2024-03-20 13:19:53 -04:00
parent 081df029e0
commit 33decc2e2d
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 17 additions and 12 deletions

View File

@ -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) { if (data?.authenticated) {
go({to: "/dashboard", type: "replace"}); go({to: "/dashboard", type: "replace"});
} else { } else {
go({to: "/login", type: "replace"}); go({to: "/login", type: "replace"});
} }
}
return <>Redirecting</>; }, [isLoading, data]);
if (isLoading) {
return <>Checking Login Status</> || null;
}
return (<>Redirecting</>) || null;
} }