aboutsummaryrefslogtreecommitdiff
path: root/src/ProfileInfo
diff options
context:
space:
mode:
authorilyayudovin <ilyayudovin123@gmail.com>2020-06-14 01:31:05 +0300
committerilyayudovin <ilyayudovin123@gmail.com>2020-06-14 01:31:05 +0300
commit3969face39ecc933b1cb9c7625be921d148552cb (patch)
tree6c1ebc773767bf0637ae6b568997033479d0e597 /src/ProfileInfo
parent57a2ff3cfa7eae111bb8f46447198586c47425fb (diff)
downloadwhich-ui-3969face39ecc933b1cb9c7625be921d148552cb.tar.gz
feat: add sing in form
Diffstat (limited to 'src/ProfileInfo')
-rw-r--r--src/ProfileInfo/ProfileInfo.tsx10
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>
);
};