aboutsummaryrefslogtreecommitdiff
path: root/src/components/Avatar/Avatar.tsx
diff options
context:
space:
mode:
authorEugene Sokolov <eug-vs@keemail.me>2020-08-13 17:27:32 +0300
committerGitHub <noreply@github.com>2020-08-13 17:27:32 +0300
commitd1e0dcd8538a61184eca50fbf7769c6d2943ff6b (patch)
tree9c2ba42d34e469d292fc1fe807e3f814a872a69e /src/components/Avatar/Avatar.tsx
parent2dc5fc00347256982136deea98d483c444002595 (diff)
parent52799ec4e4cd5801423ee0d2aa56039c061afdb4 (diff)
downloadwhich-ui-d1e0dcd8538a61184eca50fbf7769c6d2943ff6b.tar.gz
Merge pull request #78 from which-ecosystem/redesign
Move PollSubmission to separate page and add FAB
Diffstat (limited to 'src/components/Avatar/Avatar.tsx')
-rw-r--r--src/components/Avatar/Avatar.tsx16
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}
- />
);
};