import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import ContactList from '../../../components/app/contact-list'; import { CONTACT_ADD_ROUTE, CONTACT_VIEW_ROUTE, } from '../../../helpers/constants/routes'; import Button from '../../../components/ui/button'; import { getSettingsSectionNumber, handleSettingsRefs, } from '../../../helpers/utils/settings-search'; import EditContact from './edit-contact'; import AddContact from './add-contact'; import ViewContact from './view-contact'; export default class ContactListTab extends Component { static contextTypes = { t: PropTypes.func, }; static propTypes = { addressBook: PropTypes.array, history: PropTypes.object, selectedAddress: PropTypes.string, viewingContact: PropTypes.bool, editingContact: PropTypes.bool, addingContact: PropTypes.bool, showContactContent: PropTypes.bool, hideAddressBook: PropTypes.bool, }; settingsRefs = Array( getSettingsSectionNumber(this.context.t, this.context.t('contacts')), ) .fill(undefined) .map(() => { return React.createRef(); }); componentDidUpdate() { const { t } = this.context; handleSettingsRefs(t, t('contacts'), this.settingsRefs); } componentDidMount() { const { t } = this.context; handleSettingsRefs(t, t('contacts'), this.settingsRefs); } renderAddresses() { const { addressBook, history, selectedAddress } = this.props; const contacts = addressBook.filter(({ name }) => Boolean(name)); const nonContacts = addressBook.filter(({ name }) => !name); const { t } = this.context; if (addressBook.length) { return (
{t('addFriendsAndAddresses')}