diff options
author | eug-vs <eug-vs@keemail.me> | 2020-08-12 04:26:54 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-08-12 04:27:08 +0300 |
commit | 77dc482dda42f9532ece78c4c568b37658270c0a (patch) | |
tree | e62d77d19446b84d69aff16afb03d8864e0aed9e /src/components/Avatar/Avatar.tsx | |
parent | 2dc5fc00347256982136deea98d483c444002595 (diff) | |
download | which-ui-77dc482dda42f9532ece78c4c568b37658270c0a.tar.gz |
feat: improve Avatar
Diffstat (limited to 'src/components/Avatar/Avatar.tsx')
-rw-r--r-- | src/components/Avatar/Avatar.tsx | 16 |
1 files changed, 4 insertions, 12 deletions
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} - /> ); }; |