summaryrefslogtreecommitdiff
path: root/packages/bank-ui/src/components/Transactions/state.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/bank-ui/src/components/Transactions/state.ts')
-rw-r--r--packages/bank-ui/src/components/Transactions/state.ts62
1 files changed, 32 insertions, 30 deletions
diff --git a/packages/bank-ui/src/components/Transactions/state.ts b/packages/bank-ui/src/components/Transactions/state.ts
index 3e9103b59..e792ddfa0 100644
--- a/packages/bank-ui/src/components/Transactions/state.ts
+++ b/packages/bank-ui/src/components/Transactions/state.ts
@@ -23,7 +23,10 @@ import {
import { useTransactions } from "../../hooks/account.js";
import { Props, State, Transaction } from "./index.js";
-export function useComponentState({ account, routeCreateWireTransfer }: Props): State {
+export function useComponentState({
+ account,
+ routeCreateWireTransfer,
+}: Props): State {
const txResult = useTransactions(account);
if (!txResult) {
return {
@@ -38,36 +41,35 @@ export function useComponentState({ account, routeCreateWireTransfer }: Props):
};
}
- const transactions =
- txResult.result
- .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 transactions = txResult.result
+ .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",