2017-08-09 12:10:51 +02:00
|
|
|
const Component = require('react').Component
|
|
|
|
const connect = require('react-redux').connect
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const inherits = require('util').inherits
|
2017-08-11 04:35:10 +02:00
|
|
|
const selectors = require('../selectors')
|
|
|
|
const Identicon = require('./identicon')
|
2017-08-23 01:16:56 +02:00
|
|
|
const { formatBalance, formatDate } = require('../util')
|
2017-08-09 12:10:51 +02:00
|
|
|
|
|
|
|
const valuesFor = require('../util').valuesFor
|
|
|
|
|
|
|
|
module.exports = connect(mapStateToProps)(TxList)
|
|
|
|
|
2017-08-10 05:06:37 +02:00
|
|
|
function mapStateToProps (state) {
|
2017-08-09 12:10:51 +02:00
|
|
|
return {
|
2017-08-11 04:35:10 +02:00
|
|
|
txsToRender: selectors.transactionsSelector(state),
|
|
|
|
conversionRate: selectors.conversionRateSelector(state),
|
2017-08-09 12:10:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inherits(TxList, Component)
|
|
|
|
function TxList () {
|
|
|
|
Component.call(this)
|
|
|
|
}
|
|
|
|
|
2017-08-11 05:52:22 +02:00
|
|
|
const contentDivider = h('div.tx-list-content-divider', {
|
2017-08-11 07:47:56 +02:00
|
|
|
style: {},
|
2017-08-09 12:10:51 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
TxList.prototype.render = function () {
|
|
|
|
|
2017-08-10 05:06:37 +02:00
|
|
|
const { txsToRender, conversionRate } = this.props
|
2017-08-09 12:10:51 +02:00
|
|
|
|
2017-08-10 05:06:37 +02:00
|
|
|
console.log('transactions to render', txsToRender)
|
2017-08-09 12:10:51 +02:00
|
|
|
|
|
|
|
return h('div.flex-column.tx-list-container', {}, [
|
|
|
|
|
2017-08-11 07:47:56 +02:00
|
|
|
h('div.flex-row.tx-list-header-wrapper', {
|
2017-08-11 05:52:22 +02:00
|
|
|
style: {},
|
2017-08-09 12:10:51 +02:00
|
|
|
}, [
|
|
|
|
|
2017-08-11 07:47:56 +02:00
|
|
|
h('div.flex-row.tx-list-header', {
|
2017-08-09 12:10:51 +02:00
|
|
|
}, [
|
|
|
|
|
|
|
|
h('div', {
|
2017-08-11 04:35:10 +02:00
|
|
|
style: {}
|
2017-08-09 12:10:51 +02:00
|
|
|
}, 'TRANSACTIONS'),
|
|
|
|
|
|
|
|
]),
|
2017-08-11 05:52:22 +02:00
|
|
|
|
2017-08-09 12:10:51 +02:00
|
|
|
]),
|
|
|
|
|
|
|
|
contentDivider,
|
|
|
|
|
2017-08-23 01:16:56 +02:00
|
|
|
txsToRender.map((transaction) => {
|
|
|
|
return this.renderTransactionListItem(transaction)
|
|
|
|
}),
|
2017-08-09 12:10:51 +02:00
|
|
|
|
|
|
|
])
|
|
|
|
}
|
|
|
|
|
2017-08-23 01:16:56 +02:00
|
|
|
// TODO: Consider moving TxListItem into a separate component
|
|
|
|
TxList.prototype.renderTransactionListItem = function (transaction) {
|
2017-08-11 04:35:10 +02:00
|
|
|
const props = {
|
2017-08-23 01:16:56 +02:00
|
|
|
dateString: formatDate(transaction.time),
|
|
|
|
address: transaction.txParams.to,
|
|
|
|
transactionStatus: transaction.status,
|
|
|
|
transactionAmount: formatBalance(transaction.txParams.value, 6),
|
2017-08-11 04:35:10 +02:00
|
|
|
}
|
|
|
|
const { address, transactionStatus, transactionAmount, dateString } = props
|
|
|
|
|
2017-08-11 04:55:01 +02:00
|
|
|
return h('div.flex-column.tx-list-item-wrapper', {
|
|
|
|
style: {}
|
2017-08-09 12:10:51 +02:00
|
|
|
}, [
|
|
|
|
|
2017-08-11 04:55:01 +02:00
|
|
|
h('div.tx-list-date-wrapper', {
|
|
|
|
style: {}
|
2017-08-11 04:35:10 +02:00
|
|
|
}, [
|
2017-08-11 04:55:01 +02:00
|
|
|
h('span.tx-list-date', {}, [
|
2017-08-11 04:35:10 +02:00
|
|
|
dateString,
|
|
|
|
])
|
|
|
|
]),
|
2017-08-09 12:10:51 +02:00
|
|
|
|
2017-08-11 04:55:01 +02:00
|
|
|
h('div.flex-row.tx-list-content-wrapper', {
|
|
|
|
style: {}
|
2017-08-09 12:10:51 +02:00
|
|
|
}, [
|
|
|
|
|
2017-08-11 04:55:01 +02:00
|
|
|
h('div.tx-list-identicon-wrapper', {
|
|
|
|
style: {}
|
2017-08-11 04:35:10 +02:00
|
|
|
}, [
|
|
|
|
h(Identicon, {
|
|
|
|
address,
|
2017-08-11 05:52:22 +02:00
|
|
|
diameter: 24,
|
2017-08-11 04:35:10 +02:00
|
|
|
})
|
|
|
|
]),
|
2017-08-09 12:10:51 +02:00
|
|
|
|
2017-08-11 07:16:42 +02:00
|
|
|
h('div.tx-list-account-and-status-wrapper', {}, [
|
|
|
|
h('div.tx-list-account-wrapper', {
|
|
|
|
style: {}
|
|
|
|
}, [
|
|
|
|
h('span.tx-list-account', {}, [
|
2017-08-23 01:16:56 +02:00
|
|
|
`${address.slice(0, 10)}...${address.slice(-4)}`
|
2017-08-11 07:16:42 +02:00
|
|
|
]),
|
2017-08-11 04:35:10 +02:00
|
|
|
]),
|
2017-08-09 12:10:51 +02:00
|
|
|
|
2017-08-11 07:16:42 +02:00
|
|
|
h('div.tx-list-status-wrapper', {
|
|
|
|
style: {}
|
|
|
|
}, [
|
|
|
|
h('span.tx-list-status', {}, [
|
|
|
|
transactionStatus,
|
|
|
|
]),
|
2017-08-11 04:35:10 +02:00
|
|
|
]),
|
|
|
|
]),
|
2017-08-09 12:10:51 +02:00
|
|
|
|
2017-08-11 04:55:01 +02:00
|
|
|
h('div.flex-column.tx-list-details-wrapper', {
|
|
|
|
style: {}
|
2017-08-11 04:35:10 +02:00
|
|
|
}, [
|
2017-08-09 12:10:51 +02:00
|
|
|
|
2017-08-11 05:52:22 +02:00
|
|
|
h('span.tx-list-value', {}, [
|
2017-08-11 04:35:10 +02:00
|
|
|
transactionAmount,
|
|
|
|
]),
|
|
|
|
|
2017-08-11 05:52:22 +02:00
|
|
|
h('span.tx-list-fiat-value', {}, [
|
|
|
|
'+ $300 USD',
|
2017-08-11 04:35:10 +02:00
|
|
|
]),
|
2017-08-09 12:10:51 +02:00
|
|
|
|
2017-08-11 04:35:10 +02:00
|
|
|
]),
|
|
|
|
])
|
2017-08-09 12:10:51 +02:00
|
|
|
])
|
|
|
|
}
|
|
|
|
|