import { useReactiveVar } from '@apollo/client'; import { useHistory } from 'react-router'; import { roleVar, tokenVar, userVar } from '../../graphql/state'; import { Wrapper } from './styles'; import { Avatar, Link, Menu, Text } from '..'; import { Settings, Logout, Logo } from '../../assets'; type NavbarProps = { withSidebar: boolean; }; const Navbar = ({ withSidebar }: NavbarProps) => { const user = useReactiveVar(userVar); const role = useReactiveVar(roleVar); const history = useHistory(); return (
{user?.firstName} {user?.lastName}
, label: 'Settings', action: () => {} }, { icon: , label: 'Logout', action: () => { tokenVar(undefined); history.push('/login'); }, avoid: true, }, ] : [ { icon: , label: 'Logout', action: () => { tokenVar(undefined); history.push('/login'); }, avoid: true, }, ] } /> ); }; export default Navbar;