diff --git a/src/components/admin-lte/tokens/index.js b/src/components/admin-lte/tokens/index.js
index 6e0be56..6af3097 100644
--- a/src/components/admin-lte/tokens/index.js
+++ b/src/components/admin-lte/tokens/index.js
@@ -28,6 +28,19 @@ class Tokens extends React.Component {
return (
<>
+ {_this.state.showForm && (
+
{_this.state.errMsg}
)} {_this.state.txId && ( -Transaction ID: {_this.state.txId}
++ Transaction ID: + + {_this.state.txId} + +
)} {name && ( @@ -113,11 +123,15 @@ class SendTokens extends React.Component { async handleSend () { try { + _this.setState({ + txId: '', + inFetch: true + }) _this.validateInputs() const bchWalletLib = _this.props.bchWallet const { address, amountSat } = _this.state - const { tokenId } = _this.props.selectedToken + const { tokenId, qty } = _this.props.selectedToken if (!tokenId) { throw new Error('There is no token selected') @@ -127,7 +141,9 @@ class SendTokens extends React.Component { tokenId, qty: Math.floor(Number(amountSat)) } - + if (qty < receiver.qty) { + throw new Error('Insufficient balance') + } // console.log('receiver', receiver) if (!bchWalletLib) { @@ -148,10 +164,14 @@ class SendTokens extends React.Component { // console.log('result: ', result) _this.setState({ - txId: result + txId: result, + inFetch: false }) _this.resetValues() + setTimeout(() => { + _this.props.handleSend() + }, 1000) } catch (error) { let errMsg if (error.message) { @@ -163,7 +183,8 @@ class SendTokens extends React.Component { return { ...prevState, errMsg, - txId: '' + txId: '', + inFetch: false } }) } @@ -267,6 +288,7 @@ SendTokens.propTypes = { walletInfo: PropTypes.object.isRequired, // wallet info bchWallet: PropTypes.object, // get minimal-slp-wallet instance selectedToken: PropTypes.object, - handleBack: PropTypes.func.isRequired + handleBack: PropTypes.func.isRequired, + handleSend: PropTypes.func.isRequired } export default SendTokens