aboutsummaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/components/Transactions/state.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/demobank-ui/src/components/Transactions/state.ts')
-rw-r--r--packages/demobank-ui/src/components/Transactions/state.ts57
1 files changed, 29 insertions, 28 deletions
diff --git a/packages/demobank-ui/src/components/Transactions/state.ts b/packages/demobank-ui/src/components/Transactions/state.ts
index 74e6b0d36..5e99a8a76 100644
--- a/packages/demobank-ui/src/components/Transactions/state.ts
+++ b/packages/demobank-ui/src/components/Transactions/state.ts
@@ -23,7 +23,7 @@ import {
import { useTransactions } from "../../hooks/access.js";
import { Props, State, Transaction } from "./index.js";
-export function useComponentState({ account }: Props): State {
+export function useComponentState({ account, routeCreateWireTransfer }: Props): State {
const result = useTransactions(account);
if (!result) {
return {
@@ -42,38 +42,39 @@ export function useComponentState({ account }: Props): State {
result.data.type === "fail"
? []
: result.data.body.transactions
- .map((tx) => {
- const negative = tx.direction === "debit";
- const cp = parsePaytoUri(
- negative ? tx.creditor_payto_uri : tx.debtor_payto_uri,
- );
- const counterpart =
- (cp === undefined || !cp.isKnown
- ? undefined
- : cp.targetType === "iban"
- ? cp.iban
- : cp.targetType === "x-taler-bank"
- ? cp.account
- : cp.targetType === "bitcoin"
- ? `${cp.targetPath.substring(0, 6)}...`
- : undefined) ?? "unknown";
+ .map((tx) => {
+ const negative = tx.direction === "debit";
+ const cp = parsePaytoUri(
+ negative ? tx.creditor_payto_uri : tx.debtor_payto_uri,
+ );
+ const counterpart =
+ (cp === undefined || !cp.isKnown
+ ? undefined
+ : cp.targetType === "iban"
+ ? cp.iban
+ : cp.targetType === "x-taler-bank"
+ ? cp.account
+ : cp.targetType === "bitcoin"
+ ? `${cp.targetPath.substring(0, 6)}...`
+ : undefined) ?? "unknown";
- const when = AbsoluteTime.fromProtocolTimestamp(tx.date);
- const amount = Amounts.parse(tx.amount);
- const subject = tx.subject;
- return {
- negative,
- counterpart,
- when,
- amount,
- subject,
- };
- })
- .filter((x): x is Transaction => x !== undefined);
+ const when = AbsoluteTime.fromProtocolTimestamp(tx.date);
+ const amount = Amounts.parse(tx.amount);
+ const subject = tx.subject;
+ return {
+ negative,
+ counterpart,
+ when,
+ amount,
+ subject,
+ };
+ })
+ .filter((x): x is Transaction => x !== undefined);
return {
status: "ready",
error: undefined,
+ routeCreateWireTransfer,
transactions,
onNext: result.isLastPage ? undefined : result.loadMore,
onPrev: result.isFirstPage ? undefined : result.loadMorePrev,