From d2ebf09e48428a71a6242d159cb765b3980d505b Mon Sep 17 00:00:00 2001 From: Dell Date: Thu, 26 May 2022 11:17:04 +0700 Subject: [PATCH] [WIP] Fix Logout Delete Token --- .../src/contexts/LaravelAuthContext.tsx | 1 - .../dashboard/header/AccountPopover.tsx | 3 +++ frontend/client-portal/src/routes/index.tsx | 20 +++++++++---------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/frontend/client-portal/src/contexts/LaravelAuthContext.tsx b/frontend/client-portal/src/contexts/LaravelAuthContext.tsx index 0a8304c0..8e789f19 100644 --- a/frontend/client-portal/src/contexts/LaravelAuthContext.tsx +++ b/frontend/client-portal/src/contexts/LaravelAuthContext.tsx @@ -165,7 +165,6 @@ function AuthProvider({ children }: AuthProviderProps) { }; const logout = async () => { - console.log('LOGGING OUT') setSession(null); dispatch({ type: Types.Logout }); }; diff --git a/frontend/client-portal/src/layouts/dashboard/header/AccountPopover.tsx b/frontend/client-portal/src/layouts/dashboard/header/AccountPopover.tsx index 501bab1a..fe68232e 100644 --- a/frontend/client-portal/src/layouts/dashboard/header/AccountPopover.tsx +++ b/frontend/client-portal/src/layouts/dashboard/header/AccountPopover.tsx @@ -6,6 +6,7 @@ import { Box, Divider, Typography, Stack, MenuItem, Avatar } from '@mui/material import MenuPopover from '../../../components/MenuPopover'; import { IconButtonAnimate } from '../../../components/animate'; import { useNavigate } from "react-router-dom"; +import useAuth from '../../../hooks/useAuth'; // ---------------------------------------------------------------------- @@ -29,6 +30,7 @@ const MENU_OPTIONS = [ export default function AccountPopover() { const [open, setOpen] = useState(null); const navigate = useNavigate(); + const { logout } = useAuth(); const handleOpen = (event: React.MouseEvent) => { setOpen(event.currentTarget); @@ -39,6 +41,7 @@ export default function AccountPopover() { }; const handleLogout = () => { + logout(); navigate('/auth/login'); } diff --git a/frontend/client-portal/src/routes/index.tsx b/frontend/client-portal/src/routes/index.tsx index 5f12ef58..951347eb 100644 --- a/frontend/client-portal/src/routes/index.tsx +++ b/frontend/client-portal/src/routes/index.tsx @@ -58,20 +58,20 @@ export default function Router() { // }, { path: '/', - element: , + element: , children:[ { path: 'dashboard', - element: , - }, - { - path: 'medicines', - element: , - }, - { - path: 'medicines/create', - element: + element: , }, + // { + // path: 'medicines', + // element: , + // }, + // { + // path: 'medicines/create', + // element: + // }, ] }, // {