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 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'; const GenericToolbar = ({ title, actions = [], goBack = null, }: { title: string; actions: Array; goBack: () => void | null; }) => { const router = useRouter(); const theme = useTheme(); const [anchorEl, setAnchorEl] = useState(null); const {profile, connected} = useProfile(); useEffect(() => { window.scrollTo(0, 0); }, []); return ( {goBack && ( router.basePath.split('/').length > 2 ? router.back() : router.push('/dashboard') } size="large" > arrow_back )}
{title}
{actions.length > 0 && ( <> setAnchorEl(e.currentTarget)} size="large" > {connected && profile ? ( {`${profile.username[0]}`.toUpperCase()} ) : ( more_vert )} )}
); }; export default GenericToolbar;