import React from 'react'; import { AppBar as MuiAppBar, Box, Tab as MuiTab, Tabs, IconButton, Typography, Menu, MenuItem } from '@material-ui/core'; import CloseIcon from '@material-ui/icons/Close'; import SearchIcon from '@material-ui/icons/Search'; import LocalOfferIcon from '@material-ui/icons/LocalOffer'; import { Link, useHistory } from 'react-router-dom'; import { WindowType } from '../windows/Windows'; import { useAuth } from '../../lib/useAuth'; export enum AppBarTab { Query = 0, Tags, } export const appBarTabProps: Record = { [AppBarTab.Query]: { label: Query, path: "/query", }, [AppBarTab.Tags]: { label: Tags, path: "/tags", }, } export function UserMenu(props: { position: null | number[], open: boolean, onLogout: () => void, onClose: () => void, }) { let auth = useAuth(); const pos = props.open && props.position ? { left: props.position[0], top: props.position[1] } : { left: 0, top: 0 } return {auth.user?.email || "Unknown user"} { props.onClose(); props.onLogout(); }} >Sign out } export default function AppBar(props: { selectedTab: AppBarTab | null }) { let history = useHistory(); let auth = useAuth(); const [userMenuPos, setUserMenuPos] = React.useState(null); const onOpenUserMenu = (e: any) => { setUserMenuPos([e.clientX, e.clientY]) }; const onCloseUserMenu = () => { setUserMenuPos(null); }; return <> error {auth.user && history.push(appBarTabProps[val].path)} variant="scrollable" scrollButtons="auto" > {Object.keys(appBarTabProps).map((tab: any, idx: number) => )} } {auth.user && { onOpenUserMenu(e) }} >{auth.user.icon}} }