aboutsummaryrefslogtreecommitdiff
path: root/src/pages/ProfilePage/ProfileInfo.tsx
diff options
context:
space:
mode:
authorEugene Sokolov <eug-vs@keemail.me>2020-06-29 22:10:04 +0300
committerGitHub <noreply@github.com>2020-06-29 22:10:04 +0300
commit98c5a70c17416e470544a4b597461771d5a36325 (patch)
tree10ca1c1f4dd342eaca3ff1aa7698c54ae1e0f10f /src/pages/ProfilePage/ProfileInfo.tsx
parent699c702ca941c0e7e5fdcb971c9135e28b80c221 (diff)
parentaed13f230d2673a489aec455e48d6edbb503e001 (diff)
downloadwhich-ui-98c5a70c17416e470544a4b597461771d5a36325.tar.gz
Merge pull request #52 from which-ecosystem/pollSubmission
feat: add poll submission component
Diffstat (limited to 'src/pages/ProfilePage/ProfileInfo.tsx')
-rw-r--r--src/pages/ProfilePage/ProfileInfo.tsx15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/pages/ProfilePage/ProfileInfo.tsx b/src/pages/ProfilePage/ProfileInfo.tsx
index 2b9227e..9fe5912 100644
--- a/src/pages/ProfilePage/ProfileInfo.tsx
+++ b/src/pages/ProfilePage/ProfileInfo.tsx
@@ -7,6 +7,7 @@ import VerifiedIcon from '@material-ui/icons/CheckCircleOutline';
import MoreMenu from './MoreMenu';
import Highlight from './Highlight';
import UploadImage from '../../components/UploadImage/UploadImage';
+import { patch } from '../../requests';
interface PropTypes {
@@ -82,12 +83,21 @@ const ProfileInfo: React.FC<PropTypes> = ({
const classes = useStyles();
const [input, setInput] = useState(false);
+
const dateSince = new Date(user?.createdAt || '').toLocaleDateString();
const handleClick = () => {
setInput(!input);
};
+ const patchAvatar = (url: string) => {
+ const id = localStorage.getItem('userId');
+ patch(`/users/${id}`, { avatarUrl: url }).then(res => {
+ setUserInfo(res.data);
+ setUser(res.data);
+ });
+ };
+
return (
<div className={classes.root}>
{
@@ -97,7 +107,6 @@ const ProfileInfo: React.FC<PropTypes> = ({
<MoreMenu logOut={logOut} />
<div className={classes.avatarContainer}>
<Badge
- onClick={handleClick}
overlap="circle"
anchorOrigin={{
vertical: 'bottom',
@@ -105,14 +114,14 @@ const ProfileInfo: React.FC<PropTypes> = ({
}}
badgeContent={(
<div className={classes.badge}>
- <CameraAltIcon />
+ <CameraAltIcon onClick={handleClick} />
</div>
)}
>
<Avatar className={classes.avatar} src={user?.avatarUrl} />
</Badge>
</div>
- <UploadImage displayD={input} setDisplayD={setInput} setUserInfo={setUserInfo} setUser={setUser} />
+ <UploadImage isOpen={input} setIsOpen={setInput} callback={patchAvatar} />
</div>
)
: <Avatar className={classes.avatar} src={user?.avatarUrl} />