From 77dc482dda42f9532ece78c4c568b37658270c0a Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Wed, 12 Aug 2020 04:26:54 +0300
Subject: feat: improve Avatar

---
 src/components/Avatar/Avatar.tsx | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

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

diff --git a/src/components/Avatar/Avatar.tsx b/src/components/Avatar/Avatar.tsx
index e445891..29754c9 100644
--- a/src/components/Avatar/Avatar.tsx
+++ b/src/components/Avatar/Avatar.tsx
@@ -1,35 +1,27 @@
 import React from 'react';
 import { useHistory } from 'react-router-dom';
 import { Avatar as AvatarBase } from '@material-ui/core';
-import AccountCircle from '@material-ui/icons/AccountCircle';
 import { User } from 'which-types';
 
 interface PropTypes {
-  user: User;
+  user?: User;
   className?: string;
 }
 
 const Avatar: React.FC<PropTypes> = ({ user, className }) => {
   const history = useHistory();
-  const { username, avatarUrl } = user;
 
   const handleClick = () => {
-    history.push(`/profile/${username}`);
+    if (user) history.push(`/profile/${user.username}`);
   };
 
-  return avatarUrl ? (
+  return (
     <AvatarBase
-      src={avatarUrl}
-      alt={username[0].toUpperCase()}
+      src={user?.avatarUrl}
       onClick={handleClick}
       className={className}
       style={{ cursor: 'pointer' }}
     />
-  ) : (
-    <AccountCircle
-      className={className}
-      onClick={handleClick}
-    />
   );
 };
 
-- 
cgit v1.2.3

