logout function added
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
import React from 'react'
|
||||
import { Link, useLocation } from 'react-router-dom'
|
||||
import { Link, useLocation, useNavigate } from 'react-router-dom'
|
||||
import siteLinks from '../../../links/siteLinks'
|
||||
import { IoIosArrowDown } from 'react-icons/io'
|
||||
export default function UserMenu() {
|
||||
|
||||
const {pathname} = useLocation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const logout = () => {
|
||||
localStorage.clear()
|
||||
navigate('/login', {replace: true})
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="sidebar-nav scrollbar scroll_dark">
|
||||
@@ -48,7 +55,7 @@ export default function UserMenu() {
|
||||
|
||||
<li className="sidebar-banner p-4 bg-gradient text-center m-3 d-block rounded">
|
||||
<h5 className="text-white mb-1">MERMS Panel</h5>
|
||||
<Link className="btn btn-square btn-inverse-light btn-xs d-inline-block mt-2 mb-0" to={siteLinks.login}> Log Out</Link>
|
||||
<Link className="btn btn-square btn-inverse-light btn-xs d-inline-block mt-2 mb-0" to='' onClick={logout}> Log Out</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user