diff options
Diffstat (limited to 'src/pages/ProfilePage')
-rw-r--r-- | src/pages/ProfilePage/ProfileInfo.tsx | 7 | ||||
-rw-r--r-- | src/pages/ProfilePage/ProfilePage.tsx | 6 |
2 files changed, 7 insertions, 6 deletions
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> |