diff options
author | ilyayudovin <ilyayudovin123@gmail.com> | 2020-06-26 03:03:33 +0300 |
---|---|---|
committer | ilyayudovin <ilyayudovin123@gmail.com> | 2020-06-26 03:03:33 +0300 |
commit | 9e9c18cd1d02a0185d0387770a7bafc18020d6c0 (patch) | |
tree | 5cd676549a008039c71296016fa0ccb537eac328 | |
parent | c5b771b87b92260e19f0c43ed83151c8e3d49f73 (diff) | |
download | which-ui-9e9c18cd1d02a0185d0387770a7bafc18020d6c0.tar.gz |
display user avatar instead avatarIcon in header
-rw-r--r-- | src/components/Header/Header.tsx | 15 | ||||
-rw-r--r-- | src/index.tsx | 2 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index 4e25fa3..eb24ecc 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -3,7 +3,7 @@ import { AppBar, Toolbar, IconButton, - Typography + Typography, Avatar } from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; import AccountCircle from '@material-ui/icons/AccountCircle'; @@ -13,6 +13,7 @@ import HomeIcon from '@material-ui/icons/Home'; import SearchBar from './SearchBar'; interface PropTypes { + userImage: string | undefined; navigate: (prefix: string) => void; } @@ -25,10 +26,14 @@ const useStyles = makeStyles({ }, logo: { fontWeight: 'bold' + }, + avatar:{ + width: 24, + height: 24 } }); -const Header: React.FC<PropTypes> = ({ navigate }) => { +const Header: React.FC<PropTypes> = ({ navigate, userImage }) => { const classes = useStyles(); const handleHome = (): void => { @@ -56,7 +61,11 @@ const Header: React.FC<PropTypes> = ({ navigate }) => { <NotificationsIcon /> </IconButton> <IconButton onClick={handleProfile}> - <AccountCircle /> + { + localStorage.getItem('token') + ? <Avatar className={classes.avatar} src={userImage}/> + : <AccountCircle /> + } </IconButton> </div> </Toolbar> diff --git a/src/index.tsx b/src/index.tsx index 50b19f7..d50700b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -90,7 +90,7 @@ const App: React.FC = () => { return ( <ThemeProvider theme={theme}> <CssBaseline /> - <Header navigate={navigate} /> + <Header navigate={navigate} userImage={user?.avatarUrl}/> <div className={classes.root}> { page.prefix === 'profile' && <ProfilePage logOut={logOut} id={page.id} navigate={navigate} /> } { page.prefix === 'feed' && <FeedPage navigate={navigate} /> } |