summaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/pages/PublicHistoriesPage.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/demobank-ui/src/pages/PublicHistoriesPage.tsx')
-rw-r--r--packages/demobank-ui/src/pages/PublicHistoriesPage.tsx25
1 files changed, 13 insertions, 12 deletions
diff --git a/packages/demobank-ui/src/pages/PublicHistoriesPage.tsx b/packages/demobank-ui/src/pages/PublicHistoriesPage.tsx
index 680368919..d33353180 100644
--- a/packages/demobank-ui/src/pages/PublicHistoriesPage.tsx
+++ b/packages/demobank-ui/src/pages/PublicHistoriesPage.tsx
@@ -14,35 +14,36 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { Logger } from "@gnu-taler/taler-util";
+import { Logger, TalerError } from "@gnu-taler/taler-util";
import { useTranslationContext } from "@gnu-taler/web-util/browser";
import { Fragment, VNode, h } from "preact";
import { useState } from "preact/hooks";
+import { Loading } from "../components/Loading.js";
import { Transactions } from "../components/Transactions/index.js";
import { usePublicAccounts } from "../hooks/access.js";
-import { handleNotOkResult } from "./HomePage.js";
-import { Loading } from "../components/Loading.js";
const logger = new Logger("PublicHistoriesPage");
-interface Props {}
+interface Props { }
/**
* Show histories of public accounts.
*/
-export function PublicHistoriesPage({}: Props): VNode {
+export function PublicHistoriesPage({ }: Props): VNode {
const { i18n } = useTranslationContext();
const result = usePublicAccounts();
+ const firstAccount = result && !(result instanceof TalerError) && result.data.public_accounts.length > 0
+ ? result.data.public_accounts[0].account_name
+ : undefined;
- const [showAccount, setShowAccount] = useState(
- result.ok && result.data.public_accounts.length > 0
- ? result.data.public_accounts[0].account_name
- : undefined,
- );
+ const [showAccount, setShowAccount] = useState(firstAccount);
- if (!result.ok) {
- return handleNotOkResult(i18n)(result);
+ if (!result) {
+ return <Loading />
+ }
+ if (result instanceof TalerError) {
+ return <Loading />
}
const { data } = result;