import { Redirect } from "react-router-dom"; import { useApplicationState } from "../../mobx/State"; import { Children } from "../../types/Preact"; import { useClient } from "./RevoltClient"; interface Props { auth?: boolean; children: Children; } export const CheckAuth = (props: Props) => { const auth = useApplicationState().auth; const client = useClient(); const ready = auth.isLoggedIn() && typeof client?.user !== "undefined"; if (props.auth && !ready) { return ; } else if (!props.auth && ready) { return ; } return <>{props.children}; };