import React, { useCallback, useEffect } from 'react'; import { FormattedMessage, defineMessages, useIntl } from 'react-intl'; import { fetchGroupBlocks, groupUnblock } from 'soapbox/actions/groups'; import { useGroup } from 'soapbox/api/hooks'; import Account from 'soapbox/components/account'; import ScrollableList from 'soapbox/components/scrollable-list'; import { Button, Column, HStack, Spinner } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import { makeGetAccount } from 'soapbox/selectors'; import toast from 'soapbox/toast'; import ColumnForbidden from '../ui/components/column-forbidden'; type RouteParams = { groupId: string }; const messages = defineMessages({ heading: { id: 'column.group_blocked_members', defaultMessage: 'Banned Members' }, unblock: { id: 'group.group_mod_unblock', defaultMessage: 'Unban' }, unblocked: { id: 'group.group_mod_unblock.success', defaultMessage: 'Unbanned @{name} from group' }, }); interface IBlockedMember { accountId: string groupId: string } const BlockedMember: React.FC = ({ accountId, groupId }) => { const intl = useIntl(); const dispatch = useAppDispatch(); const getAccount = useCallback(makeGetAccount(), []); const account = useAppSelector((state) => getAccount(state, accountId)); if (!account) return null; const handleUnblock = () => dispatch(groupUnblock(groupId, accountId)) .then(() => toast.success(intl.formatMessage(messages.unblocked, { name: account.acct }))); return (