import { mdiLogout, mdiServer } from "@mdi/js"; import Icon from "@mdi/react"; import { AppBar, IconButton, Toolbar, Typography } from "@mui/material"; import { RouterLink } from "./RouterLink"; import { AsyncWidget } from "./AsyncWidget"; import { AuthApi, AuthInfo } from "../api/AuthApi"; import React from "react"; import { useAuth } from "../App"; import { useLoadingMessage } from "../hooks/providers/LoadingMessageProvider"; export function VirtWebAppBar(): React.ReactElement { const loadingMessage = useLoadingMessage(); const auth = useAuth(); const [info, setInfo] = React.useState(null); const load = async () => { setInfo(await AuthApi.GetAuthInfo()); }; const signOut = async () => { loadingMessage.show("Signing out..."); try { await AuthApi.SignOut(); } catch (e) { console.error(e); } auth.setSignedIn(false); loadingMessage.hide(); window.location.href = "/"; }; return ( ( VirtWeb
{info?.id}
)} /> ); }