Skip to content

Commit

Permalink
fix: disable refund button while transaction is being created (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 authored Jan 23, 2024
1 parent 0381ff9 commit 9d5f7ea
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/RefundButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const RefundButton = ({ swap }: { swap: Accessor<Record<string, any>> }) => {
setRefundTx,
t,
} = useGlobalContext();

if (swap() && swap().asset === RBTC) {
const { getEtherSwap } = useWeb3Signer();

Expand Down Expand Up @@ -51,6 +52,7 @@ const RefundButton = ({ swap }: { swap: Accessor<Record<string, any>> }) => {
);
}

const [refundRunning, setRefundRunning] = createSignal<boolean>(false);
const [valid, setValid] = createSignal<boolean>(false);

const refundAddressChange = (evt: InputEvent, asset: string) => {
Expand All @@ -73,6 +75,8 @@ const RefundButton = ({ swap }: { swap: Accessor<Record<string, any>> }) => {
};

const refundAction = async () => {
setRefundRunning(true);

try {
const transactionToRefund = await fetcher(
"/getswaptransaction",
Expand Down Expand Up @@ -133,6 +137,8 @@ const RefundButton = ({ swap }: { swap: Accessor<Record<string, any>> }) => {
setNotification(error.message);
}
}

setRefundRunning(false);
};

return (
Expand All @@ -149,7 +155,7 @@ const RefundButton = ({ swap }: { swap: Accessor<Record<string, any>> }) => {
<button
data-testid="refundButton"
class="btn"
disabled={!valid()}
disabled={!valid() || refundRunning()}
onclick={() => refundAction()}>
{t("refund")}
</button>
Expand Down

1 comment on commit 9d5f7ea

@vercel
Copy link

@vercel vercel bot commented on 9d5f7ea Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.