summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts')
-rw-r--r--packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts33
1 files changed, 21 insertions, 12 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts b/packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts
index e42b1dbf9..a5d44e872 100644
--- a/packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts
+++ b/packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts
@@ -14,14 +14,14 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { Amounts, TransactionType } from "@gnu-taler/taler-util";
+import { Amounts } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
-import { useEffect, useState } from "preact/hooks";
+import { useTranslationContext } from "@gnu-taler/web-util/browser";
+import { useState } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js";
-import { useTranslationContext } from "@gnu-taler/web-util/browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
-import { assertUnreachable, RecursiveState } from "../../utils/index.js";
+import { RecursiveState, assertUnreachable } from "../../utils/index.js";
import { Contact, Props, State } from "./index.js";
export function useComponentState(props: Props): RecursiveState<State> {
@@ -130,13 +130,16 @@ export function useComponentState(props: Props): RecursiveState<State> {
props.goToWalletBankDeposit(currencyAndAmount);
}),
},
- sendAll: {
- onClick:
- info === undefined
- ? undefined
- : pushAlertOnError(async () => {
- setAmount(info.balance.balanceMerchantDepositable);
- }),
+ selectMax: {
+ onClick: pushAlertOnError(async () => {
+ const resp = await api.wallet.call(
+ WalletApiOperation.GetMaxDepositAmount,
+ {
+ currency: amount.currency,
+ },
+ );
+ setAmount(Amounts.parseOrThrow(resp.effectiveAmount));
+ }),
},
goToWallet: {
onClick: invalid
@@ -161,7 +164,13 @@ export function useComponentState(props: Props): RecursiveState<State> {
setAmount(undefined);
}),
},
- sendAll: {},
+ selectMax: {
+ onClick: invalid
+ ? undefined
+ : pushAlertOnError(async () => {
+ props.goToWalletManualWithdraw(currencyAndAmount);
+ }),
+ },
goToBank: {
onClick: invalid
? undefined