nifty-wallet/ui/app/components/wallet-view.js

176 lines
4.3 KiB
JavaScript
Raw Normal View History

const Component = require('react').Component
const connect = require('react-redux').connect
const h = require('react-hyperscript')
const inherits = require('util').inherits
const Identicon = require('./identicon')
const AccountDropdowns = require('./dropdowns/index.js').AccountDropdowns
const Content = require('./wallet-content-display')
const actions = require('../actions')
2017-08-11 00:31:06 -07:00
const BalanceComponent = require('./balance-component')
const selectors = require('../selectors')
module.exports = connect(mapStateToProps, mapDispatchToProps)(WalletView)
function mapStateToProps (state) {
2017-08-09 23:48:05 -07:00
return {
network: state.metamask.network,
sidebarOpen: state.appState.sidebarOpen,
2017-08-06 21:54:42 -07:00
identities: state.metamask.identities,
accounts: state.metamask.accounts,
selectedAddress: selectors.getSelectedAddress(state),
selectedIdentity: selectors.getSelectedIdentity(state),
selectedAccount: selectors.getSelectedAccount(state),
}
}
function mapDispatchToProps (dispatch) {
return {
2017-08-09 23:48:05 -07:00
showSendPage: () => {dispatch(actions.showSendPage())},
hideSidebar: () => {dispatch(actions.hideSidebar())},
}
}
inherits(WalletView, Component)
function WalletView () {
Component.call(this)
}
const noop = () => {}
WalletView.prototype.render = function () {
const { network, responsiveDisplayClassname, style, identities, selectedAddress, selectedAccount, accounts, selectedIdentity } = this.props
// temporary logs + fake extra wallets
console.log("walletview, selectedAccount:", selectedAccount)
const extraWallet = h('div.flex-column.wallet-balance-wrapper', {}, [
h('div.wallet-balance', {}, [
h(BalanceComponent, {
balanceValue: selectedAccount.balance,
style: {},
}),
]),
])
2017-08-02 13:03:36 -07:00
return h('div.wallet-view.flex-column' + (responsiveDisplayClassname || ''), {
style: {},
}, [
// TODO: Separate component: wallet account details
h('div.flex-column.wallet-view-account-details', {
2017-08-09 23:48:05 -07:00
style: {}
}, [
2017-08-06 21:54:42 -07:00
h('div.flex-row.account-options-menu', {
style: {
position: 'relative',
},
2017-08-06 21:54:42 -07:00
}, [
h(AccountDropdowns, {
selected: selectedAddress,
network,
identities,
useCssTransition: true,
2017-08-06 21:54:42 -07:00
enableAccountOptions: true,
dropdownWrapperStyle: {
padding: '1px 15px',
marginLeft: '-25px',
position: 'absolute',
width: '122%', //TODO, refactor all of this component out into media queries
},
menuItemStyles: {
padding: '0px 0px',
margin: '22px 0px',
}
2017-08-06 21:54:42 -07:00
}, []),
]),
2017-08-06 21:54:42 -07:00
h('div.flex-column.flex-center', {
}, [
h('div', {
2017-08-06 21:54:42 -07:00
style: {
position: 'relative',
}
2017-08-06 21:54:42 -07:00
}, [
h(AccountDropdowns, {
accounts,
style: {
position: 'absolute',
left: 'calc(50% + 28px + 5.5px)',
top: '14px',
},
innerStyle: {
padding: '2px 16px',
},
useCssTransition: true,
selected: selectedAddress,
network,
identities,
enableAccountsSelector: true,
}, []),
2017-08-06 21:54:42 -07:00
]),
h(Identicon, {
diameter: 54,
address: selectedAddress,
}),
2017-08-06 21:54:42 -07:00
h('span.account-name', {
2017-08-09 23:48:05 -07:00
style: {}
2017-08-06 21:54:42 -07:00
}, [
selectedIdentity.name
2017-08-06 21:54:42 -07:00
]),
]),
]),
2017-08-11 00:31:06 -07:00
//'Wallet' - Title
// Not visible on mobile
h('div.flex-column.wallet-view-title-wrapper', {}, [
h('span.wallet-view-title', {}, [
'Wallet',
])
]),
//Wallet Balances
h('div.flex-column.wallet-balance-wrapper.wallet-balance-wrapper-active', {}, [
2017-08-11 00:31:06 -07:00
h('div.wallet-balance', {}, [
h(BalanceComponent, {
balanceValue: selectedAccount.balance,
style: {},
}),
]),
]),
h('div.flex-column.wallet-balance-wrapper', {}, [
2017-08-11 00:31:06 -07:00
h('div.wallet-balance', {}, [
h(BalanceComponent, {
balanceValue: selectedAccount.balance,
style: {},
}),
]),
]),
extraWallet,
extraWallet,
extraWallet,
extraWallet,
extraWallet,
extraWallet,
extraWallet,
extraWallet,
extraWallet,
extraWallet,
])
}