Skip to content

Commit

Permalink
created new Navbar component with Logout in it, so far the logout but…
Browse files Browse the repository at this point in the history
…ton is showing but not doing anything
  • Loading branch information
sharmine-s committed Jun 9, 2023
1 parent 5aaf8b6 commit 1cce5a6
Show file tree
Hide file tree
Showing 5 changed files with 615 additions and 8 deletions.
10 changes: 2 additions & 8 deletions frontend/src/components/feed/Feed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react';
import Post from '../post/Post';
import PostCreateForm from '../post/PostCreateForm';
import Navbar from '../navbar/Navbar';

const Feed = ({ navigate }) => {
const [posts, setPosts] = useState([]);
Expand All @@ -24,19 +25,12 @@ const Feed = ({ navigate }) => {
}
}, [])


const logout = () => {
window.localStorage.removeItem("token")
navigate('/login')
}

if(token) {
return(
<>
<Navbar />
<h2>Posts</h2>
<button onClick={logout}>
Logout
</button>
<PostCreateForm />
<div id='feed' role="feed">
{posts.map(
Expand Down
Empty file.
21 changes: 21 additions & 0 deletions frontend/src/components/navbar/Navbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';

const Navbar = ({ navigate }) => {

const logout = () => {
// window.localStorage.removeItem("token")
// navigate('/login')
}


return(
<>
<button onClick={logout}>
Logout
</button>
</>
)

}

export default Navbar;
Loading

0 comments on commit 1cce5a6

Please sign in to comment.