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 ? 'Remove from collection' : 'Add to collection';
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 (
{items.map(item => (- {
event.stopPropagation();
event.currentTarget.blur();
handleAction(item);
}
}
/>))}
);
};
QuickAddList.propTypes = {
items: PropTypes.arrayOf(ItemType).isRequired,
onAdd: PropTypes.func.isRequired,
onRemove: PropTypes.func.isRequired,
t: PropTypes.func.isRequired
};
export default withTranslation()(QuickAddList);