import { mdiFamilyTree } from "@mdi/js"; import Icon from "@mdi/react"; import SettingsIcon from "@mui/icons-material/Settings"; import { Alert, Button, CircularProgress } 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 { useSetAtom } from "jotai"; import * as React from "react"; import { Link, Outlet, useNavigate } from "react-router-dom"; import { AuthApi } from "../api/AuthApi"; import { User, UserApi } from "../api/UserApi"; import { RouterLink } from "./RouterLink"; export function BaseAuthenticatedPage(): React.ReactElement { const [user, setUser] = React.useState(null); const [error, setError] = React.useState(false); const setSignedIn = useSetAtom(AuthApi.authStatus); const navigate = useNavigate(); const [anchorEl, setAnchorEl] = React.useState(null); const handleMenu = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget); }; const handleCloseMenu = () => { setAnchorEl(null); }; const signOut = () => { handleCloseMenu(); AuthApi.SignOut(); navigate("/"); setSignedIn(false); }; React.useEffect(() => { const load = async () => { if (error || user != null) return; try { const user = await UserApi.GetUserInfo(); setUser(user); } catch (e) { console.error(e); setError(true); } }; load(); }); if (error) return (
Echec du chagement des informations utilisateur ! Réessayer
); if (user === null) return (
); return (
GeneIT
Profil Déconnexion
); }