From 4109cd1b2fca7e4934f0aba1c3a7fabab62270bb Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Thu, 13 Aug 2020 20:50:31 +0300
Subject: feat: create AttachLink component

---
 src/containers/Profile/ProfileInfo.tsx | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

(limited to 'src/containers/Profile/ProfileInfo.tsx')

diff --git a/src/containers/Profile/ProfileInfo.tsx b/src/containers/Profile/ProfileInfo.tsx
index 87af99d..83555e9 100644
--- a/src/containers/Profile/ProfileInfo.tsx
+++ b/src/containers/Profile/ProfileInfo.tsx
@@ -6,7 +6,7 @@ import CameraAltIcon from '@material-ui/icons/CameraAlt';
 import VerifiedIcon from '@material-ui/icons/CheckCircleOutline';
 import Skeleton from '@material-ui/lab/Skeleton';
 import Highlight from './Highlight';
-import UploadImage from '../../components/UploadImage/UploadImage';
+import AttachLink from '../../components/AttachLink/AttachLink';
 import Avatar from '../../components/Avatar/Avatar';
 import { patch } from '../../requests';
 import { useAuth } from '../../hooks/useAuth';
@@ -86,14 +86,9 @@ const ProfileInfo: React.FC<PropTypes> = ({
   savedPolls, totalVotes, setUserInfo, userInfo
 }) => {
   const classes = useStyles();
-  const [input, setInput] = useState(false);
   const { user } = useAuth();
   const dateSince = new Date(userInfo?.createdAt || '').toLocaleDateString();
 
-  const handleClick = () => {
-    setInput(!input);
-  };
-
   const patchAvatar = (url: string) => {
     const id = user?._id;
     patch(`/users/${id}`, { avatarUrl: url }).then(res => {
@@ -108,7 +103,7 @@ const ProfileInfo: React.FC<PropTypes> = ({
           ? <Skeleton animation="wave" variant="circle" width={150} height={150} className={classes.avatar} />
           : userInfo?._id === user?._id
             ? (
-              <div>
+              <AttachLink callback={patchAvatar}>
                 <div className={classes.avatarContainer}>
                   <Badge
                     overlap="circle"
@@ -116,7 +111,6 @@ const ProfileInfo: React.FC<PropTypes> = ({
                       vertical: 'bottom',
                       horizontal: 'right'
                     }}
-                    onClick={handleClick}
                     badgeContent={(
                       <div className={classes.badge}>
                         <CameraAltIcon />
@@ -126,8 +120,7 @@ const ProfileInfo: React.FC<PropTypes> = ({
                     <Avatar className={classes.avatar} user={userInfo} />
                   </Badge>
                 </div>
-                <UploadImage isOpen={input} setIsOpen={setInput} callback={patchAvatar} />
-              </div>
+              </AttachLink>
             )
             : <Avatar className={classes.avatar} user={userInfo} />
       }
-- 
cgit v1.2.3


From 02c346c65f266c1ffc108a27795c4aee9bb7616b Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Thu, 13 Aug 2020 21:36:51 +0300
Subject: fix: resolve eslint errors

---
 src/containers/Profile/ProfileInfo.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/containers/Profile/ProfileInfo.tsx')

diff --git a/src/containers/Profile/ProfileInfo.tsx b/src/containers/Profile/ProfileInfo.tsx
index 83555e9..82f640d 100644
--- a/src/containers/Profile/ProfileInfo.tsx
+++ b/src/containers/Profile/ProfileInfo.tsx
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React from 'react';
 import { Badge, Typography } from '@material-ui/core/';
 import { makeStyles } from '@material-ui/core/styles';
 import { User } from 'which-types';
-- 
cgit v1.2.3

