Skip to content

Commit

Permalink
feat: logout
Browse files Browse the repository at this point in the history
  • Loading branch information
yp969803 committed Feb 14, 2024
1 parent 9e006cd commit f756b4d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/features/workspace-view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { UserOrgDetails, getUserOrgs } from 'app/api/user';
import loader from '../../app/assets/gifs/loader.gif';
import { Navigate, useNavigate } from 'react-router-dom';
import { useSelector } from 'react-redux';
import toast from 'react-hot-toast';

const WorkspaceView = () => {
const userContext = useContext(UserContext);
Expand Down Expand Up @@ -41,15 +42,28 @@ const WorkspaceView = () => {
searchValue,
]);

const LogoutHandler= async()=>{
try{
localStorage.removeItem('token')
toast.success('Logout successful!');
navigate("/login")
}catch(e){

}
}
return (
<div className='workspaceview-container'>
<div className='workspaceview-header'>
<SearchBar />

<button onClick={() => setArcheives(!archeives)} style={archeives?{background: '#141432'}:{}}>Archeives</button>

<button onClick={() => navigate('/addWorkspace')}>
Create a workspace
</button>
<button onClick={LogoutHandler}>
Logout
</button>
</div>

<div className='workspaceview-card-container'>
Expand Down

0 comments on commit f756b4d

Please sign in to comment.