diff --git a/src/components/Payment.jsx b/src/components/Payment.jsx index 6567bdf09..31fb113a0 100644 --- a/src/components/Payment.jsx +++ b/src/components/Payment.jsx @@ -10,7 +10,7 @@ export default function Payment({ currentWallet }) { const [alert, setAlert] = useState(null) const [isSending, setIsSending] = useState(false) const [isCoinjoin, setIsCoinjoin] = useState(false) - const [account, setAccount] = useState(location.state?.account || 0) + const [account, setAccount] = useState(parseInt(location.state?.account, 10) || 0) const sendPayment = async (account, destination, amount_sats) => { const { name, token } = currentWallet @@ -18,7 +18,7 @@ export default function Payment({ currentWallet }) { method: 'POST', headers: { 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ - mixdepth: account, + mixdepth: String(account), destination, amount_sats }) @@ -53,7 +53,7 @@ export default function Payment({ currentWallet }) { method: 'POST', headers: { 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ - mixdepth: account, + mixdepth: String(account), destination, amount_sats, counterparties @@ -91,7 +91,7 @@ export default function Payment({ currentWallet }) { setValidated(true) if (isValid) { - const { account, amount, counterparties, destination } = serialize(form) + const { amount, counterparties, destination } = serialize(form) const success = isCoinjoin ? await startCoinjoin(account, destination, amount, counterparties) : await sendPayment(account, destination, amount) @@ -115,13 +115,14 @@ export default function Payment({ currentWallet }) { Account - setAccount(parseInt(e.target.value, 10))} style={{ width: '15ch' }} required /> - Please provide an account between {ACCOUNTS[0]} and {ACCOUNTS[4]}. + setAccount(parseInt(e.target.value, 10))} style={{ maxWidth: '21ch' }} required> + {ACCOUNTS.map(val => )} + Amount in Sats - - Please provide a receiving address. + + Please provide a valid amount. setIsCoinjoin(e.target.checked)} /> diff --git a/src/components/Receive.jsx b/src/components/Receive.jsx index c969a0d81..d76cebffc 100644 --- a/src/components/Receive.jsx +++ b/src/components/Receive.jsx @@ -12,7 +12,7 @@ const Receive = ({ currentWallet }) => { const [isLoading, setIsLoading] = useState(false) const [address, setAddress] = useState('') const [amount, setAmount] = useState(0) - const [account, setAccount] = useState(location.state?.account || 0) + const [account, setAccount] = useState(parseInt(location.state?.account, 10) || 0) const [addressCount, setAddressCount] = useState(0) useEffect(() => { @@ -37,7 +37,10 @@ const Receive = ({ currentWallet }) => { .finally(() => setIsLoading(false)) } - if (ACCOUNTS.includes(account)) fetchAddress(account) + + if (ACCOUNTS.includes(account)) { + fetchAddress(account) + } return () => abortCtrl.abort() }, [account, currentWallet, addressCount]) @@ -69,13 +72,14 @@ const Receive = ({ currentWallet }) => { )} Account - setAccount(parseInt(e.target.value, 10))} style={{ width: '10ch' }} required /> - Please provide an account between {ACCOUNTS[0]} and {ACCOUNTS[4]}. + setAccount(parseInt(e.target.value, 10))} style={{ maxWidth: '21ch' }} required> + {ACCOUNTS.map(val => )} + Amount in Sats setAmount(e.target.value)} style={{ width: '21ch' }} /> - Please provide a receiving address. + Please provide a valid amount. Address