From 93dc9b947ffc2bcbc8053c05c31850288bf1a22c Mon Sep 17 00:00:00 2001
From: Sebastian
Date: Wed, 7 Dec 2022 11:39:57 -0300
Subject: [PATCH] no-fix: removing unused showPublicHistories
---
packages/demobank-ui/src/context/pageState.ts | 3 --
.../demobank-ui/src/pages/home/BankFrame.tsx | 19 +----------
.../src/pages/home/PublicHistoriesPage.tsx | 34 +++++++------------
3 files changed, 13 insertions(+), 43 deletions(-)
diff --git a/packages/demobank-ui/src/context/pageState.ts b/packages/demobank-ui/src/context/pageState.ts
index 3d7ccd85b..4ef21b8f0 100644
--- a/packages/demobank-ui/src/context/pageState.ts
+++ b/packages/demobank-ui/src/context/pageState.ts
@@ -31,7 +31,6 @@ const initial: Type = {
pageState: {
isLoggedIn: false,
isRawPayto: false,
- showPublicHistories: false,
withdrawalInProgress: false,
},
pageStateSetter: () => {
@@ -62,7 +61,6 @@ function usePageState(
state: PageStateType = {
isLoggedIn: false,
isRawPayto: false,
- showPublicHistories: false,
withdrawalInProgress: false,
},
): [PageStateType, StateUpdater] {
@@ -102,7 +100,6 @@ function usePageState(
export interface PageStateType {
isLoggedIn: boolean;
isRawPayto: boolean;
- showPublicHistories: boolean;
withdrawalInProgress: boolean;
error?: {
description?: string;
diff --git a/packages/demobank-ui/src/pages/home/BankFrame.tsx b/packages/demobank-ui/src/pages/home/BankFrame.tsx
index 9b4bc4567..2d405e58c 100644
--- a/packages/demobank-ui/src/pages/home/BankFrame.tsx
+++ b/packages/demobank-ui/src/pages/home/BankFrame.tsx
@@ -75,13 +75,7 @@ export function BankFrame(Props: any): VNode {
This part of the demo shows how a bank that supports Taler
directly would work. In addition to using your own bank account,
you can also see the transaction history of some{" "}
-
- Public Accounts
-
- .
+ Public Accounts.
,
)}
@@ -134,17 +128,6 @@ function maybeDemoContent(content: VNode): VNode {
return ;
}
-/**
- * Bring the state to show the public accounts page.
- */
-function goPublicAccounts(pageStateSetter: StateUpdater) {
- return () =>
- pageStateSetter((prevState) => ({
- ...prevState,
- showPublicHistories: true,
- }));
-}
-
function ErrorBanner(Props: any): VNode | null {
const [pageState, pageStateSetter] = Props.pageState;
// const { i18n } = useTranslationContext();
diff --git a/packages/demobank-ui/src/pages/home/PublicHistoriesPage.tsx b/packages/demobank-ui/src/pages/home/PublicHistoriesPage.tsx
index 216808e5c..215dc7321 100644
--- a/packages/demobank-ui/src/pages/home/PublicHistoriesPage.tsx
+++ b/packages/demobank-ui/src/pages/home/PublicHistoriesPage.tsx
@@ -16,6 +16,7 @@
import { hooks } from "@gnu-taler/web-util/lib/index.browser";
import { Fragment, h, VNode } from "preact";
+import { route } from "preact-router";
import { StateUpdater } from "preact/hooks";
import useSWR, { SWRConfig } from "swr";
import { PageStateType, usePageContext } from "../../context/pageState.js";
@@ -25,25 +26,10 @@ import { BankFrame } from "./BankFrame.js";
import { Transactions } from "./Transactions.js";
export function PublicHistoriesPage(): VNode {
- const { pageState, pageStateSetter } = usePageContext();
- // const { i18n } = useTranslationContext();
return (
-
-
- {
- pageStateSetter((prevState: PageStateType) => ({
- ...prevState,
- showPublicHistories: false,
- }));
- }}
- >
- Go back
-
-
+
);
@@ -71,7 +57,8 @@ function SWRWithoutCredentials(Props: any): VNode {
/**
* Show histories of public accounts.
*/
-function PublicHistories(Props: any): VNode {
+function PublicHistories(): VNode {
+ const { pageState, pageStateSetter } = usePageContext();
const [showAccount, setShowAccount] = useShowPublicAccount();
const { data, error } = useSWR("access-api/public-accounts");
const { i18n } = useTranslationContext();
@@ -81,10 +68,10 @@ function PublicHistories(Props: any): VNode {
switch (error.status) {
case 404:
console.log("public accounts: 404", error);
- Props.pageStateSetter((prevState: PageStateType) => ({
+ route("/account");
+ pageStateSetter((prevState: PageStateType) => ({
...prevState,
- showPublicHistories: false,
error: {
title: i18n.str`List of public accounts was not found.`,
debug: JSON.stringify(error),
@@ -93,10 +80,10 @@ function PublicHistories(Props: any): VNode {
break;
default:
console.log("public accounts: non-404 error", error);
- Props.pageStateSetter((prevState: PageStateType) => ({
+ route("/account");
+ pageStateSetter((prevState: PageStateType) => ({
...prevState,
- showPublicHistories: false,
error: {
title: i18n.str`List of public accounts could not be retrieved.`,
debug: JSON.stringify(error),
@@ -155,7 +142,10 @@ function PublicHistories(Props: any): VNode {
) : (
No public transactions found.
)}
- {Props.children}
+
+
+ Go back
+