summaryrefslogtreecommitdiff
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.ts18
1 files changed, 9 insertions, 9 deletions
diff --git a/packages/demobank-ui/src/components/Transactions/state.ts b/packages/demobank-ui/src/components/Transactions/state.ts
index 4b62b005e..c85fba85b 100644
--- a/packages/demobank-ui/src/components/Transactions/state.ts
+++ b/packages/demobank-ui/src/components/Transactions/state.ts
@@ -14,34 +14,34 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { AbsoluteTime, Amounts, parsePaytoUri } from "@gnu-taler/taler-util";
+import { AbsoluteTime, Amounts, TalerError, parsePaytoUri } from "@gnu-taler/taler-util";
import { useTransactions } from "../../hooks/access.js";
import { Props, State, Transaction } from "./index.js";
export function useComponentState({ account }: Props): State {
const result = useTransactions(account);
- if (result.loading) {
+ if (!result) {
return {
status: "loading",
error: undefined,
};
}
- if (!result.ok) {
+ if (result instanceof TalerError) {
return {
status: "loading-error",
error: result,
};
}
- const transactions = result.data.transactions
+ const transactions = 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) ??
+ cp.targetType === "iban" ? cp.iban :
+ cp.targetType === "x-taler-bank" ? cp.account :
+ cp.targetType === "bitcoin" ? `${cp.targetPath.substring(0, 6)}...` : undefined) ??
"unkown";
const when = AbsoluteTime.fromProtocolTimestamp(tx.date);
@@ -61,7 +61,7 @@ export function useComponentState({ account }: Props): State {
status: "ready",
error: undefined,
transactions,
- onNext: result.isReachingEnd ? undefined : result.loadMore,
- onPrev: result.isReachingStart ? undefined : result.loadMorePrev,
+ onNext: result.isLastPage ? undefined : result.loadMore,
+ onPrev: result.isFirstPage ? undefined : result.loadMorePrev,
};
}