Fix Name & User Avatar
This commit is contained in:
@@ -32,7 +32,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 { logout, user } = useAuth();
|
||||||
|
|
||||||
const handleOpen = (event: React.MouseEvent<HTMLElement>) => {
|
const handleOpen = (event: React.MouseEvent<HTMLElement>) => {
|
||||||
setOpen(event.currentTarget);
|
setOpen(event.currentTarget);
|
||||||
@@ -67,10 +67,10 @@ export default function AccountPopover() {
|
|||||||
}),
|
}),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Avatar
|
{user && user.user.avatar_url && (<Avatar
|
||||||
src="https://minimal-assets-api.vercel.app/assets/images/avatars/avatar_5.jpg"
|
src={user ? user.user.avatar_url : ''}
|
||||||
alt="Rayan Moran"
|
alt={user ? user.user.full_name : ''}
|
||||||
/>
|
/>)}
|
||||||
</IconButtonAnimate>
|
</IconButtonAnimate>
|
||||||
|
|
||||||
<MenuPopover
|
<MenuPopover
|
||||||
@@ -89,16 +89,16 @@ export default function AccountPopover() {
|
|||||||
>
|
>
|
||||||
<Box sx={{ my: 1.5, px: 2.5 }}>
|
<Box sx={{ my: 1.5, px: 2.5 }}>
|
||||||
<Typography variant="subtitle2" noWrap>
|
<Typography variant="subtitle2" noWrap>
|
||||||
Rayan Moran
|
{ user ? user.user.full_name ?? 'Hi, ' : 'Hi, '}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body2" sx={{ color: 'text.secondary' }} noWrap>
|
<Typography variant="body2" sx={{ color: 'text.secondary' }} noWrap>
|
||||||
rayan.moran@gmail.com
|
{ user ? user.user.email : 'Please Wait'}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Divider sx={{ borderStyle: 'dashed' }} />
|
<Divider sx={{ borderStyle: 'dashed' }} />
|
||||||
|
|
||||||
<Stack sx={{ p: 1 }}>
|
{/* <Stack sx={{ p: 1 }}>
|
||||||
{MENU_OPTIONS.map((option) => (
|
{MENU_OPTIONS.map((option) => (
|
||||||
<MenuItem key={option.label} onClick={handleClose}>
|
<MenuItem key={option.label} onClick={handleClose}>
|
||||||
{option.label}
|
{option.label}
|
||||||
@@ -106,7 +106,7 @@ export default function AccountPopover() {
|
|||||||
))}
|
))}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Divider sx={{ borderStyle: 'dashed' }} />
|
<Divider sx={{ borderStyle: 'dashed' }} /> */}
|
||||||
|
|
||||||
<MenuItem sx={{ m: 1 }} onClick={handleLogout}>
|
<MenuItem sx={{ m: 1 }} onClick={handleLogout}>
|
||||||
Logout
|
Logout
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// @mui
|
// @mui
|
||||||
import { styled } from '@mui/material/styles';
|
import { styled } from '@mui/material/styles';
|
||||||
import { Box, Link, Typography, Avatar } from '@mui/material';
|
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) {
|
export default function NavbarAccount({ isCollapse }: Props) {
|
||||||
|
|
||||||
|
const { user } = useAuth();
|
||||||
|
|
||||||
|
console.log('current user is ', user)
|
||||||
return (
|
return (
|
||||||
<Link underline="none" color="inherit">
|
<Link underline="none" color="inherit">
|
||||||
<RootStyle
|
<RootStyle
|
||||||
@@ -31,10 +36,10 @@ export default function NavbarAccount({ isCollapse }: Props) {
|
|||||||
}),
|
}),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Avatar
|
{user && user.user.avatar_url && (<Avatar
|
||||||
src="https://minimal-assets-api.vercel.app/assets/images/avatars/avatar_5.jpg"
|
src={user ? user.user.avatar_url : ''}
|
||||||
alt="Rayan Moran"
|
alt={user ? user.user.full_name : ''}
|
||||||
/>
|
/>)}
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@@ -50,10 +55,10 @@ export default function NavbarAccount({ isCollapse }: Props) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography variant="subtitle2" noWrap>
|
<Typography variant="subtitle2" noWrap>
|
||||||
Rayan Moran
|
{ user ? user.user.full_name ?? 'Hi, ' : 'Hi, '}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body2" noWrap sx={{ color: 'text.secondary' }}>
|
<Typography variant="body2" noWrap sx={{ color: 'text.secondary', fontSize: '11px' }}>
|
||||||
user
|
{ user ? user.user.email : 'Please Wait'}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</RootStyle>
|
</RootStyle>
|
||||||
|
|||||||
Reference in New Issue
Block a user