aboutsummaryrefslogtreecommitdiff
path: root/src/pages/ProfilePage/ProfilePage.tsx
blob: 984fb1e49209201a92fa15696f28e49384a5e80c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React, { useState,useEffect } from 'react';
import { User, Poll } from '../../types';
import ProfileInfo from './ProfileInfo';
import Feed from '../../components/Feed/Feed';
import { get } from '../../requests';

interface PropTypes {
  logOut: () => void;
  id: string;
}

const ProfilePage: React.FC<PropTypes> = ({ logOut, id }) => {
  const [userInfo, setUserInfo] = useState<User>();
  const [polls, setPolls] = useState<Poll[]>([]);

  useEffect(() => {
    get(`/users/${id}`).then(response => {
      setUserInfo(response.data);
    });
  },[]);

  useEffect(() => {
    get(`/profiles/${id}`).then(response => {
      setPolls(response.data);
    });
  },[]);


  return (
    <>
      <ProfileInfo user={userInfo} logOut={logOut} />
      <Feed polls={polls} />
    </>
  );
};

export default ProfilePage;