diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta')
-rw-r--r-- | packages/taler-wallet-webextension/src/cta/Pay.tsx | 2 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/cta/Withdraw.tsx | 60 |
2 files changed, 29 insertions, 33 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Pay.tsx b/packages/taler-wallet-webextension/src/cta/Pay.tsx index 832b4879c..9b7f7862f 100644 --- a/packages/taler-wallet-webextension/src/cta/Pay.tsx +++ b/packages/taler-wallet-webextension/src/cta/Pay.tsx @@ -181,7 +181,7 @@ export function useComponentState( if (typeof window !== "undefined") { document.location.href = fu; } else { - console.log(`should redirect to ${fu}`); + console.log(`should d to ${fu}`); } } setPayResult(res); diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx index 21f98ec9a..56c64a6d7 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx +++ b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx @@ -40,7 +40,11 @@ import { WalletAction, } from "../components/styled/index.js"; import { useTranslationContext } from "../context/translation.js"; -import { HookError, useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; +import { + HookError, + useAsyncAsHook, + useAsyncAsHook2, +} from "../hooks/useAsyncAsHook.js"; import { buildTermsOfServiceState } from "../utils/index.js"; import { ButtonHandler, SelectFieldHandler } from "../mui/handlers.js"; import * as wxApi from "../wxApi.js"; @@ -99,7 +103,7 @@ export function useComponentState( /** * Ask the wallet about the withdraw URI */ - const uriInfoHook = useAsyncAsHook(async () => { + const uriInfoHook = useAsyncAsHook2(async () => { if (!talerWithdrawUri) throw Error("ERROR_NO-URI-FOR-WITHDRAWAL"); const uriInfo = await api.getWithdrawalDetailsForUri({ @@ -147,44 +151,36 @@ export function useComponentState( /** * For the exchange selected, bring the status of the terms of service */ - const terms = useAsyncAsHook( - async () => { - if (!thisExchange) return false; + const terms = useAsyncAsHook2(async () => { + if (!thisExchange) return false; - const exchangeTos = await api.getExchangeTos(thisExchange, ["text/xml"]); + const exchangeTos = await api.getExchangeTos(thisExchange, ["text/xml"]); - const state = buildTermsOfServiceState(exchangeTos); + const state = buildTermsOfServiceState(exchangeTos); - return { state }; - }, - [], - [thisExchange], - ); + return { state }; + }, [thisExchange]); /** * With the exchange and amount, ask the wallet the information * about the withdrawal */ - const info = useAsyncAsHook( - async () => { - if (!thisExchange || !amount) return false; - - const info = await api.getExchangeWithdrawalInfo({ - exchangeBaseUrl: thisExchange, - amount, - tosAcceptedFormat: ["text/xml"], - }); - - const withdrawalFee = Amounts.sub( - Amounts.parseOrThrow(info.withdrawalAmountRaw), - Amounts.parseOrThrow(info.withdrawalAmountEffective), - ).amount; - - return { info, withdrawalFee }; - }, - [], - [thisExchange, amount], - ); + const info = useAsyncAsHook2(async () => { + if (!thisExchange || !amount) return false; + + const info = await api.getExchangeWithdrawalInfo({ + exchangeBaseUrl: thisExchange, + amount, + tosAcceptedFormat: ["text/xml"], + }); + + const withdrawalFee = Amounts.sub( + Amounts.parseOrThrow(info.withdrawalAmountRaw), + Amounts.parseOrThrow(info.withdrawalAmountEffective), + ).amount; + + return { info, withdrawalFee }; + }, [thisExchange, amount]); const [reviewing, setReviewing] = useState<boolean>(false); const [reviewed, setReviewed] = useState<boolean>(false); |