diff options
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/FeedPage/FeedPage.tsx | 2 | ||||
-rw-r--r-- | src/pages/HomePage/HomePage.tsx | 4 | ||||
-rw-r--r-- | src/pages/Page.tsx | 12 | ||||
-rw-r--r-- | src/pages/ProfilePage/ProfileInfo.tsx | 7 | ||||
-rw-r--r-- | src/pages/ProfilePage/ProfilePage.tsx | 6 |
5 files changed, 16 insertions, 15 deletions
diff --git a/src/pages/FeedPage/FeedPage.tsx b/src/pages/FeedPage/FeedPage.tsx index 8e7fb55..da0fb2a 100644 --- a/src/pages/FeedPage/FeedPage.tsx +++ b/src/pages/FeedPage/FeedPage.tsx @@ -17,7 +17,7 @@ const FeedPage: React.FC = () => { return ( <Container maxWidth="sm" disableGutters> - {isAuthenticated() && <PollSubmission addPoll={addPoll} />} + {isAuthenticated && <PollSubmission addPoll={addPoll} />} <Feed polls={data} /> </Container> ); diff --git a/src/pages/HomePage/HomePage.tsx b/src/pages/HomePage/HomePage.tsx index 17e377a..b1dc506 100644 --- a/src/pages/HomePage/HomePage.tsx +++ b/src/pages/HomePage/HomePage.tsx @@ -92,7 +92,7 @@ const HomePage: React.FC = () => { Here you can share your thougts about Which with us! Note that you can ony leave feedback once per application version (there will be plenty of them later). </p> - {isAuthenticated() ? <ReviewForm /> : ( + {isAuthenticated ? <ReviewForm /> : ( <> <p> You must be authorized to leave feedback.</p> <Button @@ -142,7 +142,7 @@ const HomePage: React.FC = () => { <Button variant="contained" color="primary" size="large" onClick={handleLetsGo}> {'let\'s go!'} </Button> - {!isAuthenticated() && ( + {!isAuthenticated && ( <Button variant="outlined" color="primary" diff --git a/src/pages/Page.tsx b/src/pages/Page.tsx index 49c941a..a77a98e 100644 --- a/src/pages/Page.tsx +++ b/src/pages/Page.tsx @@ -5,12 +5,12 @@ import { SnackbarProvider } from 'notistack'; import { Switch, Route } from 'react-router-dom'; import Loading from '../components/Loading/Loading'; -const ProfilePage = React.lazy(() => import( './ProfilePage/ProfilePage')); -const FeedPage = React.lazy(() => import( './FeedPage/FeedPage')); -const LoginPage = React.lazy(() => import( './LoginPage/LoginPage')); -const RegistrationPage = React.lazy(() => import( './RegistrationPage/RegistrationPage')); -const HomePage = React.lazy(() => import( './HomePage/HomePage')); -const NotificationsPage = React.lazy(() => import( './NotificationsPage/NotificationsPage')); +const ProfilePage = React.lazy(() => import('./ProfilePage/ProfilePage')); +const FeedPage = React.lazy(() => import('./FeedPage/FeedPage')); +const LoginPage = React.lazy(() => import('./LoginPage/LoginPage')); +const RegistrationPage = React.lazy(() => import('./RegistrationPage/RegistrationPage')); +const HomePage = React.lazy(() => import('./HomePage/HomePage')); +const NotificationsPage = React.lazy(() => import('./NotificationsPage/NotificationsPage')); const useStyles = makeStyles(theme => ({ diff --git a/src/pages/ProfilePage/ProfileInfo.tsx b/src/pages/ProfilePage/ProfileInfo.tsx index 8b1447a..9eee4c1 100644 --- a/src/pages/ProfilePage/ProfileInfo.tsx +++ b/src/pages/ProfilePage/ProfileInfo.tsx @@ -86,7 +86,7 @@ const ProfileInfo: React.FC<PropTypes> = ({ }) => { const classes = useStyles(); const [input, setInput] = useState(false); - const { setUser } = useAuth(); + const { user } = useAuth(); const dateSince = new Date(userInfo?.createdAt || '').toLocaleDateString(); const handleClick = () => { @@ -94,10 +94,9 @@ const ProfileInfo: React.FC<PropTypes> = ({ }; const patchAvatar = (url: string) => { - const id = localStorage.getItem('userId'); + const id = user?._id; patch(`/users/${id}`, { avatarUrl: url }).then(res => { setUserInfo(res.data); - setUser(res.data); }); }; @@ -106,7 +105,7 @@ const ProfileInfo: React.FC<PropTypes> = ({ { !userInfo ? <Skeleton animation="wave" variant="circle" width={150} height={150} className={classes.avatar} /> - : userInfo?._id === localStorage.getItem('userId') + : userInfo?._id === user?._id ? ( <div> <MoreMenu /> diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx index 293b766..9e00784 100644 --- a/src/pages/ProfilePage/ProfilePage.tsx +++ b/src/pages/ProfilePage/ProfilePage.tsx @@ -21,7 +21,7 @@ const ProfilePage: React.FC = () => { if (!username) { if (user) history.push(`/profile/${user.username}`); else history.push('/login'); - }; + } }, [username, history, user]); @@ -31,7 +31,9 @@ const ProfilePage: React.FC = () => { const { left, right } = current.contents; return total + left.votes + right.votes; }, 0 - ), [polls]); + ), + [polls] + ); return ( <Container maxWidth="sm" disableGutters> |