diff options
author | ilyayudovin <46264063+ilyayudovin@users.noreply.github.com> | 2020-06-14 15:58:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-14 15:58:02 +0300 |
commit | 99b44bc80fa3228131a05fccb13f75ff8a46b116 (patch) | |
tree | a77bcec54244156844e245494f1ce434a12fff34 /src/ProfileInfo | |
parent | 57a2ff3cfa7eae111bb8f46447198586c47425fb (diff) | |
parent | 0308460d896966a9fe5e510926f44bac112923bb (diff) | |
download | which-ui-99b44bc80fa3228131a05fccb13f75ff8a46b116.tar.gz |
Merge pull request #31 from ilyayudovin/signIn
add sing in form
Diffstat (limited to 'src/ProfileInfo')
-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> ); }; |