From b95b178dd82a58178ac28d208f5d85458dcc9abf Mon Sep 17 00:00:00 2001 From: binarybaron Date: Mon, 9 Sep 2024 21:47:52 +0200 Subject: [PATCH] refactor(gui): Make WithdrawDialog logic explicit --- .../modal/wallet/WithdrawDialog.tsx | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src-gui/src/renderer/components/modal/wallet/WithdrawDialog.tsx b/src-gui/src/renderer/components/modal/wallet/WithdrawDialog.tsx index 4ff1cbbd..317e644d 100644 --- a/src-gui/src/renderer/components/modal/wallet/WithdrawDialog.tsx +++ b/src-gui/src/renderer/components/modal/wallet/WithdrawDialog.tsx @@ -19,6 +19,8 @@ export default function WithdrawDialog({ const [withdrawAddressValid, setWithdrawAddressValid] = useState(false); const [withdrawAddress, setWithdrawAddress] = useState(""); + const haveFundsBeenWithdrawn = withdrawTxId !== null; + function onCancel() { if (!pending) { setWithdrawTxId(null); @@ -31,34 +33,34 @@ export default function WithdrawDialog({ - {withdrawTxId === null ? ( + {haveFundsBeenWithdrawn ? ( + + ) : ( - ) : ( - )} - - {withdrawTxId === null && ( + {!haveFundsBeenWithdrawn && ( withdrawBtc(withdrawAddress)} - onPendingChange={(pending) => { - console.log("pending", pending); - setPending(pending); - }} - onSuccess={(txId) => { - setWithdrawTxId(txId); - }} + onPendingChange={setPending} + onSuccess={setWithdrawTxId} > Withdraw