import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import ImmutablePropTypes from 'react-immutable-proptypes' import ImmutablePureComponent from 'react-immutable-pure-component' import { injectIntl, defineMessages } from 'react-intl' import isObject from 'lodash.isobject' import { setupListEditor, resetListEditor, removeFromListEditor, addToListEditor, fetchListSuggestions, clearListSuggestions, changeListSuggestions, } from '../actions/lists' import { openModal } from '../actions/modal' import { MODAL_LIST_EDITOR, MODAL_LIST_DELETE, } from '../constants' import Account from '../components/account' import Button from '../components/button' import Divider from '../components/divider' import Input from '../components/input' import TabBar from '../components/tab_bar' import Text from '../components/text' class ListEdit extends ImmutablePureComponent { state = { activeTab: this.props.tab || 'members' } componentDidMount() { const { onInitialize, listId } = this.props if (listId) { onInitialize(listId) } } componentDidUpdate(prevProps) { if (this.props.listId !== prevProps.listId) { this.props.onInitialize(this.props.listId) } } componentWillUnmount() { this.props.onReset() } handleChangeTab = (tab) => { this.setState({ activeTab: tab }) } onClickClose = () => { this.props.onClose(MODAL_LIST_EDITOR) } handleOnDeleteList = () => { this.props.onDeleteList(this.props.list) } handleAddOrRemoveFromList = (accountId) => { if (this.props.accountIds.includes(accountId)) { this.props.onRemoveAccountFromList(accountId) } else { this.props.onAddAccountToList(accountId) } } handleSearchSuggestionsChange = (value) => { this.props.onChangeSuggestions(value) } handleSearchSuggestionsKeyUp = (e) => { if (e.keyCode === 13) { this.props.onSubmitSearchSuggestions(this.props.searchSuggestionsValue) } } handleSearchSuggestionsSubmit = () => { this.props.onSubmitSearchSuggestions(this.props.searchSuggestionsValue) } render() { const { title, accountIds, searchAccountIds, intl, searchSuggestionsValue, } = this.props const { activeTab } = this.state // : todo : save new list title return (