import React, { useState, useContext } from 'react' import { Link, useHistory, useLocation } from 'react-router-dom' import { AppBar, Toolbar, Tabs, Tab, Button, Menu, MenuItem } from '@mui/material' import OpenInNewIcon from '@mui/icons-material/OpenInNew' import Username from './username' import { AppContext } from '../context/appContext' const NODE_ENV = process.env.NODE_ENV const PORT_API = process.env.PORT_API const baseUrl = NODE_ENV === 'development' ? `http://localhost:${PORT_API ?? 5000}` : '' const Header = (props: any) => { const history = useHistory() const { pathname } = useLocation() const appContext = useContext(AppContext) const [tabValue, setTabValue] = useState(pathname) const [anchorEl, setAnchorEl] = useState< (EventTarget & HTMLButtonElement) | null >(null) const handleMenu = ( event: React.MouseEvent ) => { setAnchorEl(event.currentTarget) } const handleClose = () => { setAnchorEl(null) } const handleTabChange = (event: React.SyntheticEvent, value: string) => { setTabValue(value) } const handleLogout = () => { if (appContext.logout) appContext.logout() } return ( theme.zIndex.drawer + 1 }} > logo { setTabValue('/') history.push('/') }} />
) } export default Header