import * as React from 'react'; import { useNavigate } from 'react-router-dom'; import PropTypes from 'prop-types'; import MenuItem from '@mui/material/MenuItem'; import Menu from '@mui/material/Menu'; import { Link } from 'react-router-dom'; import Can from 'components/Can'; import apolloClient from 'graphql/client'; import * as URLS from 'config/urls'; import useAuthentication from 'hooks/useAuthentication'; import useFormatMessage from 'hooks/useFormatMessage'; import useRevokeAccessToken from 'hooks/useRevokeAccessToken'; function AccountDropdownMenu(props) { const formatMessage = useFormatMessage(); const authentication = useAuthentication(); const token = authentication.token; const navigate = useNavigate(); const revokeAccessTokenMutation = useRevokeAccessToken(token); const { open, onClose, anchorEl, id } = props; const logout = async () => { await revokeAccessTokenMutation.mutateAsync(); authentication.removeToken(); await apolloClient.clearStore(); onClose(); navigate(URLS.LOGIN); }; return (
); } AccountDropdownMenu.propTypes = { open: PropTypes.bool.isRequired, onClose: PropTypes.func.isRequired, anchorEl: PropTypes.oneOfType([PropTypes.element, PropTypes.func]), id: PropTypes.string.isRequired, }; export default AccountDropdownMenu;