import React from 'react' import PropTypes from 'prop-types' import { translate, Interpolate } from 'react-i18next' import PopupLayout from '../../../../common/Popups/PopupLayout' import { CustomInput } from 'reactstrap' import { getTitle } from '../../../../../common/helper' export class SourceIndexUpdatePopup extends React.Component { static propTypes = { type: PropTypes.string.isRequired, sourceLists: PropTypes.array.isRequired, chosenLists: PropTypes.array.isRequired, chosenSourceIndexes: PropTypes.array.isRequired, updateItemTitle: PropTypes.string, actions: PropTypes.object.isRequired, t: PropTypes.func.isRequired }; componentWillMount = () => { const { sourceLists, actions } = this.props if (sourceLists.length === 0) { actions.getMainSourceLists({page: 1, limit: 50}) } }; onChoseList = (e) => { const { type, chosenLists, actions } = this.props const isChecked = e.target.checked const listId = parseInt(e.target.dataset.listId) const lists = isChecked ? chosenLists.concat(listId) : chosenLists.filter((id) => listId !== id) const action = type === 'add' ? actions.setChosenListsToAddSources : actions.setChosenListsToUpdateSources action(lists) }; onSubmit = () => { const { actions, chosenSourceIndexes, chosenLists, type } = this.props actions.addSourcesToList({ sources: chosenSourceIndexes, sourceLists: chosenLists }, type === 'add') }; getBodyTitle () { const { t, type, updateItemTitle } = this.props if (type === 'add') { return
{t('sourceListsTab.popup.addToListDesc')}
} else { return (