fix #7162
This commit is contained in:
parent
a06f7f7cbb
commit
c13f3cf1cd
@ -32,7 +32,7 @@ export enum Pages {
|
|||||||
welcome = "/welcome",
|
welcome = "/welcome",
|
||||||
|
|
||||||
balance = "/balance",
|
balance = "/balance",
|
||||||
balance_history = "/balance/history/:currency",
|
balance_history = "/balance/history/:currency?",
|
||||||
balance_manual_withdraw = "/balance/manual-withdraw/:currency?",
|
balance_manual_withdraw = "/balance/manual-withdraw/:currency?",
|
||||||
balance_deposit = "/balance/deposit/:currency",
|
balance_deposit = "/balance/deposit/:currency",
|
||||||
balance_transaction = "/balance/transaction/:tid",
|
balance_transaction = "/balance/transaction/:tid",
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
import { PrepareTipResult } from "@gnu-taler/taler-util";
|
import { PrepareTipResult } from "@gnu-taler/taler-util";
|
||||||
import { h, VNode } from "preact";
|
import { h, VNode } from "preact";
|
||||||
import { useEffect, useState } from "preact/hooks";
|
import { useEffect, useState } from "preact/hooks";
|
||||||
|
import { Loading } from "../components/Loading";
|
||||||
import { AmountView } from "../renderHtml";
|
import { AmountView } from "../renderHtml";
|
||||||
import * as wxApi from "../wxApi";
|
import * as wxApi from "../wxApi";
|
||||||
|
|
||||||
@ -105,7 +106,7 @@ export function TipPage({ talerTipUri }: Props): VNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!prepareTipResult) {
|
if (!prepareTipResult) {
|
||||||
return <span>Loading ...</span>;
|
return <Loading />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -127,13 +127,6 @@ function Application(): VNode {
|
|||||||
|
|
||||||
<Route path={Pages.pending} component={Pending} />
|
<Route path={Pages.pending} component={Pending} />
|
||||||
|
|
||||||
<Route
|
|
||||||
path={Pages.balance_transaction}
|
|
||||||
component={({ tid }: { tid: string }) =>
|
|
||||||
goToWalletPage(Pages.balance_transaction.replace(":tid", tid))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
path={Pages.backup}
|
path={Pages.backup}
|
||||||
component={BackupPage}
|
component={BackupPage}
|
||||||
|
@ -21,7 +21,6 @@ import {
|
|||||||
NotificationType,
|
NotificationType,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { h, VNode } from "preact";
|
import { h, VNode } from "preact";
|
||||||
import { route } from "preact-router";
|
|
||||||
import { useState } from "preact/hooks";
|
import { useState } from "preact/hooks";
|
||||||
import { Loading } from "../components/Loading";
|
import { Loading } from "../components/Loading";
|
||||||
import { LoadingError } from "../components/LoadingError";
|
import { LoadingError } from "../components/LoadingError";
|
||||||
@ -32,7 +31,12 @@ import { CreateManualWithdraw } from "./CreateManualWithdraw";
|
|||||||
import { ExchangeAddPage } from "./ExchangeAddPage";
|
import { ExchangeAddPage } from "./ExchangeAddPage";
|
||||||
import { ReserveCreated } from "./ReserveCreated";
|
import { ReserveCreated } from "./ReserveCreated";
|
||||||
|
|
||||||
export function ManualWithdrawPage({ currency }: { currency?: string }): VNode {
|
interface Props {
|
||||||
|
currency?: string;
|
||||||
|
onCancel: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ManualWithdrawPage({ currency, onCancel }: Props): VNode {
|
||||||
const [success, setSuccess] = useState<
|
const [success, setSuccess] = useState<
|
||||||
| {
|
| {
|
||||||
response: AcceptManualWithdrawalResult;
|
response: AcceptManualWithdrawalResult;
|
||||||
@ -80,9 +84,7 @@ export function ManualWithdrawPage({ currency }: { currency?: string }): VNode {
|
|||||||
payto={success.response.exchangePaytoUris[0]}
|
payto={success.response.exchangePaytoUris[0]}
|
||||||
exchangeBaseUrl={success.exchangeBaseUrl}
|
exchangeBaseUrl={success.exchangeBaseUrl}
|
||||||
amount={success.amount}
|
amount={success.amount}
|
||||||
onBack={() => {
|
onCancel={onCancel}
|
||||||
route(Pages.balance);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,13 @@ export interface Props {
|
|||||||
payto: string;
|
payto: string;
|
||||||
exchangeBaseUrl: string;
|
exchangeBaseUrl: string;
|
||||||
amount: AmountJson;
|
amount: AmountJson;
|
||||||
onBack: () => void;
|
onCancel: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ReserveCreated({
|
export function ReserveCreated({
|
||||||
reservePub,
|
reservePub,
|
||||||
payto,
|
payto,
|
||||||
onBack,
|
onCancel,
|
||||||
exchangeBaseUrl,
|
exchangeBaseUrl,
|
||||||
amount,
|
amount,
|
||||||
}: Props): VNode {
|
}: Props): VNode {
|
||||||
@ -55,7 +55,7 @@ export function ReserveCreated({
|
|||||||
</section>
|
</section>
|
||||||
<footer>
|
<footer>
|
||||||
<div />
|
<div />
|
||||||
<ButtonDestructive onClick={onBack}>
|
<ButtonDestructive onClick={onCancel}>
|
||||||
Cancel withdrawal
|
Cancel withdrawal
|
||||||
</ButtonDestructive>
|
</ButtonDestructive>
|
||||||
</footer>
|
</footer>
|
||||||
|
@ -26,11 +26,12 @@ import {
|
|||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { differenceInSeconds } from "date-fns";
|
import { differenceInSeconds } from "date-fns";
|
||||||
import { ComponentChildren, Fragment, h, VNode } from "preact";
|
import { ComponentChildren, Fragment, h, VNode } from "preact";
|
||||||
import { route } from "preact-router";
|
|
||||||
import { useState } from "preact/hooks";
|
import { useState } from "preact/hooks";
|
||||||
import emptyImg from "../../static/img/empty.png";
|
import emptyImg from "../../static/img/empty.png";
|
||||||
import { BankDetailsByPaytoType } from "../components/BankDetailsByPaytoType";
|
import { BankDetailsByPaytoType } from "../components/BankDetailsByPaytoType";
|
||||||
import { ErrorTalerOperation } from "../components/ErrorTalerOperation";
|
import { ErrorTalerOperation } from "../components/ErrorTalerOperation";
|
||||||
|
import { Loading } from "../components/Loading";
|
||||||
|
import { LoadingError } from "../components/LoadingError";
|
||||||
import { Part } from "../components/Part";
|
import { Part } from "../components/Part";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@ -49,7 +50,11 @@ import { useAsyncAsHook } from "../hooks/useAsyncAsHook";
|
|||||||
import { Pages } from "../NavigationBar";
|
import { Pages } from "../NavigationBar";
|
||||||
import * as wxApi from "../wxApi";
|
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<Transaction> {
|
async function getTransaction(): Promise<Transaction> {
|
||||||
const res = await wxApi.getTransactions();
|
const res = await wxApi.getTransactions();
|
||||||
const ts = res.transactions.filter((t) => t.transactionId === tid);
|
const ts = res.transactions.filter((t) => t.transactionId === tid);
|
||||||
@ -65,43 +70,30 @@ export function TransactionPage({ tid }: { tid: string }): VNode {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (!state) {
|
if (!state) {
|
||||||
return (
|
return <Loading />;
|
||||||
<div>
|
|
||||||
<i18n.Translate>Loading ...</i18n.Translate>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.hasError) {
|
if (state.hasError) {
|
||||||
route(Pages.balance);
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<LoadingError
|
||||||
<i18n.Translate>
|
title="Could not load the transaction information"
|
||||||
There was an error. Redirecting into the history page
|
error={state}
|
||||||
</i18n.Translate>
|
/>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function goToHistory(): void {
|
const currency = Amounts.parse(state.response.amountRaw)?.currency;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TransactionView
|
<TransactionView
|
||||||
transaction={state.response}
|
transaction={state.response}
|
||||||
onDelete={() => wxApi.deleteTransaction(tid).then(goToHistory)}
|
onDelete={() =>
|
||||||
onRetry={() => wxApi.retryTransaction(tid).then(goToHistory)}
|
wxApi.deleteTransaction(tid).then(() => goToWalletHistory(currency))
|
||||||
onBack={goToHistory}
|
}
|
||||||
|
onRetry={() =>
|
||||||
|
wxApi.retryTransaction(tid).then(() => goToWalletHistory(currency))
|
||||||
|
}
|
||||||
|
onBack={() => goToWalletHistory(currency)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -121,12 +121,6 @@ function Application(): VNode {
|
|||||||
* BALANCE
|
* BALANCE
|
||||||
*/}
|
*/}
|
||||||
|
|
||||||
<Route
|
|
||||||
path={Pages.balance}
|
|
||||||
component={Redirect}
|
|
||||||
to={Pages.balance_history.replace(":currency", "")}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
path={Pages.balance_history}
|
path={Pages.balance_history}
|
||||||
component={HistoryPage}
|
component={HistoryPage}
|
||||||
@ -145,11 +139,22 @@ function Application(): VNode {
|
|||||||
<Route
|
<Route
|
||||||
path={Pages.balance_transaction}
|
path={Pages.balance_transaction}
|
||||||
component={TransactionPage}
|
component={TransactionPage}
|
||||||
|
goToWalletHistory={(currency?: string) => {
|
||||||
|
route(
|
||||||
|
Pages.balance_history.replace(
|
||||||
|
":currency",
|
||||||
|
currency || "",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
path={Pages.balance_manual_withdraw}
|
path={Pages.balance_manual_withdraw}
|
||||||
component={ManualWithdrawPage}
|
component={ManualWithdrawPage}
|
||||||
|
onCancel={() => {
|
||||||
|
route(Pages.balance);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
@ -232,7 +237,14 @@ function Application(): VNode {
|
|||||||
|
|
||||||
{/**
|
{/**
|
||||||
* NOT FOUND
|
* NOT FOUND
|
||||||
|
* all redirects should be at the end
|
||||||
*/}
|
*/}
|
||||||
|
<Route
|
||||||
|
path={Pages.balance}
|
||||||
|
component={Redirect}
|
||||||
|
to={Pages.balance_history.replace(":currency", "")}
|
||||||
|
/>
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
default
|
default
|
||||||
component={Redirect}
|
component={Redirect}
|
||||||
|
Loading…
Reference in New Issue
Block a user