From 61a424debfbfa98570e070fbf25d03aa9c56d679 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sun, 14 Jun 2020 20:39:16 +0300
Subject: refactor: structurize pages

---
 src/index.tsx | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

(limited to 'src/index.tsx')

diff --git a/src/index.tsx b/src/index.tsx
index 5888170..5ab1910 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -10,8 +10,9 @@ import teal from '@material-ui/core/colors/teal';
 import 'typeface-roboto';
 
 import Header from './components/Header/Header';
-import Feed from './components/Feed/Feed';
 import ProfilePage from './pages/ProfilePage/ProfilePage';
+import FeedPage from './pages/FeedPage/FeedPage';
+import AuthPage from './pages/AuthPage/AuthPage';
 import { User } from './types';
 import { get } from './requests';
 
@@ -36,6 +37,12 @@ const App: React.FC = () => {
   const [user, setUser] = React.useState<User | undefined>();
   const classes = useStyles();
 
+  const logOut = () => {
+    localStorage.removeItem('userId');
+    setUser(undefined);
+  };
+
+
   useEffect(() => {
     const userId = localStorage.getItem('userId');
     if (userId) {
@@ -52,8 +59,12 @@ const App: React.FC = () => {
       <div className={classes.root}>
         {
           page === 'profile'
-            ? <ProfilePage setUser={setUser} user={user} />
-            : <Feed page={page} />
+            ? (
+              user
+                ? <ProfilePage logOut={logOut} id={user?._id} />
+                : <AuthPage setUser={setUser} />
+            )
+            : <FeedPage />
         }
       </div>
     </ThemeProvider>
-- 
cgit v1.2.3

