diff --git a/src/App.tsx b/src/App.tsx index 899d0c4..7c5f3a1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -126,6 +126,7 @@ import { handleGetFileFromIndexedDB } from "./utils/indexedDB"; import { Wallets } from "./Wallets"; import { useHandleTutorials } from "./components/Tutorials/useHandleTutorials"; import { Tutorials } from "./components/Tutorials/Tutorials"; +import BoundedNumericTextField from "./common/BoundedNumericTextField"; type extStates = @@ -745,41 +746,52 @@ function App() { setLtcBalanceLoading(false); }); }; - const sendCoinFunc = () => { - setSendPaymentError(""); - setSendPaymentSuccess(""); - if (!paymentTo) { - setSendPaymentError("Please enter a recipient"); - return; - } - if (!paymentAmount) { - setSendPaymentError("Please enter an amount greater than 0"); - return; - } - if (!paymentPassword) { - setSendPaymentError("Please enter your wallet password"); - return; - } - setIsLoading(true); - window - .sendMessage("sendCoin", { - amount: Number(paymentAmount), - receiver: paymentTo.trim(), - password: paymentPassword, + const sendCoinFunc = async() => { + try { + setSendPaymentError(""); + setSendPaymentSuccess(""); + if (!paymentTo) { + setSendPaymentError("Please enter a recipient"); + return; + } + if (!paymentAmount) { + setSendPaymentError("Please enter an amount greater than 0"); + return; + } + if (!paymentPassword) { + setSendPaymentError("Please enter your wallet password"); + return; + } + const fee = await getFee('PAYMENT') + + await show({ + message: `Would you like to transfer ${Number(paymentAmount)} QORT?` , + paymentFee: fee.fee + ' QORT' }) - .then((response) => { - if (response?.error) { - setSendPaymentError(response.error); - } else { - setIsOpenSendQort(false); - setIsOpenSendQortSuccess(true); - } - setIsLoading(false); - }) - .catch((error) => { - console.error("Failed to send coin:", error); - setIsLoading(false); - }); + setIsLoading(true); + window + .sendMessage("sendCoin", { + amount: Number(paymentAmount), + receiver: paymentTo.trim(), + password: paymentPassword, + }) + .then((response) => { + if (response?.error) { + setSendPaymentError(response.error); + } else { + setIsOpenSendQort(false); + setIsOpenSendQortSuccess(true); + } + setIsLoading(false); + }) + .catch((error) => { + console.error("Failed to send coin:", error); + setIsLoading(false); + }); + } catch (error) { + //error + } + }; const clearAllStates = () => { @@ -1854,12 +1866,14 @@ console.log('openTutorialModal3', openTutorialModal) Amount - setPaymentAmount(+e.target.value)} - autoComplete="off" + minValue={0} + maxValue={+balance} + allowDecimals={true} + initialValue={'0'} + allowNegatives={false} + afterChange={(e: string) => setPaymentAmount(+e)} /> @@ -2895,14 +2909,21 @@ await showInfo({ aria-labelledby="alert-dialog-title" aria-describedby="alert-dialog-description" > - {"Publish"} + {message.paymentFee ? "Payment" : "Publish"} {message.message} - - publish fee: {message.publishFee} - + {message?.paymentFee && ( + + payment fee: {message.paymentFee} + + )} + {message?.publishFee && ( + + publish fee: {message.publishFee} + + )} : } + {canViewPassword ? : } ) }}