Skip to content

Commit c34e6f0

Browse files
committed
Add logout functionality and add back navigate functionality for createQuestion
1 parent d914446 commit c34e6f0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Frontend/src/components/NavigationBar.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
import Container from 'react-bootstrap/Container';
22
import Navbar from 'react-bootstrap/Navbar';
3+
import Button from 'react-bootstrap/esm/Button';
4+
import { useNavigate } from 'react-router-dom';
35

46
function NavigationBar() {
7+
const navigate = useNavigate();
8+
9+
// Add log out functionality
10+
const handleLogout = () => {
11+
navigate("/login");
12+
}
13+
514
return (
615
<Navbar className='bg-light' sticky="top">
716
<Container>
817
<Navbar.Brand>PeerPrep</Navbar.Brand>
18+
<Button className="ms-auto" variant="danger" onClick={handleLogout}>
19+
Logout
20+
</Button>
921
</Container>
1022
</Navbar>
1123
);

Frontend/src/components/question/CreateQn.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function CreateQn({handleClose, addQuestion}) {
2121
console.log(result.data)
2222
addQuestion(result.data)
2323
handleClose()
24+
navigate("/home")
2425
}
2526
)
2627
.catch(e => {

0 commit comments

Comments
 (0)