diff options
author | ilyayudovin <ilyayudovin123@gmail.com> | 2020-06-28 19:09:20 +0300 |
---|---|---|
committer | ilyayudovin <ilyayudovin123@gmail.com> | 2020-06-28 19:09:20 +0300 |
commit | 7ad127942bb12ee9de691e10dc9386849459ea46 (patch) | |
tree | 1e576177546a8d3fe7f0f5dbf40bed34ca23a75e /src/pages/ProfilePage/ProfileInfo.tsx | |
parent | ccb26a42a3ad8d748e00cfbe9687f3198d5b8cb4 (diff) | |
download | which-ui-7ad127942bb12ee9de691e10dc9386849459ea46.tar.gz |
feat: add poll submission component
Diffstat (limited to 'src/pages/ProfilePage/ProfileInfo.tsx')
-rw-r--r-- | src/pages/ProfilePage/ProfileInfo.tsx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/pages/ProfilePage/ProfileInfo.tsx b/src/pages/ProfilePage/ProfileInfo.tsx index 2b9227e..fada65f 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}> { @@ -112,7 +122,7 @@ const ProfileInfo: React.FC<PropTypes> = ({ <Avatar className={classes.avatar} src={user?.avatarUrl} /> </Badge> </div> - <UploadImage displayD={input} setDisplayD={setInput} setUserInfo={setUserInfo} setUser={setUser} /> + <UploadImage displayD={input} setDisplayD={setInput} callback={patchAvatar} /> </div> ) : <Avatar className={classes.avatar} src={user?.avatarUrl} /> |