import React from 'react'; import { Button, ClickAwayListener, Grow, MenuItem, MenuList, Paper, Popper, } from '@material-ui/core'; import Avatar from '@material-ui/core/Avatar'; import { makeStyles } from '@material-ui/core/styles'; import { useCurrentIdentityQuery } from './CurrentIdentity.generated'; const useStyles = makeStyles((theme) => ({ displayName: { marginLeft: theme.spacing(2), }, })); const CurrentIdentity = () => { const classes = useStyles(); const { loading, error, data } = useCurrentIdentityQuery(); const [open, setOpen] = React.useState(false); const anchorRef = React.useRef(null); if (error || loading || !data?.repository?.userIdentity) return null; const user = data.repository.userIdentity; const handleToggle = () => { setOpen((prevOpen) => !prevOpen); }; const handleClose = (event: any) => { if (anchorRef.current && anchorRef.current.contains(event.target)) { return; } setOpen(false); }; return ( <> {({ TransitionProps, placement }) => ( Name: {user.name ? user.name : 'none'} Id: {user.humanId ? user.humanId : 'none'} Email: {user.email ? user.email : 'none'} Login: {user.login ? user.login : 'none'} Protected: {user.isProtected ? user.login : 'not set'} )}
{user.displayName}
); }; export default CurrentIdentity;