refactor: switch to using Authenticated and Navigate components
This commit is contained in:
parent
33decc2e2d
commit
6fbbe4975c
|
@ -1,24 +1,12 @@
|
||||||
import {useGo, useIsAuthenticated} from "@refinedev/core";
|
import {Authenticated} from "@refinedev/core";
|
||||||
import {useEffect} from "react";
|
import {Navigate} from "@remix-run/react";
|
||||||
|
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
const {isLoading, data} = useIsAuthenticated();
|
return (
|
||||||
|
<Authenticated v3LegacyAuthProviderCompatible key={"index"} loading={
|
||||||
const go = useGo();
|
<>Checking Login Status</>
|
||||||
|
}>
|
||||||
useEffect(() => {
|
<Navigate to="/dashboard" replace/>
|
||||||
if (!isLoading) {
|
</Authenticated>
|
||||||
if (data?.authenticated) {
|
)
|
||||||
go({to: "/dashboard", type: "replace"});
|
|
||||||
} else {
|
|
||||||
go({to: "/login", type: "replace"});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [isLoading, data]);
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <>Checking Login Status</> || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (<>Redirecting</>) || null;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue