1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-23 11:46:13 +02:00
metamask-extension/ui/app/components/tx-view.js

140 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 ethUtil = require('ethereumjs-util')
const inherits = require('util').inherits
2017-08-02 22:32:02 +02:00
const actions = require('../actions')
// slideout menu
const WalletView = require('./wallet-view')
// balance component
const BalanceComponent = require('./balance-component')
2017-08-09 12:10:51 +02:00
// tx list
const TxList = require('./tx-list')
const Identicon = require('./identicon')
// const AccountDropdowns = require('./account-dropdowns').AccountDropdowns
// const Content = require('./wallet-content-display')
2017-08-02 22:32:02 +02:00
module.exports = connect(mapStateToProps, mapDispatchToProps)(TxView)
function mapStateToProps (state) {
return {
sidebarOpen: state.appState.sidebarOpen,
identities: state.metamask.identities,
accounts: state.metamask.accounts,
address: state.metamask.selectedAddress,
2017-08-09 12:10:51 +02:00
transactions: state.metamask.selectedAddressTxList || [],
shapeShiftTxList: state.metamask.shapeShiftTxList,
conversionRate: state.metamask.conversionRate,
currentCurrency: state.metamask.currentCurrency,
2017-08-02 22:32:02 +02:00
}
}
2017-08-02 22:32:02 +02:00
function mapDispatchToProps (dispatch) {
return {
showSidebar: () => { dispatch(actions.showSidebar()) },
hideSidebar: () => { dispatch(actions.hideSidebar()) },
showModal: () => { dispatch(actions.showModal()) },
2017-08-02 22:32:02 +02:00
}
}
2017-08-01 06:34:37 +02:00
inherits(TxView, Component)
function TxView () {
Component.call(this)
}
TxView.prototype.render = function () {
var props = this.props
var selected = props.address || Object.keys(props.accounts)[0]
var checksumAddress = selected && ethUtil.toChecksumAddress(selected)
var identity = props.identities[selected]
var account = props.accounts[selected]
2017-08-09 12:10:51 +02:00
const { conversionRate, currentCurrency, transactions } = props
console.log(transactions)
return h('div.tx-view.flex-column', {
style: {},
}, [
h('div.flex-row.phone-visible', {
style: {
margin: '1em 0.9em',
alignItems: 'center'
},
onClick: () => {
this.props.sidebarOpen ? this.props.hideSidebar() : this.props.showSidebar()
},
}, [
// burger
h('div.fa.fa-bars', {
style: {
fontSize: '1.3em',
},
}, []),
// account display
h('.identicon-wrapper.select-none', {
style: {
marginLeft: '0.9em',
},
}, [
h(Identicon, {
diameter: 24,
address: selected,
}),
]),
h('span.account-name', {
style: {},
}, [
identity.name,
]),
]),
2017-08-07 00:46:55 +02:00
// laptop: flex-row, flex-center
// mobile: flex-column
h('div.hero-balance', {
style: {},
2017-08-03 09:43:24 +02:00
}, [
h(BalanceComponent, {
balanceValue: account && account.balance,
conversionRate,
currentCurrency,
style: {},
2017-08-07 00:46:55 +02:00
}),
// laptop: 10vw?
// phone: 75vw?
h('div.flex-row.flex-center.hero-balance-buttons', {
2017-08-09 12:10:51 +02:00
style: {},
2017-08-07 00:46:55 +02:00
}, [
h('button.btn-clear', {
style: {
2017-08-07 00:46:55 +02:00
textAlign: 'center',
},
onClick: () => {
this.props.showModal()
},
2017-08-07 00:46:55 +02:00
}, 'BUY'),
2017-08-03 09:43:24 +02:00
2017-08-07 00:46:55 +02:00
h('button.btn-clear', {
style: {
textAlign: 'center',
marginLeft: '1.4em',
},
}, 'SEND'),
2017-08-07 00:46:55 +02:00
]),
2017-08-03 09:43:24 +02:00
]),
2017-08-09 12:10:51 +02:00
h(TxList, {}),
2017-08-01 07:00:18 +02:00
])
}