From 3969face39ecc933b1cb9c7625be921d148552cb Mon Sep 17 00:00:00 2001
From: ilyayudovin <ilyayudovin123@gmail.com>
Date: Sun, 14 Jun 2020 01:31:05 +0300
Subject: feat: add sing in form

---
 src/index.tsx | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

(limited to 'src/index.tsx')

diff --git a/src/index.tsx b/src/index.tsx
index adf44a5..98be8a7 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -13,7 +13,8 @@ import Header from './Header/Header';
 import Feed from './Feed/Feed';
 import ProfileInfo from './ProfileInfo/ProfileInfo';
 
-import { get } from './requests';
+import SignInForm from './Form/SignInForm';
+import { User } from './types';
 
 const theme = createMuiTheme({
   palette: {
@@ -33,20 +34,17 @@ const useStyles = makeStyles({
 
 const App: React.FC = () => {
   const [page, setPage] = useState('feed');
-  const [id, setId] = useState<string>('');
+  const [user, setUser] = React.useState<User | undefined>();
   const classes = useStyles();
 
-  get('/users').then(response => {
-    setId(response.data[0]._id);
-  });
-
   return (
     <ThemeProvider theme={theme}>
       <CssBaseline />
       <Header setPage={setPage} />
       <div className={classes.root}>
         {
-          page === 'profile' && <ProfileInfo id={id} />
+          // eslint-disable-next-line
+          page === 'profile' && (!user ? <SignInForm setUser={setUser} /> : <ProfileInfo id={user?._id || ''} setUser={setUser} />)
         }
         <Feed page={page} />
       </div>
-- 
cgit v1.2.3

