import { m } from 'framer-motion';
// @mui
import { alpha } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Stack from '@mui/material/Stack';
import Avatar from '@mui/material/Avatar';
import Divider from '@mui/material/Divider';
import MenuItem from '@mui/material/MenuItem';
import IconButton from '@mui/material/IconButton';
import Typography from '@mui/material/Typography';
// routes
import { useRouter } from 'src/routes/hooks';
// auth
import { useAuthContext } from 'src/auth/hooks';
// components
import { varHover } from 'src/components/animate';
import CustomPopover, { usePopover } from 'src/components/custom-popover';
// ----------------------------------------------------------------------
const OPTIONS = [
{
label: 'Home',
linkTo: '/',
},
{
label: 'Profile',
linkTo: '/#1',
},
{
label: 'Settings',
linkTo: '/#2',
},
];
// ----------------------------------------------------------------------
export default function AccountPopover() {
const router = useRouter();
const { logout, user } = useAuthContext();
const popover = usePopover();
const handleLogout = async () => {
try {
await logout();
popover.onClose();
router.replace('/');
} catch (error) {
console.error(error);
}
};
const handleClickItem = (path: string) => {
popover.onClose();
router.push(path);
};
return (
<>
alpha(theme.palette.grey[500], 0.08),
...(popover.open && {
background: (theme) =>
`linear-gradient(135deg, ${theme.palette.primary.light} 0%, ${theme.palette.primary.main} 100%)`,
}),
}}
>
`solid 2px ${theme.palette.background.default}`,
}}
>
{user?.displayName.charAt(0).toUpperCase()}
{user?.displayName}
{user?.email}
{OPTIONS.map((option) => (
))}
>
);
}