import React from 'react'; import PropTypes from 'prop-types'; import { Link } from 'react-router'; import { withTranslation } from 'react-i18next'; import Icons from './Icons'; const Item = ({ isAdded, onSelect, name, url, t }) => { const buttonLabel = isAdded ? t('QuickAddList.ButtonRemoveARIA') : t('QuickAddList.ButtonAddToCollectionARIA'); return (
  • { /* eslint-disable-line */ } {name} e.stopPropogation()} > {t('QuickAddList.View')}
  • ); }; const ItemType = PropTypes.shape({ name: PropTypes.string.isRequired, url: PropTypes.string.isRequired, isAdded: PropTypes.bool.isRequired, }); Item.propTypes = { name: PropTypes.string.isRequired, url: PropTypes.string.isRequired, isAdded: PropTypes.bool.isRequired, onSelect: PropTypes.func.isRequired, t: PropTypes.func.isRequired }; const QuickAddList = ({ items, onAdd, onRemove, t }) => { const handleAction = (item) => { if (item.isAdded) { onRemove(item); } else { onAdd(item); } }; return ( ); }; QuickAddList.propTypes = { items: PropTypes.arrayOf(ItemType).isRequired, onAdd: PropTypes.func.isRequired, onRemove: PropTypes.func.isRequired, t: PropTypes.func.isRequired }; export default withTranslation()(QuickAddList);