import web3 from 'Embark/web3' import React from 'react'; import { connect } from 'react-redux'; import { Nav, MenuItem, NavDropdown } from 'react-bootstrap'; import Blockies from 'react-blockies'; import { string, bool, func, arrayOf, shape } from 'prop-types'; import { getAccounts, getDefaultAccount, accountsIsLoading, actions as accountActions } from '../reducers/accounts'; import './accountlist.css'; const AccList = ({ accounts, defaultAccount, changeAccount, isLoading, classNameNavDropdown, }) => ( {!isLoading ?
:
Loading...
}
); AccList.propTypes = { accounts: arrayOf(shape({ address: string, balance: string })).isRequired, defaultAccount: string, changeAccount: func.isRequired, isLoading: bool.isRequired, classNameNavDropdown: string } const mapStateToProps = state => ({ accounts: getAccounts(state), defaultAccount: getDefaultAccount(state), isLoading: accountsIsLoading(state), }); const mapDispatchToProps = dispatch => ({ changeAccount(address) { web3.eth.defaultAccount = address; dispatch(accountActions.updateDefaultAccount(address)); }, }); export default connect(mapStateToProps, mapDispatchToProps)(AccList);