diff options
author | Sebastian <sebasjm@gmail.com> | 2022-11-16 16:04:52 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-11-16 16:05:13 -0300 |
commit | 1a63d56bfdd091cc7aefdf1e25f3a074bfdf5e0e (patch) | |
tree | 7255cf4a5b51af4807e2a01a370497413a78968f /packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts | |
parent | 53164dc47b1138235a0c797affaa6fb37ea43239 (diff) | |
download | wallet-core-1a63d56bfdd091cc7aefdf1e25f3a074bfdf5e0e.tar.xz |
fix #7411, also making the backup payment visible
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts b/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts index d8b752d44..91883c823 100644 --- a/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts +++ b/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts @@ -21,7 +21,7 @@ import { KnownBankAccountsInfo, parsePaytoUri, PaytoUri, - stringifyPaytoUri + stringifyPaytoUri, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { useState } from "preact/hooks"; @@ -37,10 +37,16 @@ export function useComponentState( const currency = parsed !== undefined ? parsed.currency : currencyStr; const hook = useAsyncAsHook(async () => { - const { balances } = await api.wallet.call(WalletApiOperation.GetBalances, {}); - const { accounts } = await api.wallet.call(WalletApiOperation.ListKnownBankAccounts, { - currency - }); + const { balances } = await api.wallet.call( + WalletApiOperation.GetBalances, + {}, + ); + const { accounts } = await api.wallet.call( + WalletApiOperation.ListKnownBankAccounts, + { + currency, + }, + ); return { accounts, balances }; }); @@ -120,13 +126,13 @@ export function useComponentState( }, }; } - const firstAccount = accounts[0].uri + const firstAccount = accounts[0].uri; const currentAccount = !selectedAccount ? firstAccount : selectedAccount; if (fee === undefined && parsedAmount) { - getFeeForAmount(currentAccount, parsedAmount, api).then(initialFee => { - setFee(initialFee) - }) + getFeeForAmount(currentAccount, parsedAmount, api).then((initialFee) => { + setFee(initialFee); + }); return { status: "loading", error: undefined, @@ -177,10 +183,10 @@ export function useComponentState( const amountError = !isDirty ? undefined : !parsedAmount - ? "Invalid amount" - : Amounts.cmp(balance, parsedAmount) === -1 - ? `Too much, your current balance is ${Amounts.stringifyValue(balance)}` - : undefined; + ? "Invalid amount" + : Amounts.cmp(balance, parsedAmount) === -1 + ? `Too much, your current balance is ${Amounts.stringifyValue(balance)}` + : undefined; const unableToDeposit = !parsedAmount || //no amount specified @@ -194,8 +200,9 @@ export function useComponentState( const depositPaytoUri = stringifyPaytoUri(currentAccount); const amount = Amounts.stringify(parsedAmount); await api.wallet.call(WalletApiOperation.CreateDepositGroup, { - amount, depositPaytoUri - }) + amount, + depositPaytoUri, + }); onSuccess(currency); } @@ -242,8 +249,9 @@ async function getFeeForAmount( const depositPaytoUri = `payto://${p.targetType}/${p.targetPath}`; const amount = Amounts.stringify(a); return await api.wallet.call(WalletApiOperation.GetFeeForDeposit, { - amount, depositPaytoUri - }) + amount, + depositPaytoUri, + }); } export function labelForAccountType(id: string) { |