import {useState, useEffect} from 'react'; import {useTheme} from '@mui/material/styles'; import {useRouter} from 'next/router'; import Toolbar from '@mui/material/Toolbar'; import Typography from '@mui/material/Typography'; import IconButton from '@mui/material/IconButton'; import Box from '@mui/material/Box'; import Avatar from '@mui/material/Avatar'; import Icon from '@mui/material/Icon'; import AppBar from '@mui/material/AppBar'; import useProfile from '../../hooks/useProfile'; import GenericMenu from '../GenericMenu'; import {ActionType} from '../GenericMenu/Action'; import {useSession} from 'next-auth/react'; import DrawerNotification from '../DrawerNotification'; const GenericToolbar = ({ title, actions = [], goBack = false, }: { title: string; actions: Array; goBack?: boolean; }) => { const router = useRouter(); const theme = useTheme(); const [anchorEl, setAnchorEl] = useState(null); const {profile, connected} = useProfile(); const session = useSession(); const isAuthenticated = session.status === 'authenticated'; useEffect(() => { window.scrollTo(0, 0); }, []); return ( {goBack && ( router.back()} size="large" > chevron_left )} {title} {isAuthenticated && } {actions.length > 0 && ( <> setAnchorEl(e.currentTarget)} size="large" > {connected && profile ? ( {`${profile.username[0]}`.toUpperCase()} ) : ( more_vert )} )} ); }; export default GenericToolbar;