From b5ce9be31993f5b4bee9abbe57d775b7ea407507 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Tue, 11 Aug 2020 22:19:23 +0300
Subject: refactor: create separate Avatar component

---
 src/components/UserStrip/UserStrip.tsx | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

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

diff --git a/src/components/UserStrip/UserStrip.tsx b/src/components/UserStrip/UserStrip.tsx
index 73d9363..a837961 100644
--- a/src/components/UserStrip/UserStrip.tsx
+++ b/src/components/UserStrip/UserStrip.tsx
@@ -1,10 +1,11 @@
 import React from 'react';
-import { useHistory } from 'react-router-dom';
 import { makeStyles } from '@material-ui/core/styles';
 import VerifiedIcon from '@material-ui/icons/CheckCircleOutline';
-import { Avatar, CardHeader } from '@material-ui/core/';
+import { CardHeader } from '@material-ui/core/';
 import { User } from 'which-types';
 
+import Avatar from '../Avatar/Avatar';
+
 
 interface PropTypes {
   user: User;
@@ -21,30 +22,15 @@ const useStyles = makeStyles(theme => ({
     marginLeft: theme.spacing(0.5),
     width: theme.spacing(2),
     height: theme.spacing(2)
-  },
-  avatar: {
-    cursor: 'pointer'
   }
 }));
 
 
 const UserStrip: React.FC<PropTypes> = ({ user, info }) => {
   const classes = useStyles();
-  const history = useHistory();
-  const { username, avatarUrl, verified } = user;
-
-  const handleNavigate = () => {
-    history.push(`/profile/${username}`);
-  };
-
-  const avatar = (
-    <Avatar
-      src={avatarUrl}
-      alt={username[0].toUpperCase()}
-      onClick={handleNavigate}
-      className={classes.avatar}
-    />
-  );
+  const { username, verified } = user;
+
+  const avatar = <Avatar user={user} />;
 
   const title = (
     <div className={classes.root}>
-- 
cgit v1.2.3

