Browse Source

Use form and form submit for better handling

debug-collab-settlement
bonomat 3 years ago
parent
commit
cebe3c0336
No known key found for this signature in database GPG Key ID: E5F8E74C672BC666
  1. 6
      taker-frontend/src/components/Wallet.tsx

6
taker-frontend/src/components/Wallet.tsx

@ -24,7 +24,7 @@ import {
VStack,
} from "@chakra-ui/react";
import * as React from "react";
import { useState } from "react";
import { FormEvent, useState } from "react";
import { useAsync } from "react-async";
import { useNavigate } from "react-router-dom";
import { postWithdraw } from "../App";
@ -50,7 +50,8 @@ export default function Wallet(
const [withdrawAddress, setWithdrawAddress] = useState("");
let { run: runWithdraw, isLoading: isWithdrawing } = useAsync({
deferFn: async () => {
deferFn: async ([event]: FormEvent<HTMLFormElement>[]) => {
event.preventDefault();
try {
const url = await postWithdraw({
amount: withdrawAmount,
@ -68,7 +69,6 @@ export default function Wallet(
isClosable: true,
});
} catch (e) {
console.log(`Caught an error: ${e}`);
createErrorToast(toast, e);
}
},

Loading…
Cancel
Save