From c13f3cf1cd491dfd6371c34e1979a32b3cfe1370 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 25 Jan 2022 10:29:29 -0300 Subject: fix #7162 --- .../src/NavigationBar.tsx | 2 +- packages/taler-wallet-webextension/src/cta/Tip.tsx | 3 +- .../src/popupEntryPoint.tsx | 7 ---- .../src/wallet/ManualWithdrawPage.tsx | 12 +++--- .../src/wallet/ReserveCreated.tsx | 6 +-- .../src/wallet/Transaction.tsx | 48 +++++++++------------- .../src/walletEntryPoint.tsx | 24 ++++++++--- 7 files changed, 51 insertions(+), 51 deletions(-) (limited to 'packages/taler-wallet-webextension') diff --git a/packages/taler-wallet-webextension/src/NavigationBar.tsx b/packages/taler-wallet-webextension/src/NavigationBar.tsx index c16bcb53b..9aaeb0d18 100644 --- a/packages/taler-wallet-webextension/src/NavigationBar.tsx +++ b/packages/taler-wallet-webextension/src/NavigationBar.tsx @@ -32,7 +32,7 @@ export enum Pages { welcome = "/welcome", balance = "/balance", - balance_history = "/balance/history/:currency", + balance_history = "/balance/history/:currency?", balance_manual_withdraw = "/balance/manual-withdraw/:currency?", balance_deposit = "/balance/deposit/:currency", balance_transaction = "/balance/transaction/:tid", diff --git a/packages/taler-wallet-webextension/src/cta/Tip.tsx b/packages/taler-wallet-webextension/src/cta/Tip.tsx index 5a9ab720d..3f8b09bd1 100644 --- a/packages/taler-wallet-webextension/src/cta/Tip.tsx +++ b/packages/taler-wallet-webextension/src/cta/Tip.tsx @@ -23,6 +23,7 @@ import { PrepareTipResult } from "@gnu-taler/taler-util"; import { h, VNode } from "preact"; import { useEffect, useState } from "preact/hooks"; +import { Loading } from "../components/Loading"; import { AmountView } from "../renderHtml"; import * as wxApi from "../wxApi"; @@ -105,7 +106,7 @@ export function TipPage({ talerTipUri }: Props): VNode { } if (!prepareTipResult) { - return Loading ...; + return ; } return ( diff --git a/packages/taler-wallet-webextension/src/popupEntryPoint.tsx b/packages/taler-wallet-webextension/src/popupEntryPoint.tsx index 5169c8540..80e67f881 100644 --- a/packages/taler-wallet-webextension/src/popupEntryPoint.tsx +++ b/packages/taler-wallet-webextension/src/popupEntryPoint.tsx @@ -127,13 +127,6 @@ function Application(): VNode { - - goToWalletPage(Pages.balance_transaction.replace(":tid", tid)) - } - /> - void; +} + +export function ManualWithdrawPage({ currency, onCancel }: Props): VNode { const [success, setSuccess] = useState< | { response: AcceptManualWithdrawalResult; @@ -80,9 +84,7 @@ export function ManualWithdrawPage({ currency }: { currency?: string }): VNode { payto={success.response.exchangePaytoUris[0]} exchangeBaseUrl={success.exchangeBaseUrl} amount={success.amount} - onBack={() => { - route(Pages.balance); - }} + onCancel={onCancel} /> ); } diff --git a/packages/taler-wallet-webextension/src/wallet/ReserveCreated.tsx b/packages/taler-wallet-webextension/src/wallet/ReserveCreated.tsx index ae820d8fe..7ccef2daa 100644 --- a/packages/taler-wallet-webextension/src/wallet/ReserveCreated.tsx +++ b/packages/taler-wallet-webextension/src/wallet/ReserveCreated.tsx @@ -9,13 +9,13 @@ export interface Props { payto: string; exchangeBaseUrl: string; amount: AmountJson; - onBack: () => void; + onCancel: () => void; } export function ReserveCreated({ reservePub, payto, - onBack, + onCancel, exchangeBaseUrl, amount, }: Props): VNode { @@ -55,7 +55,7 @@ export function ReserveCreated({
- + Cancel withdrawal
diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx index 21bfc943d..423a641a3 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx @@ -26,11 +26,12 @@ import { } from "@gnu-taler/taler-util"; import { differenceInSeconds } from "date-fns"; import { ComponentChildren, Fragment, h, VNode } from "preact"; -import { route } from "preact-router"; import { useState } from "preact/hooks"; import emptyImg from "../../static/img/empty.png"; import { BankDetailsByPaytoType } from "../components/BankDetailsByPaytoType"; import { ErrorTalerOperation } from "../components/ErrorTalerOperation"; +import { Loading } from "../components/Loading"; +import { LoadingError } from "../components/LoadingError"; import { Part } from "../components/Part"; import { Button, @@ -49,7 +50,11 @@ import { useAsyncAsHook } from "../hooks/useAsyncAsHook"; import { Pages } from "../NavigationBar"; import * as wxApi from "../wxApi"; -export function TransactionPage({ tid }: { tid: string }): VNode { +interface Props { + tid: string; + goToWalletHistory: (currency?: string) => void; +} +export function TransactionPage({ tid, goToWalletHistory }: Props): VNode { async function getTransaction(): Promise { const res = await wxApi.getTransactions(); const ts = res.transactions.filter((t) => t.transactionId === tid); @@ -65,43 +70,30 @@ export function TransactionPage({ tid }: { tid: string }): VNode { ]); if (!state) { - return ( -
- Loading ... -
- ); + return ; } if (state.hasError) { - route(Pages.balance); return ( -
- - There was an error. Redirecting into the history page - -
+ ); } - function goToHistory(): void { - const currency = - state !== undefined && !state.hasError - ? Amounts.parseOrThrow(state.response.amountRaw).currency - : undefined; - - if (currency) { - route(Pages.balance_history.replace(":currency", currency)); - } else { - route(Pages.balance); - } - } + const currency = Amounts.parse(state.response.amountRaw)?.currency; return ( wxApi.deleteTransaction(tid).then(goToHistory)} - onRetry={() => wxApi.retryTransaction(tid).then(goToHistory)} - onBack={goToHistory} + onDelete={() => + wxApi.deleteTransaction(tid).then(() => goToWalletHistory(currency)) + } + onRetry={() => + wxApi.retryTransaction(tid).then(() => goToWalletHistory(currency)) + } + onBack={() => goToWalletHistory(currency)} /> ); } diff --git a/packages/taler-wallet-webextension/src/walletEntryPoint.tsx b/packages/taler-wallet-webextension/src/walletEntryPoint.tsx index c8bbc7f7a..629b93fc5 100644 --- a/packages/taler-wallet-webextension/src/walletEntryPoint.tsx +++ b/packages/taler-wallet-webextension/src/walletEntryPoint.tsx @@ -121,12 +121,6 @@ function Application(): VNode { * BALANCE */} - - { + route( + Pages.balance_history.replace( + ":currency", + currency || "", + ), + ); + }} /> { + route(Pages.balance); + }} /> +