import React, { ChangeEventHandler } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { unverifyUser, verifyUser } from 'soapbox/actions/admin'; import snackbar from 'soapbox/actions/snackbar'; import Account from 'soapbox/components/account'; import List, { ListItem } from 'soapbox/components/list'; import MissingIndicator from 'soapbox/components/missing_indicator'; import { Button, HStack, Modal, Stack, Toggle } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks'; import { makeGetAccount } from 'soapbox/selectors'; import { isLocal } from 'soapbox/utils/accounts'; import StaffRolePicker from './staff-role-picker'; const getAccount = makeGetAccount(); const messages = defineMessages({ userVerified: { id: 'admin.users.user_verified_message', defaultMessage: '@{acct} was verified' }, userUnverified: { id: 'admin.users.user_unverified_message', defaultMessage: '@{acct} was unverified' }, }); interface IAccountModerationModal { /** Action to close the modal. */ onClose: (type: string) => void, /** ID of the account to moderate. */ accountId: string, } /** Moderator actions against accounts. */ const AccountModerationModal: React.FC = ({ onClose, accountId }) => { const intl = useIntl(); const dispatch = useAppDispatch(); const features = useFeatures(); const account = useAppSelector(state => getAccount(state, accountId)); const handleClose = () => onClose('ACCOUNT_MODERATION'); if (!account) { return ( ); } const handleAdminFE = () => { window.open(`/pleroma/admin/#/users/${account.id}/`, '_blank'); }; const handleVerifiedChange: ChangeEventHandler = (e) => { const { checked } = e.target; const message = checked ? messages.userVerified : messages.userUnverified; const action = checked ? verifyUser : unverifyUser; dispatch(action(account.id)) .then(() => dispatch(snackbar.success(intl.formatMessage(message, { acct: account.acct })))) .catch(() => {}); }; return ( } onClose={handleClose} >
{isLocal(account) && ( }>
)} }>
{features.adminFE && ( )}
); }; export default AccountModerationModal;