diff options
Diffstat (limited to 'packages/bank-ui/src/components/Transactions')
-rw-r--r-- | packages/bank-ui/src/components/Transactions/state.ts | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/packages/bank-ui/src/components/Transactions/state.ts b/packages/bank-ui/src/components/Transactions/state.ts index 4e4552a82..ce6338e57 100644 --- a/packages/bank-ui/src/components/Transactions/state.ts +++ b/packages/bank-ui/src/components/Transactions/state.ts @@ -17,7 +17,9 @@ import { AbsoluteTime, Amounts, + HttpStatusCode, TalerError, + assertUnreachable, parsePaytoUri, } from "@gnu-taler/taler-util"; import { useTransactions } from "../../hooks/account.js"; @@ -27,21 +29,27 @@ export function useComponentState({ account, routeCreateWireTransfer, }: Props): State { - const txResult = useTransactions(account); - if (!txResult) { + const result = useTransactions(account); + if (!result) { return { status: "loading", error: undefined, }; } - if (txResult instanceof TalerError) { + if (result instanceof TalerError) { return { status: "loading-error", - error: txResult, + error: result, + }; + } + if (result.type === "fail") { + return { + status: "loading", + error: undefined, }; } - const transactions = txResult.result + const transactions = result.body .map((tx) => { const negative = tx.direction === "debit"; const cp = parsePaytoUri( @@ -76,7 +84,7 @@ export function useComponentState({ error: undefined, routeCreateWireTransfer, transactions, - onGoNext: txResult.isLastPage ? undefined : txResult.loadNext, - onGoStart: txResult.isFirstPage ? undefined : txResult.loadFirst, + onGoNext: result.isLastPage ? undefined : result.loadNext, + onGoStart: result.isFirstPage ? undefined : result.loadFirst, }; } |