diff --git a/web/src/components/header.tsx b/web/src/components/header.tsx index 3c514d8..f0654cc 100644 --- a/web/src/components/header.tsx +++ b/web/src/components/header.tsx @@ -1,13 +1,20 @@ -import React, { useState } from 'react' +import React, { useState, useContext } from 'react' import { Link, useHistory, useLocation } from 'react-router-dom' -import AppBar from '@mui/material/AppBar' -import Toolbar from '@mui/material/Toolbar' -import Tabs from '@mui/material/Tabs' -import Tab from '@mui/material/Tab' -import Button from '@mui/material/Button' +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 = @@ -16,11 +23,29 @@ const baseUrl = 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 ( { > App Stream +
+ + + + + + +
) diff --git a/web/src/components/userName.tsx b/web/src/components/userName.tsx new file mode 100644 index 0000000..10093fe --- /dev/null +++ b/web/src/components/userName.tsx @@ -0,0 +1,30 @@ +import React from 'react' +import { Typography, IconButton } from '@mui/material' +import AccountCircle from '@mui/icons-material/AccountCircle' + +const UserName = (props: any) => { + return ( + + {props.avatarContent ? ( + user-avatar + ) : ( + + )} + + {props.userName} + + + ) +} + +export default UserName