Can set user recovery key from UI
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
import { Button } from "@mui/material";
|
||||
import Box from "@mui/material/Box";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import Toolbar from "@mui/material/Toolbar";
|
||||
import useMediaQuery from "@mui/material/useMediaQuery";
|
||||
import * as React from "react";
|
||||
import { Outlet, useNavigate } from "react-router";
|
||||
import { AuthApi, type UserInfo } from "../../api/AuthApi";
|
||||
import { useAuth } from "../../App";
|
||||
import { useAlert } from "../../hooks/contexts_provider/AlertDialogProvider";
|
||||
import { useLoadingMessage } from "../../hooks/contexts_provider/LoadingMessageProvider";
|
||||
import { AsyncWidget } from "../AsyncWidget";
|
||||
import DashboardHeader from "./DashboardHeader";
|
||||
import DashboardSidebar from "./DashboardSidebar";
|
||||
import { AuthApi, type UserInfo } from "../../api/AuthApi";
|
||||
import { AsyncWidget } from "../AsyncWidget";
|
||||
import { Button } from "@mui/material";
|
||||
import { useAuth } from "../../App";
|
||||
|
||||
interface UserInfoContext {
|
||||
info: UserInfo;
|
||||
@@ -21,12 +23,25 @@ const UserInfoContextK = React.createContext<UserInfoContext | null>(null);
|
||||
|
||||
export default function BaseAuthenticatedPage(): React.ReactElement {
|
||||
const theme = useTheme();
|
||||
const alert = useAlert();
|
||||
const loadingMessage = useLoadingMessage();
|
||||
|
||||
const [userInfo, setuserInfo] = React.useState<null | UserInfo>(null);
|
||||
const loadUserInfo = async () => {
|
||||
setuserInfo(await AuthApi.GetUserInfo());
|
||||
};
|
||||
|
||||
const reloadUserInfo = async () => {
|
||||
try {
|
||||
loadingMessage.show("Refreshing user information...");
|
||||
} catch (e) {
|
||||
console.error(`Failed to load user information! ${e}`);
|
||||
alert(`Failed to load user information! ${e}`);
|
||||
} finally {
|
||||
loadingMessage.hide();
|
||||
}
|
||||
};
|
||||
|
||||
const auth = useAuth();
|
||||
const navigate = useNavigate();
|
||||
|
||||
@@ -85,7 +100,7 @@ export default function BaseAuthenticatedPage(): React.ReactElement {
|
||||
<UserInfoContextK
|
||||
value={{
|
||||
info: userInfo!,
|
||||
reloadUserInfo: loadUserInfo,
|
||||
reloadUserInfo,
|
||||
signOut,
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user