import React from 'react'; import gql from 'graphql-tag'; import { Query } from 'react-apollo'; import Avatar from '@material-ui/core/Avatar'; import { makeStyles } from '@material-ui/styles'; const useStyles = makeStyles(theme => ({ displayName: { marginLeft: theme.spacing(2), }, })); const QUERY = gql` { defaultRepository { userIdentity { displayName avatarUrl } } } `; const CurrentIdentity = () => { const classes = useStyles(); return ( {({ loading, error, data }) => { if (error || loading || !data.defaultRepository.userIdentity) return null; const user = data.defaultRepository.userIdentity; return ( <> {user.displayName.charAt(0).toUpperCase()}
{user.displayName}
); }}
); }; export default CurrentIdentity;