You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
43 lines
1.4 KiB
4 years ago
|
import { compose } from 'redux';
|
||
|
import { connect } from 'react-redux';
|
||
|
import { withRouter } from 'react-router-dom';
|
||
|
import { getAddressBook } from '../../../selectors';
|
||
4 years ago
|
import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app';
|
||
|
import { getEnvironmentType } from '../../../../app/scripts/lib/util';
|
||
5 years ago
|
|
||
|
import {
|
||
|
CONTACT_ADD_ROUTE,
|
||
|
CONTACT_EDIT_ROUTE,
|
||
|
CONTACT_VIEW_ROUTE,
|
||
4 years ago
|
} from '../../../helpers/constants/routes';
|
||
|
import ContactListTab from './contact-list-tab.component';
|
||
5 years ago
|
|
||
|
const mapStateToProps = (state, ownProps) => {
|
||
4 years ago
|
const { location } = ownProps;
|
||
|
const { pathname } = location;
|
||
5 years ago
|
|
||
4 years ago
|
const pathNameTail = pathname.match(/[^/]+$/u)[0];
|
||
|
const pathNameTailIsAddress = pathNameTail.includes('0x');
|
||
5 years ago
|
|
||
4 years ago
|
const viewingContact = Boolean(pathname.match(CONTACT_VIEW_ROUTE));
|
||
|
const editingContact = Boolean(pathname.match(CONTACT_EDIT_ROUTE));
|
||
4 years ago
|
const addingContact = Boolean(pathname.match(CONTACT_ADD_ROUTE));
|
||
|
const envIsPopup = getEnvironmentType() === ENVIRONMENT_TYPE_POPUP;
|
||
5 years ago
|
|
||
4 years ago
|
const hideAddressBook =
|
||
4 years ago
|
envIsPopup && (viewingContact || editingContact || addingContact);
|
||
5 years ago
|
|
||
|
return {
|
||
|
viewingContact,
|
||
|
editingContact,
|
||
|
addingContact,
|
||
|
addressBook: getAddressBook(state),
|
||
|
selectedAddress: pathNameTailIsAddress ? pathNameTail : '',
|
||
|
hideAddressBook,
|
||
|
envIsPopup,
|
||
|
showContactContent: !envIsPopup || hideAddressBook,
|
||
4 years ago
|
};
|
||
|
};
|
||
5 years ago
|
|
||
4 years ago
|
export default compose(withRouter, connect(mapStateToProps))(ContactListTab);
|