[WIP] Fix Logout Delete Token
This commit is contained in:
@@ -165,7 +165,6 @@ function AuthProvider({ children }: AuthProviderProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const logout = async () => {
|
const logout = async () => {
|
||||||
console.log('LOGGING OUT')
|
|
||||||
setSession(null);
|
setSession(null);
|
||||||
dispatch({ type: Types.Logout });
|
dispatch({ type: Types.Logout });
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { Box, Divider, Typography, Stack, MenuItem, Avatar } from '@mui/material
|
|||||||
import MenuPopover from '../../../components/MenuPopover';
|
import MenuPopover from '../../../components/MenuPopover';
|
||||||
import { IconButtonAnimate } from '../../../components/animate';
|
import { IconButtonAnimate } from '../../../components/animate';
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import useAuth from '../../../hooks/useAuth';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ const MENU_OPTIONS = [
|
|||||||
export default function AccountPopover() {
|
export default function AccountPopover() {
|
||||||
const [open, setOpen] = useState<HTMLElement | null>(null);
|
const [open, setOpen] = useState<HTMLElement | null>(null);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { logout } = useAuth();
|
||||||
|
|
||||||
const handleOpen = (event: React.MouseEvent<HTMLElement>) => {
|
const handleOpen = (event: React.MouseEvent<HTMLElement>) => {
|
||||||
setOpen(event.currentTarget);
|
setOpen(event.currentTarget);
|
||||||
@@ -39,6 +41,7 @@ export default function AccountPopover() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
|
logout();
|
||||||
navigate('/auth/login');
|
navigate('/auth/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,20 +58,20 @@ export default function Router() {
|
|||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
element: <DashboardLayout />,
|
element: <AuthProvider><DashboardLayout /></AuthProvider>,
|
||||||
children:[
|
children:[
|
||||||
{
|
{
|
||||||
path: 'dashboard',
|
path: 'dashboard',
|
||||||
element: <AuthProvider><Dashboard /></AuthProvider>,
|
element: <Dashboard />,
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'medicines',
|
|
||||||
element: <AuthProvider><Medicines /></AuthProvider>,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'medicines/create',
|
|
||||||
element: <AuthProvider><MedicinesCreate /></AuthProvider>
|
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// path: 'medicines',
|
||||||
|
// element: <AuthProvider><Medicines /></AuthProvider>,
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// path: 'medicines/create',
|
||||||
|
// element: <AuthProvider><MedicinesCreate /></AuthProvider>
|
||||||
|
// },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
|
|||||||
Reference in New Issue
Block a user