mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 12:51:42 +03:00
Fixed transfer amount issue
This commit is contained in:
parent
fdb2ff95e6
commit
6015b73987
@ -29,22 +29,30 @@ class TransferContainer extends Component {
|
||||
|
||||
// Component Life Cycle Functions
|
||||
componentDidMount() {
|
||||
const { currentAccount: { name }, navigation } = this.props;
|
||||
const { currentAccount: { name } } = this.props;
|
||||
|
||||
const balance = navigation.getParam('balance', '');
|
||||
|
||||
this.setState({ balance });
|
||||
|
||||
|
||||
if (!balance) this.fetchBalance(name);
|
||||
this.fetchBalance(name);
|
||||
}
|
||||
|
||||
// Component Functions
|
||||
|
||||
fetchBalance = (username) => {
|
||||
const { navigation } = this.props;
|
||||
const fundType = navigation.getParam('fundType', '');
|
||||
|
||||
getAccount(username)
|
||||
.then((account) => {
|
||||
const balance = account[0].balance.replace('STEEM', '');
|
||||
let balance;
|
||||
switch (fundType) {
|
||||
case 'STEEM':
|
||||
balance = account[0].balance.replace(fundType, '');
|
||||
break;
|
||||
case 'SBD':
|
||||
balance = account[0].sbd_balance.replace(fundType, '');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
this.setState({ balance: Number(balance) });
|
||||
});
|
||||
@ -108,7 +116,7 @@ class TransferContainer extends Component {
|
||||
|
||||
render() {
|
||||
const {
|
||||
accounts, currentAccount, navigation, fetchBalance,
|
||||
accounts, currentAccount, navigation,
|
||||
} = this.props;
|
||||
const { balance } = this.state;
|
||||
|
||||
@ -123,6 +131,7 @@ class TransferContainer extends Component {
|
||||
transferToAccount={this._transferToAccount}
|
||||
handleOnModalClose={this._handleOnModalClose}
|
||||
accountType={currentAccount.local.authType}
|
||||
currentAccountName={currentAccount.name}
|
||||
balance={balance}
|
||||
fundType={fundType}
|
||||
transferType={transferType}
|
||||
|
@ -101,7 +101,7 @@ class TransferView extends Component {
|
||||
/>
|
||||
);
|
||||
|
||||
_renderDropdown = accounts => (
|
||||
_renderDropdown = (accounts, currentAccountName) => (
|
||||
<DropdownButton
|
||||
dropdownButtonStyle={styles.dropdownButtonStyle}
|
||||
rowTextStyle={styles.rowTextStyle}
|
||||
@ -109,8 +109,8 @@ class TransferView extends Component {
|
||||
dropdownStyle={styles.dropdownStyle}
|
||||
textStyle={styles.dropdownText}
|
||||
options={accounts.map(item => item.username)}
|
||||
defaultText={accounts[0].username}
|
||||
selectedOptionIndex={0}
|
||||
defaultText={currentAccountName}
|
||||
selectedOptionIndex={accounts.findIndex(item => item.username === currentAccountName)}
|
||||
onSelect={(index, value) => this._handleOnDropdownChange(value)}
|
||||
/>
|
||||
);
|
||||
@ -126,7 +126,7 @@ class TransferView extends Component {
|
||||
|
||||
render() {
|
||||
const {
|
||||
accounts, intl, handleOnModalClose, balance, fundType, transferType,
|
||||
accounts, intl, handleOnModalClose, balance, fundType, transferType, currentAccountName,
|
||||
} = this.props;
|
||||
const {
|
||||
destination, isUsernameValid, amount, steemConnectTransfer, memo, isTransfering, from,
|
||||
@ -156,7 +156,7 @@ class TransferView extends Component {
|
||||
<View style={styles.middleContent}>
|
||||
<TransferFormItem
|
||||
label={intl.formatMessage({ id: 'transfer.from' })}
|
||||
rightComponent={() => this._renderDropdown(accounts)}
|
||||
rightComponent={() => this._renderDropdown(accounts, currentAccountName)}
|
||||
/>
|
||||
<TransferFormItem
|
||||
label={intl.formatMessage({ id: 'transfer.to' })}
|
||||
@ -211,7 +211,7 @@ class TransferView extends Component {
|
||||
onPress={() => this.ActionSheet.show()}
|
||||
isLoading={isTransfering}
|
||||
>
|
||||
<Text style={styles.buttonText}>NEXT</Text>
|
||||
<Text style={styles.buttonText}>{intl.formatMessage({ id: 'transfer.next' })}</Text>
|
||||
</MainButton>
|
||||
</View>
|
||||
</ScrollView>
|
||||
|
Loading…
Reference in New Issue
Block a user