diff options
author | ilyayudovin <ilyayudovin123@gmail.com> | 2020-06-12 18:29:51 +0300 |
---|---|---|
committer | ilyayudovin <ilyayudovin123@gmail.com> | 2020-06-12 18:29:51 +0300 |
commit | 1ac600e2fd9024604d98c525957cd2fbfdf9a779 (patch) | |
tree | 872c39e078f478935a9481d89ed5bb09336f6cab /src/ProfileInfo | |
parent | f0f192e09993eedc2c9596bcdb520a96f5cfacdb (diff) | |
download | which-ui-1ac600e2fd9024604d98c525957cd2fbfdf9a779.tar.gz |
feat: take user info from database
Diffstat (limited to 'src/ProfileInfo')
-rw-r--r-- | src/ProfileInfo/ProfileInfo.tsx | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/ProfileInfo/ProfileInfo.tsx b/src/ProfileInfo/ProfileInfo.tsx index ac8ef26..05a2b78 100644 --- a/src/ProfileInfo/ProfileInfo.tsx +++ b/src/ProfileInfo/ProfileInfo.tsx @@ -1,10 +1,11 @@ -import React from 'react'; +import React, {useEffect, useState} from 'react'; import { Avatar } from '@material-ui/core/'; import { makeStyles } from '@material-ui/core/styles'; -import { Poll } from '../types'; +import {Poll, User} from "../types"; +import {get} from "../requests"; interface PropTypes { - profile: Poll; + id: string; } const useStyles = makeStyles({ @@ -33,14 +34,22 @@ const useStyles = makeStyles({ } }); -const ProfileInfo: React.FC<PropTypes> = ({ profile }) => { +const ProfileInfo: React.FC<PropTypes> = ({ id }) => { + const [userInfo, setUserInfo] = useState<User>(); + + let endpoint: string = '/users/' + id; + + get(endpoint).then(response => { + setUserInfo(response.data) + }); + const classes = useStyles(); return ( <div> - <Avatar className={classes.avatar} src={profile.author.avatarUrl} /> + <Avatar className={classes.avatar} src={userInfo?.avatarUrl} /> <div className={classes.name}> - Nick Name + {userInfo?.name} </div> <div className={classes.profileMenu}> <div style={{ borderBottom: '1px solid green', color: 'green' }} className={classes.menuButton}> |