import React from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { removeFromListEditor, addToListEditor } from 'soapbox/actions/lists'; import IconButton from 'soapbox/components/icon-button'; import { HStack } from 'soapbox/components/ui'; import AccountContainer from 'soapbox/containers/account-container'; import { useAppSelector, useAppDispatch } from 'soapbox/hooks'; const messages = defineMessages({ remove: { id: 'lists.account.remove', defaultMessage: 'Remove from list' }, add: { id: 'lists.account.add', defaultMessage: 'Add to list' }, }); interface IAccount { accountId: string, } const Account: React.FC = ({ accountId }) => { const intl = useIntl(); const dispatch = useAppDispatch(); const isAdded = useAppSelector((state) => state.listEditor.accounts.items.includes(accountId)); const onRemove = () => dispatch(removeFromListEditor(accountId)); const onAdd = () => dispatch(addToListEditor(accountId)); let button; if (isAdded) { button = ; } else { button = ; } return (
{button}
); }; export default Account;