diff options
author | Sebastian <sebasjm@gmail.com> | 2024-10-01 12:25:38 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-10-01 12:25:38 -0300 |
commit | 8fb629a7d478292397768ec900f0c00ab4479485 (patch) | |
tree | f9a45564f1eb2f142fd5d122db46ffab573c125c /packages/taler-wallet-webextension/src/cta | |
parent | 98bfd3f4f9c9229f84edab1a48a0ad670279446e (diff) | |
download | wallet-core-8fb629a7d478292397768ec900f0c00ab4479485.tar.xz |
fix manual withdrawal
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta')
-rw-r--r-- | packages/taler-wallet-webextension/src/cta/Withdraw/index.ts | 4 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/cta/Withdraw/state.ts | 24 |
2 files changed, 20 insertions, 8 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts index 91bde9369..8d4ad0bde 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts @@ -47,8 +47,8 @@ export interface PropsFromURI { export interface PropsFromParams { talerExchangeWithdrawUri: string | undefined; - scope: ScopeInfo; - amount: string | undefined; + scope: ScopeInfo | undefined; + amount: AmountJson | undefined; cancel: () => Promise<void>; onSuccess: (txid: string) => Promise<void>; } diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts index 8a862d200..232bfe9e2 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts @@ -37,14 +37,14 @@ import { PropsFromParams, PropsFromURI, State } from "./index.js"; export function useComponentStateFromParams({ talerExchangeWithdrawUri: maybeTalerUri, - amount, scope, + amount: paramsAmount, cancel, onSuccess, }: PropsFromParams): RecursiveState<State> { const api = useBackendContext(); const { i18n } = useTranslationContext(); - const paramsAmount = amount ? Amounts.parse(amount) : undefined; + // const paramsAmount = amount ? Amounts.parse(amount) : undefined; const [updatedExchangeByUser, setUpdatedExchangeByUser] = useState<string>(); const uriInfoHook = useAsyncAsHook(async () => { const exchanges = await api.wallet.call( @@ -75,6 +75,10 @@ export function useComponentStateFromParams({ return { amount: chosenAmount, exchanges, exchange: ex }; }); + useEffect(() => { + uriInfoHook?.retry(); + }, [paramsAmount]); + if (!uriInfoHook) return { status: "loading", error: undefined }; if (uriInfoHook.hasError) { @@ -88,14 +92,22 @@ export function useComponentStateFromParams({ }; } - useEffect(() => { - uriInfoHook?.retry(); - }, [amount]); + const currency = uriInfoHook.response.exchange?.currency ?? scope?.currency; const exchangeByTalerUri = uriInfoHook.response.exchange?.exchangeBaseUrl; const exchangeList = uriInfoHook.response.exchanges.exchanges; const maybeAmount = uriInfoHook.response.amount ?? paramsAmount; + if (!currency) { + return { + status: "error", + error: alertFromError( + i18n, + i18n.str`Could not load the list of exchanges`, + {} as any, + ), + }; + } // if (!maybeAmount) { // const exchangeBaseUrl = @@ -156,7 +168,7 @@ export function useComponentStateFromParams({ // }; // }; // } - const chosenAmount = maybeAmount ?? Amounts.zeroOfCurrency(scope.currency); + const chosenAmount = maybeAmount ?? Amounts.zeroOfCurrency(currency); async function doManualWithdraw( exchange: string, |