import { mdiFamilyTree } from "@mdi/js"; import Icon from "@mdi/react"; import SettingsIcon from "@mui/icons-material/Settings"; import { Box, Button } from "@mui/material"; import AppBar from "@mui/material/AppBar"; import Menu from "@mui/material/Menu"; import MenuItem from "@mui/material/MenuItem"; import Toolbar from "@mui/material/Toolbar"; import Typography from "@mui/material/Typography"; import * as React from "react"; import { Link, Outlet, useNavigate } from "react-router-dom"; import { useAuth } from "../App"; import { AuthApi } from "../api/AuthApi"; import { User, UserApi } from "../api/UserApi"; import { AsyncWidget } from "./AsyncWidget"; import { RouterLink } from "./RouterLink"; import { DarkThemeButton } from "./DarkThemeButton"; interface UserContext { user: User; reloadUserInfo: () => void; } const UserContextK = React.createContext(null); export function BaseAuthenticatedPage(): React.ReactElement { const [user, setUser] = React.useState(null); const auth = useAuth(); const navigate = useNavigate(); const [anchorEl, setAnchorEl] = React.useState(null); const load = async () => { setUser(await UserApi.GetUserInfo()); }; const handleMenu = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget); }; const handleCloseMenu = () => { setAnchorEl(null); }; const signOut = () => { handleCloseMenu(); AuthApi.SignOut(); navigate("/"); auth.setSignedIn(false); }; return ( ( 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], }} > GeneIT
Profil Déconnexion
)} /> ); } export function useUser(): UserContext { return React.useContext(UserContextK)!; }