Skip to content

Commit

Permalink
logout added refined
Browse files Browse the repository at this point in the history
  • Loading branch information
vijay-varadarajan committed Jul 5, 2024
1 parent 79ee05e commit a43a5d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
28 changes: 19 additions & 9 deletions src/Components/Common/Navbar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import React from "react";
import "./style.css";
import { FaUser, FaBell, FaShoppingCart, FaHome } from "react-icons/fa";
import { FaUser, FaBell, FaShoppingCart, FaHome, FaSignOutAlt } from "react-icons/fa";
import { useNavigate } from 'react-router-dom';
import SecureLS from 'secure-ls';

const ls = new SecureLS({ encodingType: 'aes' });

const Navbar = () => {
const navigate = useNavigate();

const handleLogout = () => {
// Remove the auth token
ls.remove('authToken');
// Redirect to login page
navigate('/login');
};

return (
<nav className="navbar sticky-top navbar-light bg-light">
<a className="navbar-brand icon-margin" href="#">
Expand All @@ -14,20 +27,17 @@ const Navbar = () => {
<FaHome />
</a>
</li>
<li className="nav-item">
<a className="nav-link icon-margin" href="#">
<FaUser />
</a>
</li>

<li className="nav-item">
<a className="nav-link icon-margin" href="/cart">
<FaShoppingCart />
</a>
</li>

<li className="nav-item">
<a className="nav-link icon-margin" href="#">
<FaBell />
</a>
<button className="nav-link icon-margin" onClick={handleLogout} style={{ background: 'none', border: 'none', cursor: 'pointer' }}>
<FaSignOutAlt />
</button>
</li>
</ul>
</nav>
Expand Down
10 changes: 1 addition & 9 deletions src/Components/SideBar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@ const SidebarComponent = ({ children }) => {
<li>
<a href="#">My Orders</a>
</li>
<li>
<a href="#">Payments</a>
</li>
<li>
<a href="#">Transactions</a>
</li>
<li>
<a href="#">Settings</a>
</li>

</ul>
</div>
<div id="page-content-wrapper">{children}</div>
Expand Down

0 comments on commit a43a5d7

Please sign in to comment.