import { Box, Button } from "@mui/material"; import * as React from "react"; import { Outlet } from "react-router-dom"; import { AuthApi, AuthInfo } from "../api/AuthApi"; import { AsyncWidget } from "./AsyncWidget"; import { SolarEnergyAppBar } from "./SolarEnergyAppBar"; import { SolarEnergyNavList } from "./SolarEnergyNavList"; interface AuthInfoContext { info: AuthInfo; reloadAuthInfo: () => void; } const AuthInfoContextK = React.createContext(null); export function BaseAuthenticatedPage(): React.ReactElement { const [authInfo, setAuthInfo] = React.useState(null); const signOut = () => { AuthApi.SignOut(); }; const load = async () => { setAuthInfo(await AuthApi.GetAuthInfo()); }; return ( ( <> )} build={() => ( theme.palette.mode === "light" ? theme.palette.grey[100] : theme.palette.grey[900], color: (theme) => theme.palette.mode === "light" ? theme.palette.grey[900] : theme.palette.grey[100], }} >
)} /> ); } export function useAuthInfo(): AuthInfoContext { return React.useContext(AuthInfoContextK)!; }