aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-11-16 16:04:52 -0300
committerSebastian <sebasjm@gmail.com>2022-11-16 16:05:13 -0300
commit1a63d56bfdd091cc7aefdf1e25f3a074bfdf5e0e (patch)
tree7255cf4a5b51af4807e2a01a370497413a78968f /packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
parent53164dc47b1138235a0c797affaa6fb37ea43239 (diff)
downloadwallet-core-1a63d56bfdd091cc7aefdf1e25f3a074bfdf5e0e.tar.xz
fix #7411, also making the backup payment visible
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/Withdraw/state.ts')
-rw-r--r--packages/taler-wallet-webextension/src/cta/Withdraw/state.ts63
1 files changed, 39 insertions, 24 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
index 704ef1ac3..016027163 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
@@ -19,7 +19,7 @@ import {
AmountJson,
Amounts,
ExchangeListItem,
- ExchangeTosStatus
+ ExchangeTosStatus,
} from "@gnu-taler/taler-util";
import { TalerError, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { useState } from "preact/hooks";
@@ -35,7 +35,10 @@ export function useComponentStateFromParams(
api: typeof wxApi,
): RecursiveState<State> {
const uriInfoHook = useAsyncAsHook(async () => {
- const exchanges = await api.wallet.call(WalletApiOperation.ListExchanges, {});
+ const exchanges = await api.wallet.call(
+ WalletApiOperation.ListExchanges,
+ {},
+ );
return { amount: Amounts.parseOrThrow(amount), exchanges };
});
@@ -58,11 +61,14 @@ export function useComponentStateFromParams(
transactionId: string;
confirmTransferUrl: string | undefined;
}> {
- const res = await api.wallet.call(WalletApiOperation.AcceptManualWithdrawal, {
- exchangeBaseUrl: exchange,
- amount: Amounts.stringify(chosenAmount),
- restrictAge: ageRestricted,
- });
+ const res = await api.wallet.call(
+ WalletApiOperation.AcceptManualWithdrawal,
+ {
+ exchangeBaseUrl: exchange,
+ amount: Amounts.stringify(chosenAmount),
+ restrictAge: ageRestricted,
+ },
+ );
return {
confirmTransferUrl: undefined,
transactionId: res.transactionId,
@@ -93,9 +99,12 @@ export function useComponentStateFromURI(
const uriInfoHook = useAsyncAsHook(async () => {
if (!talerWithdrawUri) throw Error("ERROR_NO-URI-FOR-WITHDRAWAL");
- const uriInfo = await api.wallet.call(WalletApiOperation.GetWithdrawalDetailsForUri, {
- talerWithdrawUri,
- });
+ const uriInfo = await api.wallet.call(
+ WalletApiOperation.GetWithdrawalDetailsForUri,
+ {
+ talerWithdrawUri,
+ },
+ );
const { amount, defaultExchangeBaseUrl } = uriInfo;
return {
talerWithdrawUri,
@@ -126,11 +135,14 @@ export function useComponentStateFromURI(
transactionId: string;
confirmTransferUrl: string | undefined;
}> {
- const res = await api.wallet.call(WalletApiOperation.AcceptBankIntegratedWithdrawal, {
- exchangeBaseUrl: exchange,
- talerWithdrawUri: uri,
- restrictAge: ageRestricted
- });
+ const res = await api.wallet.call(
+ WalletApiOperation.AcceptBankIntegratedWithdrawal,
+ {
+ exchangeBaseUrl: exchange,
+ talerWithdrawUri: uri,
+ restrictAge: ageRestricted,
+ },
+ );
return {
confirmTransferUrl: res.confirmTransferUrl,
transactionId: res.transactionId,
@@ -189,11 +201,14 @@ function exchangeSelectionState(
* about the withdrawal
*/
const amountHook = useAsyncAsHook(async () => {
- const info = await api.wallet.call(WalletApiOperation.GetWithdrawalDetailsForAmount, {
- exchangeBaseUrl: currentExchange.exchangeBaseUrl,
- amount: Amounts.stringify(chosenAmount),
- restrictAge: ageRestricted,
- });
+ const info = await api.wallet.call(
+ WalletApiOperation.GetWithdrawalDetailsForAmount,
+ {
+ exchangeBaseUrl: currentExchange.exchangeBaseUrl,
+ amount: Amounts.stringify(chosenAmount),
+ restrictAge: ageRestricted,
+ },
+ );
const withdrawAmount = {
raw: Amounts.parseOrThrow(info.amountRaw),
@@ -264,10 +279,10 @@ function exchangeSelectionState(
//TODO: calculate based on exchange info
const ageRestriction = ageRestrictionEnabled
? {
- list: ageRestrictionOptions,
- value: String(ageRestricted),
- onChange: async (v: string) => setAgeRestricted(parseInt(v, 10)),
- }
+ list: ageRestrictionOptions,
+ value: String(ageRestricted),
+ onChange: async (v: string) => setAgeRestricted(parseInt(v, 10)),
+ }
: undefined;
return {