You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.5 KiB
64 lines
1.5 KiB
7 years ago
|
import React, { Component } from 'react'
|
||
|
import PropTypes from 'prop-types'
|
||
7 years ago
|
import SendRowWrapper from '../send-row-wrapper/'
|
||
|
import FromDropdown from './from-dropdown/'
|
||
7 years ago
|
|
||
|
export default class SendFromRow extends Component {
|
||
|
|
||
|
static propTypes = {
|
||
|
closeFromDropdown: PropTypes.func,
|
||
7 years ago
|
conversionRate: PropTypes.number,
|
||
|
from: PropTypes.object,
|
||
7 years ago
|
fromAccounts: PropTypes.array,
|
||
|
fromDropdownOpen: PropTypes.bool,
|
||
|
openFromDropdown: PropTypes.func,
|
||
|
tokenContract: PropTypes.object,
|
||
|
updateSendFrom: PropTypes.func,
|
||
7 years ago
|
setSendTokenBalance: PropTypes.func,
|
||
7 years ago
|
};
|
||
|
|
||
6 years ago
|
static contextTypes = {
|
||
|
t: PropTypes.func,
|
||
|
};
|
||
|
|
||
7 years ago
|
async handleFromChange (newFrom) {
|
||
|
const {
|
||
|
updateSendFrom,
|
||
|
tokenContract,
|
||
7 years ago
|
setSendTokenBalance,
|
||
7 years ago
|
} = this.props
|
||
|
|
||
|
if (tokenContract) {
|
||
|
const usersToken = await tokenContract.balanceOf(newFrom.address)
|
||
7 years ago
|
setSendTokenBalance(usersToken)
|
||
7 years ago
|
}
|
||
|
updateSendFrom(newFrom)
|
||
|
}
|
||
|
|
||
|
render () {
|
||
|
const {
|
||
7 years ago
|
closeFromDropdown,
|
||
|
conversionRate,
|
||
7 years ago
|
from,
|
||
|
fromAccounts,
|
||
|
fromDropdownOpen,
|
||
|
openFromDropdown,
|
||
|
} = this.props
|
||
7 years ago
|
|
||
7 years ago
|
return (
|
||
|
<SendRowWrapper label={`${this.context.t('from')}:`}>
|
||
|
<FromDropdown
|
||
|
accounts={fromAccounts}
|
||
|
closeDropdown={() => closeFromDropdown()}
|
||
|
conversionRate={conversionRate}
|
||
7 years ago
|
dropdownOpen={fromDropdownOpen}
|
||
|
onSelect={newFrom => this.handleFromChange(newFrom)}
|
||
|
openDropdown={() => openFromDropdown()}
|
||
|
selectedAccount={from}
|
||
7 years ago
|
/>
|
||
|
</SendRowWrapper>
|
||
7 years ago
|
)
|
||
7 years ago
|
}
|
||
|
|
||
|
}
|