import React from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { removeFromListAdder, addToListAdder } from 'soapbox/actions/lists'; import Icon from 'soapbox/components/icon'; import IconButton from 'soapbox/components/icon-button'; import { useAppDispatch, useAppSelector } 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 IList { listId: string, } const List: React.FC = ({ listId }) => { const intl = useIntl(); const dispatch = useAppDispatch(); const list = useAppSelector((state) => state.lists.get(listId)); const added = useAppSelector((state) => state.listAdder.lists.items.includes(listId)); const onRemove = () => dispatch(removeFromListAdder(listId)); const onAdd = () => dispatch(addToListAdder(listId)); if (!list) return null; let button; if (added) { button = ; } else { button = ; } return (
{list.title} {button}
); }; export default List;