import { useEffect, useRef, useState } from 'react'; // material-ui import { useTheme } from '@mui/material/styles'; import Avatar from '@mui/material/Avatar'; import Card from '@mui/material/Card'; import CardContent from '@mui/material/CardContent'; import Chip from '@mui/material/Chip'; import ClickAwayListener from '@mui/material/ClickAwayListener'; import Divider from '@mui/material/Divider'; import InputAdornment from '@mui/material/InputAdornment'; import List from '@mui/material/List'; import ListItemButton from '@mui/material/ListItemButton'; import ListItemIcon from '@mui/material/ListItemIcon'; import ListItemText from '@mui/material/ListItemText'; import OutlinedInput from '@mui/material/OutlinedInput'; import Paper from '@mui/material/Paper'; import Popper from '@mui/material/Popper'; import Stack from '@mui/material/Stack'; import Switch from '@mui/material/Switch'; import Typography from '@mui/material/Typography'; import Box from '@mui/material/Box'; // project imports import UpgradePlanCard from './UpgradePlanCard'; import MainCard from 'ui-component/cards/MainCard'; import Transitions from 'ui-component/extended/Transitions'; import useConfig from 'hooks/useConfig'; // assets import User1 from 'assets/images/users/user-round.svg'; import { IconLogout, IconSearch, IconSettings, IconUser } from '@tabler/icons-react'; // ==============================|| PROFILE MENU ||============================== // export default function ProfileSection() { const theme = useTheme(); const { state: { borderRadius } } = useConfig(); const [sdm, setSdm] = useState(true); const [value, setValue] = useState(''); const [notification, setNotification] = useState(false); const [open, setOpen] = useState(false); /** * anchorRef is used on different components and specifying one type leads to other components throwing an error * */ const anchorRef = useRef(null); const handleToggle = () => { setOpen((prevOpen) => !prevOpen); }; const handleClose = (event) => { if (anchorRef.current && anchorRef.current.contains(event.target)) { return; } setOpen(false); }; const prevOpen = useRef(open); useEffect(() => { if (prevOpen.current === true && open === false) { anchorRef.current.focus(); } prevOpen.current = open; }, [open]); return ( <> } label={} ref={anchorRef} aria-controls={open ? 'menu-list-grow' : undefined} aria-haspopup="true" onClick={handleToggle} color="primary" aria-label="user-account" /> {({ TransitionProps }) => ( {open && ( Good Morning, Johne Doe Project Admin setValue(e.target.value)} placeholder="Search profile options" startAdornment={ } aria-describedby="search-helper-text" slotProps={{ input: { 'aria-label': 'weight' } }} /> Start DND Mode setSdm(e.target.checked)} name="sdm" size="small" /> Allow Notifications setNotification(e.target.checked)} name="sdm" size="small" /> Account Settings} /> Social Profile } /> Logout} /> )} )} ); }