From 9e9c18cd1d02a0185d0387770a7bafc18020d6c0 Mon Sep 17 00:00:00 2001
From: ilyayudovin <ilyayudovin123@gmail.com>
Date: Fri, 26 Jun 2020 03:03:33 +0300
Subject: display user avatar instead avatarIcon in header

---
 src/components/Header/Header.tsx | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

(limited to 'src/components/Header/Header.tsx')

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>
-- 
cgit v1.2.3

