diff options
Diffstat (limited to 'src/ProfileInfo/ProfileInfo.tsx')
-rw-r--r-- | src/ProfileInfo/ProfileInfo.tsx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/ProfileInfo/ProfileInfo.tsx b/src/ProfileInfo/ProfileInfo.tsx index a7289df..693f550 100644 --- a/src/ProfileInfo/ProfileInfo.tsx +++ b/src/ProfileInfo/ProfileInfo.tsx @@ -1,11 +1,13 @@ 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'; interface PropTypes { id: string; + setUser: (newUser: User | undefined) => void; } const useStyles = makeStyles({ @@ -34,7 +36,7 @@ const useStyles = makeStyles({ } }); -const ProfileInfo: React.FC<PropTypes> = ({ id }) => { +const ProfileInfo: React.FC<PropTypes> = ({ id, setUser }) => { const [userInfo, setUserInfo] = useState<User>(); get(`/users/${id}`).then(response => { @@ -43,6 +45,11 @@ const ProfileInfo: React.FC<PropTypes> = ({ id }) => { const classes = useStyles(); + const LogOut = () => { + localStorage.clear(); + setUser(undefined); + }; + return ( <div> <Avatar className={classes.avatar} src={userInfo?.avatarUrl} /> @@ -60,6 +67,7 @@ const ProfileInfo: React.FC<PropTypes> = ({ id }) => { Following </div> </div> + <Button variant="contained" onClick={LogOut}>Log Out</Button> </div> ); }; |