From 4d66f774c3ad4040f522d2ec52b5b4c2edd2b478 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 11 Mar 2022 02:17:40 -0300 Subject: pending operations --- .../src/popup/BalancePage.tsx | 30 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'packages/taler-wallet-webextension/src/popup') diff --git a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx index d7bfdf545..199ff10df 100644 --- a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx +++ b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx @@ -14,7 +14,13 @@ TALER; see the file COPYING. If not, see */ -import { Amounts, Balance, i18n } from "@gnu-taler/taler-util"; +import { + Amounts, + Balance, + i18n, + NotificationType, + Transaction, +} from "@gnu-taler/taler-util"; import { Fragment, h, VNode } from "preact"; import { useState } from "preact/hooks"; import { BalanceTable } from "../components/BalanceTable"; @@ -22,6 +28,7 @@ import { JustInDevMode } from "../components/JustInDevMode"; import { Loading } from "../components/Loading"; import { LoadingError } from "../components/LoadingError"; import { MultiActionButton } from "../components/MultiActionButton"; +import PendingTransactions from "../components/PendingTransactions"; import { ButtonBoxPrimary, ButtonPrimary } from "../components/styled"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook"; import { AddNewActionView } from "../wallet/AddNewActionView"; @@ -39,8 +46,19 @@ export function BalancePage({ goToWalletHistory, }: Props): VNode { const [addingAction, setAddingAction] = useState(false); - const state = useAsyncAsHook(wxApi.getBalance); - const balances = !state || state.hasError ? [] : state.response.balances; + const state = useAsyncAsHook( + async () => ({ + balance: await wxApi.getBalance(), + pending: await wxApi.getTransactions(), + }), + [NotificationType.WithdrawGroupFinished], + ); + const balances = + !state || state.hasError ? [] : state.response.balance.balances; + const pending = + !state || state.hasError + ? [] + : state.response.pending.transactions.filter((t) => t.pending); if (!state) { return ; @@ -62,6 +80,7 @@ export function BalancePage({ return ( void; goToAddAction: () => void; goToWalletDeposit: (currency: string) => void; @@ -79,6 +99,7 @@ export interface BalanceViewProps { export function BalanceView({ balances, + pending, goToWalletManualWithdraw, goToWalletDeposit, goToWalletHistory, @@ -96,6 +117,9 @@ export function BalanceView({ return ( + {pending.length > 0 ? ( + + ) : undefined}