From 1ac600e2fd9024604d98c525957cd2fbfdf9a779 Mon Sep 17 00:00:00 2001 From: ilyayudovin Date: Fri, 12 Jun 2020 18:29:51 +0300 Subject: feat: take user info from database --- src/ProfileInfo/ProfileInfo.tsx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/ProfileInfo/ProfileInfo.tsx') 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 = ({ profile }) => { +const ProfileInfo: React.FC = ({ id }) => { + const [userInfo, setUserInfo] = useState(); + + let endpoint: string = '/users/' + id; + + get(endpoint).then(response => { + setUserInfo(response.data) + }); + const classes = useStyles(); return (
- +
- Nick Name + {userInfo?.name}
-- cgit v1.2.3