From 3969face39ecc933b1cb9c7625be921d148552cb Mon Sep 17 00:00:00 2001
From: ilyayudovin <ilyayudovin123@gmail.com>
Date: Sun, 14 Jun 2020 01:31:05 +0300
Subject: feat: add sing in form

---
 src/ProfileInfo/ProfileInfo.tsx | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'src/ProfileInfo/ProfileInfo.tsx')

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>
   );
 };
-- 
cgit v1.2.3

