import { getBasepath, navigate } from "hookrouter" import * as React from "react" import { Application, isExecutableApplication } from "../common/api" import { HttpError } from "../common/http" import { normalize, Options } from "../common/util" import { Modal } from "./components/modal" export interface AppProps { options: Options } const App: React.FunctionComponent = (props) => { const [authed, setAuthed] = React.useState(!!props.options.authed) const [app, setApp] = React.useState(props.options.app) const [error, setError] = React.useState() React.useEffect(() => { if (app && !isExecutableApplication(app)) { navigate(normalize(`${getBasepath()}/${app.path}/`, true)) } }, [app]) if (typeof window !== "undefined") { // eslint-disable-next-line @typescript-eslint/no-explicit-any ;(window as any).setAuthed = (a: boolean): void => { if (authed !== a) { setAuthed(a) } } } return ( <> {authed && app && app.embedPath ? ( ) : null} ) } export default App