aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilyayudovin <ilyayudovin123@gmail.com>2020-06-14 17:28:24 +0300
committerilyayudovin <ilyayudovin123@gmail.com>2020-06-14 17:28:24 +0300
commit657c340ea9e244b7f1041bac5be240d428d758e5 (patch)
tree890978dd6a98b1dc4a582935d37c79528ed4c524
parent3c3223c3b41411639ff19ebd58df569cf17999ca (diff)
downloadwhich-ui-657c340ea9e244b7f1041bac5be240d428d758e5.tar.gz
feat: add profilePage to render ProfileInfo and SignInForm
-rw-r--r--src/Pages/ProfilePage/ProfileInfo.tsx (renamed from src/Pages/ProfilePage/ProfileInfo/ProfileInfo.tsx)4
-rw-r--r--src/Pages/ProfilePage/ProfilePage.tsx30
-rw-r--r--src/Pages/ProfilePage/SignInForm.tsx (renamed from src/Pages/ProfilePage/Form/SignInForm.tsx)4
-rw-r--r--src/index.tsx19
4 files changed, 38 insertions, 19 deletions
diff --git a/src/Pages/ProfilePage/ProfileInfo/ProfileInfo.tsx b/src/Pages/ProfilePage/ProfileInfo.tsx
index af866f8..8fce8df 100644
--- a/src/Pages/ProfilePage/ProfileInfo/ProfileInfo.tsx
+++ b/src/Pages/ProfilePage/ProfileInfo.tsx
@@ -2,8 +2,8 @@ import React, { useState } from 'react';
import { Avatar } from '@material-ui/core/';
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button/Button';
-import { User } from '../../../types';
-import { get } from '../../../requests';
+import { User } from '../../types';
+import { get } from '../../requests';
interface PropTypes {
id: string;
diff --git a/src/Pages/ProfilePage/ProfilePage.tsx b/src/Pages/ProfilePage/ProfilePage.tsx
new file mode 100644
index 0000000..8d082dc
--- /dev/null
+++ b/src/Pages/ProfilePage/ProfilePage.tsx
@@ -0,0 +1,30 @@
+import React, {useState} from 'react';
+import {makeStyles} from '@material-ui/core/styles';
+import {User} from '../../types';
+import SignInForm from "./SignInForm";
+import ProfileInfo from "./ProfileInfo";
+
+interface PropTypes {
+ id: string;
+ setUser: (newUser: User | undefined) => void;
+ user: User | undefined;
+}
+
+const useStyles = makeStyles({
+
+});
+
+const ProfilePage: React.FC<PropTypes> = ({id, setUser, user}) => {
+ const classes = useStyles();
+
+ return (
+ user ? (
+ <>
+ <ProfileInfo id={user?._id || ''} setUser={setUser} />
+ </>
+ )
+ : <SignInForm setUser={setUser} />
+ )
+};
+
+export default ProfilePage;
diff --git a/src/Pages/ProfilePage/Form/SignInForm.tsx b/src/Pages/ProfilePage/SignInForm.tsx
index bfdc283..6e27535 100644
--- a/src/Pages/ProfilePage/Form/SignInForm.tsx
+++ b/src/Pages/ProfilePage/SignInForm.tsx
@@ -2,8 +2,8 @@ import React, { useRef } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
-import { User } from '../../../types';
-import { get } from '../../../requests';
+import { User } from '../../types';
+import { get } from '../../requests';
interface PropTypes {
setUser: (newUser: User) => void;
diff --git a/src/index.tsx b/src/index.tsx
index ec31728..a5e1168 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -11,9 +11,9 @@ import 'typeface-roboto';
import Header from './Components/Header/Header';
import Feed from './Components/Feed/Feed';
-import ProfileInfo from './Pages/ProfilePage/ProfileInfo/ProfileInfo';
-
-import SignInForm from './Pages/ProfilePage/Form/SignInForm';
+import ProfileInfo from './Pages/ProfilePage/ProfileInfo';
+import ProfilePage from './Pages/ProfilePage/ProfilePage';
+import SignInForm from './Pages/ProfilePage/SignInForm';
import { User } from './types';
import { get } from './requests';
@@ -53,18 +53,7 @@ const App: React.FC = () => {
<Header setPage={setPage} />
<div className={classes.root}>
{
- page === 'profile'
- ? (
- user
- ? (
- <>
- <ProfileInfo id={user?._id || ''} setUser={setUser} />
- <Feed page={page} />
- </>
- )
- : <SignInForm setUser={setUser} />
- )
- : <Feed page={page} />
+ page === 'profile' ? <ProfilePage id={user?._id || ''} setUser={setUser} user={user} /> : <Feed page={page} />
}
</div>
</ThemeProvider>