balances corrected on transfer screens

This commit is contained in:
feruz 2019-12-06 20:16:05 +02:00
parent f462546f07
commit 5afc3cee22
3 changed files with 43 additions and 41 deletions

View File

@ -201,21 +201,17 @@ const WalletContainer = ({
const _navigate = async (transferType, fundType) => { const _navigate = async (transferType, fundType) => {
let balance; let balance;
switch (fundType) { if (transferType === 'transfer_token' && fundType === 'STEEM') {
case 'STEEM': balance = Math.round(walletData.balance * 1000) / 1000;
balance = Math.round(walletData.balance * 1000) / 1000; }
break; if (transferType === 'transfer_token' && fundType === 'SBD') {
case 'SBD': balance = Math.round(walletData.sbdBalance * 1000) / 1000;
balance = Math.round(walletData.sbdBalance * 1000) / 1000; }
break; if (transferType === 'withdraw_steem' && fundType === 'STEEM') {
case 'SAVING_STEEM': balance = Math.round(walletData.savingBalance * 1000) / 1000;
balance = Math.round(walletData.savingBalance * 1000) / 1000; }
break; if (transferType === 'withdraw_sbd' && fundType === 'SBD') {
case 'SAVING_SBD': balance = Math.round(walletData.savingBalanceSbd * 1000) / 1000;
balance = Math.round(walletData.savingBalanceSbd * 1000) / 1000;
break;
default:
break;
} }
if (isPinCodeOpen) { if (isPinCodeOpen) {

View File

@ -34,6 +34,8 @@ class TransferContainer extends Component {
super(props); super(props);
this.state = { this.state = {
fundType: props.navigation.getParam('fundType', ''), fundType: props.navigation.getParam('fundType', ''),
balance: props.navigation.getParam('balance', ''),
transferType: props.navigation.getParam('transferType', ''),
selectedAccount: props.currentAccount, selectedAccount: props.currentAccount,
}; };
} }
@ -63,33 +65,28 @@ class TransferContainer extends Component {
}; };
fetchBalance = username => { fetchBalance = username => {
const { fundType } = this.state; const { fundType, transferType } = this.state;
getAccount(username).then(async account => { getAccount(username).then(async account => {
let balance; let balance;
switch (fundType) {
case 'STEEM': if (transferType === 'transfer_token' && fundType === 'STEEM') {
balance = account[0].balance.replace(fundType, ''); balance = account[0].balance.replace(fundType, '');
break; }
case 'SBD': if (transferType === 'transfer_token' && fundType === 'SBD') {
balance = account[0].sbd_balance.replace(fundType, ''); balance = account[0].sbd_balance.replace(fundType, '');
break; }
case 'ESTM': if (transferType === 'points' && fundType === 'ESTM') {
this._getUserPointsBalance(username); this._getUserPointsBalance(username);
break; }
case 'SAVING_STEEM': if (transferType === 'transfer_to_saving' && fundType === 'STEEM') {
this.setState({ fundType: 'STEEM' }); balance = account[0].balance.replace(fundType, '');
balance = account[0].savings_balance.replace(' STEEM', ''); }
break; if (transferType === 'transfer_to_saving' && fundType === 'SBD') {
case 'SAVING_SBD': balance = account[0].sbd_balance.replace(fundType, '');
this.setState({ fundType: 'STEEM DOLLAR' }); }
balance = account[0].savings_sbd_balance.replace(' SBD', ''); if (transferType === 'powerUp' && fundType === 'STEEM') {
break; balance = account[0].balance.replace(fundType, '');
case 'STEEM_POWER':
balance = account[0].balance.replace(fundType, '');
break;
default:
break;
} }
const local = await getUserDataWithUsername(username); const local = await getUserDataWithUsername(username);

View File

@ -31,10 +31,19 @@ class TransferView extends Component {
super(props); super(props);
this.state = { this.state = {
from: props.currentAccountName, from: props.currentAccountName,
destination: props.transferType === 'powerUp' ? props.currentAccountName : '', destination:
props.transferType === 'powerUp' ||
props.transferType === 'withdraw_steem' ||
props.transferType === 'withdraw_steem'
? props.currentAccountName
: '',
amount: '', amount: '',
memo: '', memo: '',
isUsernameValid: !!(props.transferType === 'powerUp' && props.currentAccountName), isUsernameValid: !!(
props.transferType === 'powerUp' ||
props.transferType === 'withdraw_steem' ||
(props.transferType === 'withdraw_steem' && props.currentAccountName)
),
steemConnectTransfer: false, steemConnectTransfer: false,
isTransfering: false, isTransfering: false,
}; };