import React from 'react'; import { withRouter } from 'react-router-dom'; import { client, CLIENT_DEFAULT_TAB } from 'App/routes'; import { Icon } from 'UI'; import { getInitials } from 'App/utils'; import { useStore } from 'App/mstore'; import { observer } from 'mobx-react-lite'; import { useTranslation } from 'react-i18next'; const CLIENT_PATH = client(CLIENT_DEFAULT_TAB); interface Props { history: any; } function UserMenu(props: Props) { const { t } = useTranslation(); const { history }: any = props; const { loginStore, userStore } = useStore(); const { account } = userStore; const onLogoutClick = userStore.logout; const onAccountClick = () => { history.push(CLIENT_PATH); }; const onLogout = () => { loginStore.invalidateSpotJWT(); window.postMessage( { type: 'orspot:invalidate', }, '*', ); void onLogoutClick(); }; return (
{getInitials(account.name)}
{account.name}
{account.email}
{account.superAdmin ? 'Owner' : account.admin ? 'Admin' : 'Member'}
); } export default withRouter(observer(UserMenu));