import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import { createSubscribedElement } from '../../UnstatedUtils'; import AppContainer from '../../../services/AppContainer'; import { toastSuccess, toastError } from '../../../util/apiNotification'; import AdminUsersContainer from '../../../services/AdminUsersContainer'; class RemoveAdminButton extends React.Component { constructor(props) { super(props); this.onClickRemoveAdminBtn = this.onClickRemoveAdminBtn.bind(this); } async onClickRemoveAdminBtn() { const { t } = this.props; try { const username = await this.props.adminUsersContainer.removeUserAdmin(this.props.user._id); toastSuccess(t('toaster.remove_user_admin', { username })); } catch (err) { toastError(err); } } renderRemoveAdminBtn() { const { t } = this.props; return ( { this.onClickRemoveAdminBtn() }}> {t('admin:user_management.user_table.remove_admin_access')} ); } renderRemoveAdminAlert() { const { t } = this.props; return (
{t('admin:user_management.user_table.cannot_remove')}