import { mdiFamilyTree } from "@mdi/js"; import Icon from "@mdi/react"; import SettingsIcon from "@mui/icons-material/Settings"; import { 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"; 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 ( (
GeneIT
Profil Déconnexion
)} /> ); } export function useUser(): UserContext { return React.useContext(UserContextK)!; }