From 8e05280b7dba5698030b7bdb16f29bb137c7c92d Mon Sep 17 00:00:00 2001 From: R Date: Sat, 4 Feb 2023 08:36:59 +0700 Subject: [PATCH] Fix Name & User Avatar --- .../dashboard/header/AccountPopover.tsx | 18 +++++++++--------- .../dashboard/navbar/NavbarAccount.tsx | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/frontend/client-portal/src/layouts/dashboard/header/AccountPopover.tsx b/frontend/client-portal/src/layouts/dashboard/header/AccountPopover.tsx index 64bb2e33..728b85ce 100755 --- a/frontend/client-portal/src/layouts/dashboard/header/AccountPopover.tsx +++ b/frontend/client-portal/src/layouts/dashboard/header/AccountPopover.tsx @@ -32,7 +32,7 @@ const MENU_OPTIONS = [ export default function AccountPopover() { const [open, setOpen] = useState(null); const navigate = useNavigate(); - const { logout } = useAuth(); + const { logout, user } = useAuth(); const handleOpen = (event: React.MouseEvent) => { setOpen(event.currentTarget); @@ -67,10 +67,10 @@ export default function AccountPopover() { }), }} > - + {user && user.user.avatar_url && ()} - Rayan Moran + { user ? user.user.full_name ?? 'Hi, ' : 'Hi, '} - rayan.moran@gmail.com + { user ? user.user.email : 'Please Wait'} - + {/* {MENU_OPTIONS.map((option) => ( {option.label} @@ -106,7 +106,7 @@ export default function AccountPopover() { ))} - + */} Logout diff --git a/frontend/client-portal/src/layouts/dashboard/navbar/NavbarAccount.tsx b/frontend/client-portal/src/layouts/dashboard/navbar/NavbarAccount.tsx index 8e72ad90..91671ffa 100755 --- a/frontend/client-portal/src/layouts/dashboard/navbar/NavbarAccount.tsx +++ b/frontend/client-portal/src/layouts/dashboard/navbar/NavbarAccount.tsx @@ -1,6 +1,7 @@ // @mui import { styled } from '@mui/material/styles'; import { Box, Link, Typography, Avatar } from '@mui/material'; +import useAuth from '../../../hooks/useAuth'; // ---------------------------------------------------------------------- @@ -22,6 +23,10 @@ type Props = { }; export default function NavbarAccount({ isCollapse }: Props) { + + const { user } = useAuth(); + + console.log('current user is ', user) return ( - + {user && user.user.avatar_url && ()} - Rayan Moran + { user ? user.user.full_name ?? 'Hi, ' : 'Hi, '} - - user + + { user ? user.user.email : 'Please Wait'}