2016-08-18 19:40:35 +02:00
|
|
|
const inherits = require('util').inherits
|
|
|
|
const Component = require('react').Component
|
2018-03-29 17:00:44 +02:00
|
|
|
const PropTypes = require('prop-types')
|
2016-08-18 19:40:35 +02:00
|
|
|
const h = require('react-hyperscript')
|
2018-03-29 17:00:44 +02:00
|
|
|
const connect = require('react-redux').connect
|
2017-08-03 23:48:19 +02:00
|
|
|
const vreme = new (require('vreme'))()
|
2017-10-14 17:23:44 +02:00
|
|
|
const explorerLink = require('etherscan-link').createExplorerLink
|
2016-08-18 19:40:35 +02:00
|
|
|
const actions = require('../actions')
|
|
|
|
const addressSummary = require('../util').addressSummary
|
|
|
|
|
|
|
|
const CopyButton = require('./copyButton')
|
2017-05-16 20:34:53 +02:00
|
|
|
const EthBalance = require('./eth-balance')
|
2016-08-19 00:20:26 +02:00
|
|
|
const Tooltip = require('./tooltip')
|
2016-08-18 19:40:35 +02:00
|
|
|
|
|
|
|
|
2018-03-29 17:00:44 +02:00
|
|
|
ShiftListItem.contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
}
|
|
|
|
|
2016-08-18 19:40:35 +02:00
|
|
|
module.exports = connect(mapStateToProps)(ShiftListItem)
|
|
|
|
|
2018-03-29 17:00:44 +02:00
|
|
|
|
2016-08-18 19:40:35 +02:00
|
|
|
function mapStateToProps (state) {
|
2017-05-12 21:41:31 +02:00
|
|
|
return {
|
2018-01-12 20:48:18 +01:00
|
|
|
selectedAddress: state.metamask.selectedAddress,
|
2017-05-12 21:41:31 +02:00
|
|
|
conversionRate: state.metamask.conversionRate,
|
2017-05-16 20:34:53 +02:00
|
|
|
currentCurrency: state.metamask.currentCurrency,
|
2017-05-12 21:41:31 +02:00
|
|
|
}
|
2016-08-18 19:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inherits(ShiftListItem, Component)
|
2016-08-19 00:20:26 +02:00
|
|
|
|
2016-08-18 19:40:35 +02:00
|
|
|
function ShiftListItem () {
|
|
|
|
Component.call(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
ShiftListItem.prototype.render = function () {
|
2018-08-07 07:39:54 +02:00
|
|
|
return h('div.transaction-list-item.tx-list-clickable', {
|
2018-02-09 01:40:15 +01:00
|
|
|
style: {
|
|
|
|
paddingTop: '20px',
|
|
|
|
paddingBottom: '20px',
|
|
|
|
justifyContent: 'space-around',
|
|
|
|
alignItems: 'center',
|
2018-08-07 07:39:54 +02:00
|
|
|
flexDirection: 'row',
|
2018-02-09 01:40:15 +01:00
|
|
|
},
|
|
|
|
}, [
|
|
|
|
h('div', {
|
|
|
|
style: {
|
|
|
|
width: '0px',
|
|
|
|
position: 'relative',
|
|
|
|
bottom: '19px',
|
|
|
|
},
|
|
|
|
}, [
|
|
|
|
h('img', {
|
|
|
|
src: 'https://info.shapeshift.io/sites/default/files/logo.png',
|
2016-08-18 19:40:35 +02:00
|
|
|
style: {
|
2018-02-09 01:40:15 +01:00
|
|
|
height: '35px',
|
|
|
|
width: '132px',
|
|
|
|
position: 'absolute',
|
|
|
|
clip: 'rect(0px,23px,34px,0px)',
|
2016-08-18 19:40:35 +02:00
|
|
|
},
|
2018-02-09 01:40:15 +01:00
|
|
|
}),
|
|
|
|
]),
|
2016-08-18 19:40:35 +02:00
|
|
|
|
2018-02-09 01:40:15 +01:00
|
|
|
this.renderInfo(),
|
|
|
|
this.renderUtilComponents(),
|
|
|
|
])
|
2016-08-18 19:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function formatDate (date) {
|
|
|
|
return vreme.format(new Date(date), 'March 16 2014 14:30')
|
|
|
|
}
|
|
|
|
|
|
|
|
ShiftListItem.prototype.renderUtilComponents = function () {
|
|
|
|
var props = this.props
|
2017-05-16 20:34:53 +02:00
|
|
|
const { conversionRate, currentCurrency } = props
|
2016-08-18 19:40:35 +02:00
|
|
|
|
|
|
|
switch (props.response.status) {
|
|
|
|
case 'no_deposits':
|
|
|
|
return h('.flex-row', [
|
2016-08-19 00:20:26 +02:00
|
|
|
h(CopyButton, {
|
|
|
|
value: this.props.depositAddress,
|
2016-08-18 19:40:35 +02:00
|
|
|
}),
|
2016-08-19 00:20:26 +02:00
|
|
|
h(Tooltip, {
|
2018-03-29 17:00:44 +02:00
|
|
|
title: this.context.t('qrCode'),
|
2016-08-19 00:20:26 +02:00
|
|
|
}, [
|
|
|
|
h('i.fa.fa-qrcode.pointer.pop-hover', {
|
|
|
|
onClick: () => props.dispatch(actions.reshowQrCode(props.depositAddress, props.depositType)),
|
|
|
|
style: {
|
|
|
|
margin: '5px',
|
|
|
|
marginLeft: '23px',
|
|
|
|
marginRight: '12px',
|
|
|
|
fontSize: '20px',
|
|
|
|
color: '#F7861C',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
]),
|
2016-08-18 19:40:35 +02:00
|
|
|
])
|
|
|
|
case 'received':
|
|
|
|
return h('.flex-row')
|
|
|
|
|
|
|
|
case 'complete':
|
|
|
|
return h('.flex-row', [
|
2016-08-19 00:20:26 +02:00
|
|
|
h(CopyButton, {
|
|
|
|
value: this.props.response.transaction,
|
|
|
|
}),
|
2017-05-16 20:34:53 +02:00
|
|
|
h(EthBalance, {
|
2016-08-19 05:24:17 +02:00
|
|
|
value: `${props.response.outgoingCoin}`,
|
2017-05-12 21:41:31 +02:00
|
|
|
conversionRate,
|
2017-05-16 20:34:53 +02:00
|
|
|
currentCurrency,
|
2016-08-19 05:24:17 +02:00
|
|
|
width: '55px',
|
|
|
|
shorten: true,
|
2016-08-20 02:18:11 +02:00
|
|
|
needsParse: false,
|
|
|
|
incoming: true,
|
2016-08-19 00:20:26 +02:00
|
|
|
style: {
|
2016-08-19 05:24:17 +02:00
|
|
|
fontSize: '15px',
|
|
|
|
color: '#01888C',
|
2016-08-19 00:20:26 +02:00
|
|
|
},
|
2016-08-19 05:24:17 +02:00
|
|
|
}),
|
2016-08-18 19:40:35 +02:00
|
|
|
])
|
|
|
|
|
|
|
|
case 'failed':
|
|
|
|
return ''
|
|
|
|
default:
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ShiftListItem.prototype.renderInfo = function () {
|
|
|
|
var props = this.props
|
|
|
|
switch (props.response.status) {
|
|
|
|
case 'no_deposits':
|
2016-08-19 00:20:26 +02:00
|
|
|
return h('.flex-column', {
|
|
|
|
style: {
|
|
|
|
width: '200px',
|
|
|
|
overflow: 'hidden',
|
|
|
|
},
|
|
|
|
}, [
|
2016-08-18 19:40:35 +02:00
|
|
|
h('div', {
|
2016-08-19 00:20:26 +02:00
|
|
|
style: {
|
|
|
|
fontSize: 'x-small',
|
|
|
|
color: '#ABA9AA',
|
|
|
|
width: '100%',
|
|
|
|
},
|
2018-03-29 17:00:44 +02:00
|
|
|
}, this.context.t('toETHviaShapeShift', [props.depositType])),
|
|
|
|
h('div', this.context.t('noDeposits')),
|
2016-08-18 19:40:35 +02:00
|
|
|
h('div', {
|
|
|
|
style: {
|
|
|
|
fontSize: 'x-small',
|
|
|
|
color: '#ABA9AA',
|
|
|
|
width: '100%',
|
|
|
|
},
|
|
|
|
}, formatDate(props.time)),
|
|
|
|
])
|
|
|
|
case 'received':
|
2016-08-19 00:20:26 +02:00
|
|
|
return h('.flex-column', {
|
|
|
|
style: {
|
|
|
|
width: '200px',
|
|
|
|
overflow: 'hidden',
|
|
|
|
},
|
|
|
|
}, [
|
2016-08-18 19:40:35 +02:00
|
|
|
h('div', {
|
2016-08-19 00:20:26 +02:00
|
|
|
style: {
|
|
|
|
fontSize: 'x-small',
|
|
|
|
color: '#ABA9AA',
|
|
|
|
width: '100%',
|
|
|
|
},
|
2018-03-29 17:00:44 +02:00
|
|
|
}, this.context.t('toETHviaShapeShift', [props.depositType])),
|
|
|
|
h('div', this.context.t('conversionProgress')),
|
2016-08-18 19:40:35 +02:00
|
|
|
h('div', {
|
|
|
|
style: {
|
|
|
|
fontSize: 'x-small',
|
|
|
|
color: '#ABA9AA',
|
|
|
|
width: '100%',
|
|
|
|
},
|
|
|
|
}, formatDate(props.time)),
|
|
|
|
])
|
|
|
|
case 'complete':
|
2016-08-19 00:20:26 +02:00
|
|
|
var url = explorerLink(props.response.transaction, parseInt('1'))
|
2016-08-18 19:40:35 +02:00
|
|
|
|
|
|
|
return h('.flex-column.pointer', {
|
2016-08-19 00:20:26 +02:00
|
|
|
style: {
|
|
|
|
width: '200px',
|
|
|
|
overflow: 'hidden',
|
|
|
|
},
|
2017-04-01 03:04:13 +02:00
|
|
|
onClick: () => global.platform.openWindow({ url }),
|
2016-08-18 19:40:35 +02:00
|
|
|
}, [
|
|
|
|
h('div', {
|
2016-08-19 00:20:26 +02:00
|
|
|
style: {
|
|
|
|
fontSize: 'x-small',
|
|
|
|
color: '#ABA9AA',
|
|
|
|
width: '100%',
|
|
|
|
},
|
2018-03-29 17:00:44 +02:00
|
|
|
}, this.context.t('fromShapeShift')),
|
2016-08-19 00:20:26 +02:00
|
|
|
h('div', formatDate(props.time)),
|
2016-08-18 19:40:35 +02:00
|
|
|
h('div', {
|
|
|
|
style: {
|
|
|
|
fontSize: 'x-small',
|
|
|
|
color: '#ABA9AA',
|
|
|
|
width: '100%',
|
|
|
|
},
|
|
|
|
}, addressSummary(props.response.transaction)),
|
|
|
|
])
|
|
|
|
|
|
|
|
case 'failed':
|
2018-03-29 17:00:44 +02:00
|
|
|
return h('span.error', '(' + this.context.t('failed') + ')')
|
2016-08-18 19:40:35 +02:00
|
|
|
default:
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
}
|