1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-23 03:36:18 +02:00
metamask-extension/ui/app/components/wallet-view.js

135 lines
3.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('./account-dropdowns').AccountDropdowns
const Content = require('./wallet-content-display')
const actions = require('../actions')
const selectors = require('../selectors')
module.exports = connect(mapStateToProps, mapDispatchToProps)(WalletView)
function mapStateToProps (state) {
2017-08-10 08:48:05 +02:00
return {
network: state.metamask.network,
sidebarOpen: state.appState.sidebarOpen,
2017-08-07 06:54:42 +02: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-10 08:48:05 +02:00
showSendPage: () => {dispatch(actions.showSendPage())},
hideSidebar: () => {dispatch(actions.hideSidebar())},
}
}
inherits(WalletView, Component)
function WalletView () {
Component.call(this)
}
const noop = () => {}
WalletView.prototype.render = function () {
2017-08-10 10:52:26 +02:00
const { network, responsiveDisplayClassname, style, identities, selectedAddress, selectedAccount } = this.props
console.log(selectedAccount)
2017-08-02 22:03:36 +02:00
return h('div.wallet-view.flex-column' + (responsiveDisplayClassname || ''), {
style: {},
}, [
// TODO: Separate component: wallet account details
h('div.flex-column', {
2017-08-10 08:48:05 +02:00
style: {}
}, [
2017-08-07 06:54:42 +02:00
h('div.flex-row.account-options-menu', {
style: {
position: 'relative',
},
2017-08-07 06:54:42 +02:00
}, [
h(AccountDropdowns, {
selected: selectedAddress,
network,
identities,
2017-08-07 06:54:42 +02: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-07 06:54:42 +02:00
}, []),
]),
2017-08-07 06:54:42 +02:00
h('div.flex-column.flex-center', {
style: {
position: 'relative',
},
}, [
2017-08-07 06:54:42 +02:00
h('.identicon-wrapper.select-none', {
style: {
marginBottom: '1%',
},
}, [
h(Identicon, {
diameter: 54,
address: selectedAddress,
2017-08-07 06:54:42 +02:00
}),
]),
h('span.account-name', {
2017-08-10 08:48:05 +02:00
style: {}
2017-08-07 06:54:42 +02:00
}, [
2017-08-10 08:48:05 +02:00
'Account 1'
2017-08-07 06:54:42 +02:00
]),
h(AccountDropdowns, {
2017-08-07 06:54:42 +02:00
style: {
position: 'absolute',
left: 'calc(50% + 28px + 5.5px)',
top: '19.5%',
2017-08-07 06:54:42 +02:00
},
2017-08-10 08:48:05 +02:00
selected: selectedAddress,
network,
identities,
enableAccountsSelector: true,
}, []),
]),
]),
h(Content, {
2017-08-10 08:48:05 +02:00
title: 'Wallet',
amount: '1001.124 ETH',
fiatValue: '$300,000.00 USD',
active: true,
}),
// Wallet contents
h(Content, {
2017-08-10 08:48:05 +02:00
title: "Total Token Balance",
amount: "45.439 ETH",
fiatValue: "$13,000.00 USD",
active: false,
style: {
marginTop: '1.3em',
2017-08-10 08:48:05 +02:00
}
})
])
}