From 29942b1f5463f990fceab7fce8dcedeb6dcf1128 Mon Sep 17 00:00:00 2001 From: Miika Turunen Date: Mon, 18 Sep 2017 22:32:25 +0300 Subject: [PATCH] AGP-215, Read invoice payload --- .../components/dashboard/qrModal/qrModal.js | 2 ++ .../components/dashboard/sendCoin/sendCoin.js | 27 ++++++++++++++++--- .../walletsNativeSend/walletsNativeSend.js | 26 +++++++++++++++--- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/react/src/components/dashboard/qrModal/qrModal.js b/react/src/components/dashboard/qrModal/qrModal.js index c1a5757..0324e57 100755 --- a/react/src/components/dashboard/qrModal/qrModal.js +++ b/react/src/components/dashboard/qrModal/qrModal.js @@ -68,6 +68,8 @@ class QRModal extends React.Component { modalIsOpen: false, errorShown: this.state.error ? true : false, }); + + ReactDOM.unmountComponentAtNode(document.getElementById('webcam')); } render() { diff --git a/react/src/components/dashboard/sendCoin/sendCoin.js b/react/src/components/dashboard/sendCoin/sendCoin.js index 4d3ce8b..8bd3fcf 100644 --- a/react/src/components/dashboard/sendCoin/sendCoin.js +++ b/react/src/components/dashboard/sendCoin/sendCoin.js @@ -67,10 +67,29 @@ class SendCoin extends React.Component { } setRecieverFromScan(receiver) { - this.setState({ - sendTo: receiver - }); - + try { + var o = JSON.parse(receiver); + if (o && typeof o === "object") { + if(o.coin === this.props.ActiveCoin.coin) { + if(o.amount) { + this.setState({ + amount: o.amount + }); + } + if(o.address) { + this.setState({ + sendTo: o.address + }); + } + } + } + } + catch (e) { + this.setState({ + sendTo: receiver + }); + } + document.getElementById('edexcoinSendTo').focus(); } diff --git a/react/src/components/dashboard/walletsNativeSend/walletsNativeSend.js b/react/src/components/dashboard/walletsNativeSend/walletsNativeSend.js index 7efbcf0..3ee55ba 100644 --- a/react/src/components/dashboard/walletsNativeSend/walletsNativeSend.js +++ b/react/src/components/dashboard/walletsNativeSend/walletsNativeSend.js @@ -81,10 +81,28 @@ class WalletsNativeSend extends React.Component { } setRecieverFromScan(receiver) { - this.setState({ - sendTo: receiver, - }); - + try { + var o = JSON.parse(receiver); + if (o && typeof o === "object") { + if(o.coin === this.props.ActiveCoin.coin) { + if(o.amount) { + this.setState({ + amount: o.amount + }); + } + if(o.address) { + this.setState({ + sendTo: o.address + }); + } + } + } + } + catch (e) { + this.setState({ + sendTo: receiver + }); + } document.getElementById('kmdWalletSendTo').focus(); }