aboutsummaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/AuthPage/AuthPage.tsx5
-rw-r--r--src/pages/AuthPage/SignInForm.tsx4
-rw-r--r--src/pages/FeedPage/FeedPage.tsx8
-rw-r--r--src/pages/ProfilePage/ProfilePage.tsx11
4 files changed, 18 insertions, 10 deletions
diff --git a/src/pages/AuthPage/AuthPage.tsx b/src/pages/AuthPage/AuthPage.tsx
index d9c43d3..82d468d 100644
--- a/src/pages/AuthPage/AuthPage.tsx
+++ b/src/pages/AuthPage/AuthPage.tsx
@@ -4,10 +4,11 @@ import SignInForm from './SignInForm';
interface PropTypes {
setUser: (newUser: User | undefined) => void;
+ navigate: (prefix: string, id: string) => void;
}
-const AuthPage: React.FC<PropTypes> = ({ setUser }) => {
- return <SignInForm setUser={setUser} />;
+const AuthPage: React.FC<PropTypes> = ({ setUser, navigate }) => {
+ return <SignInForm setUser={setUser} navigate={navigate} />;
};
export default AuthPage;
diff --git a/src/pages/AuthPage/SignInForm.tsx b/src/pages/AuthPage/SignInForm.tsx
index 6e27535..b7696e7 100644
--- a/src/pages/AuthPage/SignInForm.tsx
+++ b/src/pages/AuthPage/SignInForm.tsx
@@ -7,6 +7,7 @@ import { get } from '../../requests';
interface PropTypes {
setUser: (newUser: User) => void;
+ navigate: (prefix: string, id: string) => void;
}
const useStyles = makeStyles(theme => ({
@@ -22,7 +23,7 @@ const useStyles = makeStyles(theme => ({
}
}));
-const SignInForm: React.FC<PropTypes> = ({ setUser }) => {
+const SignInForm: React.FC<PropTypes> = ({ setUser, navigate }) => {
const classes = useStyles();
const inputRef = useRef<HTMLInputElement>();
@@ -33,6 +34,7 @@ const SignInForm: React.FC<PropTypes> = ({ setUser }) => {
const user = response.data[0];
setUser(user);
localStorage.setItem('userId', user._id);
+ navigate('profile', user._id);
});
}
};
diff --git a/src/pages/FeedPage/FeedPage.tsx b/src/pages/FeedPage/FeedPage.tsx
index 03bacfd..fd75190 100644
--- a/src/pages/FeedPage/FeedPage.tsx
+++ b/src/pages/FeedPage/FeedPage.tsx
@@ -3,7 +3,11 @@ import { Poll } from '../../types';
import Feed from '../../components/Feed/Feed';
import { get } from '../../requests';
-const FeedPage: React.FC = () => {
+interface PropTypes {
+ navigate: (prefix: string, id: string) => void;
+}
+
+const FeedPage: React.FC<PropTypes> = ({ navigate }) => {
const [polls, setPolls] = useState<Poll[]>([]);
useEffect(() => {
@@ -12,7 +16,7 @@ const FeedPage: React.FC = () => {
});
}, []);
- return <Feed polls={polls} />;
+ return <Feed polls={polls} navigate={navigate} />;
};
export default FeedPage;
diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx
index 984fb1e..0f5fb2b 100644
--- a/src/pages/ProfilePage/ProfilePage.tsx
+++ b/src/pages/ProfilePage/ProfilePage.tsx
@@ -1,4 +1,4 @@
-import React, { useState,useEffect } from 'react';
+import React, { useState, useEffect } from 'react';
import { User, Poll } from '../../types';
import ProfileInfo from './ProfileInfo';
import Feed from '../../components/Feed/Feed';
@@ -6,10 +6,11 @@ import { get } from '../../requests';
interface PropTypes {
logOut: () => void;
+ navigate: (prefix: string, id: string) => void;
id: string;
}
-const ProfilePage: React.FC<PropTypes> = ({ logOut, id }) => {
+const ProfilePage: React.FC<PropTypes> = ({ logOut, id, navigate }) => {
const [userInfo, setUserInfo] = useState<User>();
const [polls, setPolls] = useState<Poll[]>([]);
@@ -17,19 +18,19 @@ const ProfilePage: React.FC<PropTypes> = ({ logOut, id }) => {
get(`/users/${id}`).then(response => {
setUserInfo(response.data);
});
- },[]);
+ }, [id]);
useEffect(() => {
get(`/profiles/${id}`).then(response => {
setPolls(response.data);
});
- },[]);
+ }, [id]);
return (
<>
<ProfileInfo user={userInfo} logOut={logOut} />
- <Feed polls={polls} />
+ <Feed polls={polls} navigate={navigate} />
</>
);
};