Added loading state to set hook modal

This commit is contained in:
Valtteri Karesto
2022-03-23 13:28:59 +02:00
parent 50fa20c39a
commit 81890c8833

View File

@@ -74,8 +74,15 @@ export const SetHookDialog: React.FC<{ account: IAccount }> = ({ account }) => {
if (!account) { if (!account) {
return null; return null;
} }
const onSubmit: SubmitHandler<SetHookData> = async (data) => { const onSubmit: SubmitHandler<SetHookData> = async (data) => {
const currAccount = state.accounts.find(
(acc) => acc.address === account.address
);
if (currAccount) currAccount.isLoading = true;
const res = await deployHook(account, data); const res = await deployHook(account, data);
if (currAccount) currAccount.isLoading = false;
if (res && res.engine_result === "tesSUCCESS") { if (res && res.engine_result === "tesSUCCESS") {
toast.success("Transaction succeeded!"); toast.success("Transaction succeeded!");
return setIsSetHookDialogOpen(false); return setIsSetHookDialogOpen(false);
@@ -227,7 +234,11 @@ export const SetHookDialog: React.FC<{ account: IAccount }> = ({ account }) => {
<Button outline>Cancel</Button> <Button outline>Cancel</Button>
</DialogClose> </DialogClose>
{/* <DialogClose asChild> */} {/* <DialogClose asChild> */}
<Button variant="primary" type="submit"> <Button
variant="primary"
type="submit"
isLoading={account.isLoading}
>
Set Hook Set Hook
</Button> </Button>
{/* </DialogClose> */} {/* </DialogClose> */}