no-fix: removing unused showPublicHistories
This commit is contained in:
parent
e4a2937f2a
commit
93dc9b947f
@ -31,7 +31,6 @@ const initial: Type = {
|
|||||||
pageState: {
|
pageState: {
|
||||||
isLoggedIn: false,
|
isLoggedIn: false,
|
||||||
isRawPayto: false,
|
isRawPayto: false,
|
||||||
showPublicHistories: false,
|
|
||||||
withdrawalInProgress: false,
|
withdrawalInProgress: false,
|
||||||
},
|
},
|
||||||
pageStateSetter: () => {
|
pageStateSetter: () => {
|
||||||
@ -62,7 +61,6 @@ function usePageState(
|
|||||||
state: PageStateType = {
|
state: PageStateType = {
|
||||||
isLoggedIn: false,
|
isLoggedIn: false,
|
||||||
isRawPayto: false,
|
isRawPayto: false,
|
||||||
showPublicHistories: false,
|
|
||||||
withdrawalInProgress: false,
|
withdrawalInProgress: false,
|
||||||
},
|
},
|
||||||
): [PageStateType, StateUpdater<PageStateType>] {
|
): [PageStateType, StateUpdater<PageStateType>] {
|
||||||
@ -102,7 +100,6 @@ function usePageState(
|
|||||||
export interface PageStateType {
|
export interface PageStateType {
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
isRawPayto: boolean;
|
isRawPayto: boolean;
|
||||||
showPublicHistories: boolean;
|
|
||||||
withdrawalInProgress: boolean;
|
withdrawalInProgress: boolean;
|
||||||
error?: {
|
error?: {
|
||||||
description?: string;
|
description?: string;
|
||||||
|
@ -75,13 +75,7 @@ export function BankFrame(Props: any): VNode {
|
|||||||
This part of the demo shows how a bank that supports Taler
|
This part of the demo shows how a bank that supports Taler
|
||||||
directly would work. In addition to using your own bank account,
|
directly would work. In addition to using your own bank account,
|
||||||
you can also see the transaction history of some{" "}
|
you can also see the transaction history of some{" "}
|
||||||
<a
|
<a href="/public-accounts">Public Accounts</a>.
|
||||||
href="/public-accounts"
|
|
||||||
onClick={goPublicAccounts(pageStateSetter)}
|
|
||||||
>
|
|
||||||
Public Accounts
|
|
||||||
</a>
|
|
||||||
.
|
|
||||||
</i18n.Translate>
|
</i18n.Translate>
|
||||||
</p>,
|
</p>,
|
||||||
)}
|
)}
|
||||||
@ -134,17 +128,6 @@ function maybeDemoContent(content: VNode): VNode {
|
|||||||
return <Fragment />;
|
return <Fragment />;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Bring the state to show the public accounts page.
|
|
||||||
*/
|
|
||||||
function goPublicAccounts(pageStateSetter: StateUpdater<PageStateType>) {
|
|
||||||
return () =>
|
|
||||||
pageStateSetter((prevState) => ({
|
|
||||||
...prevState,
|
|
||||||
showPublicHistories: true,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
function ErrorBanner(Props: any): VNode | null {
|
function ErrorBanner(Props: any): VNode | null {
|
||||||
const [pageState, pageStateSetter] = Props.pageState;
|
const [pageState, pageStateSetter] = Props.pageState;
|
||||||
// const { i18n } = useTranslationContext();
|
// const { i18n } = useTranslationContext();
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
import { hooks } from "@gnu-taler/web-util/lib/index.browser";
|
import { hooks } from "@gnu-taler/web-util/lib/index.browser";
|
||||||
import { Fragment, h, VNode } from "preact";
|
import { Fragment, h, VNode } from "preact";
|
||||||
|
import { route } from "preact-router";
|
||||||
import { StateUpdater } from "preact/hooks";
|
import { StateUpdater } from "preact/hooks";
|
||||||
import useSWR, { SWRConfig } from "swr";
|
import useSWR, { SWRConfig } from "swr";
|
||||||
import { PageStateType, usePageContext } from "../../context/pageState.js";
|
import { PageStateType, usePageContext } from "../../context/pageState.js";
|
||||||
@ -25,25 +26,10 @@ import { BankFrame } from "./BankFrame.js";
|
|||||||
import { Transactions } from "./Transactions.js";
|
import { Transactions } from "./Transactions.js";
|
||||||
|
|
||||||
export function PublicHistoriesPage(): VNode {
|
export function PublicHistoriesPage(): VNode {
|
||||||
const { pageState, pageStateSetter } = usePageContext();
|
|
||||||
// const { i18n } = useTranslationContext();
|
|
||||||
return (
|
return (
|
||||||
<SWRWithoutCredentials baseUrl={getBankBackendBaseUrl()}>
|
<SWRWithoutCredentials baseUrl={getBankBackendBaseUrl()}>
|
||||||
<BankFrame>
|
<BankFrame>
|
||||||
<PublicHistories pageStateSetter={pageStateSetter}>
|
<PublicHistories />
|
||||||
<br />
|
|
||||||
<a
|
|
||||||
class="pure-button"
|
|
||||||
onClick={() => {
|
|
||||||
pageStateSetter((prevState: PageStateType) => ({
|
|
||||||
...prevState,
|
|
||||||
showPublicHistories: false,
|
|
||||||
}));
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Go back
|
|
||||||
</a>
|
|
||||||
</PublicHistories>
|
|
||||||
</BankFrame>
|
</BankFrame>
|
||||||
</SWRWithoutCredentials>
|
</SWRWithoutCredentials>
|
||||||
);
|
);
|
||||||
@ -71,7 +57,8 @@ function SWRWithoutCredentials(Props: any): VNode {
|
|||||||
/**
|
/**
|
||||||
* Show histories of public accounts.
|
* Show histories of public accounts.
|
||||||
*/
|
*/
|
||||||
function PublicHistories(Props: any): VNode {
|
function PublicHistories(): VNode {
|
||||||
|
const { pageState, pageStateSetter } = usePageContext();
|
||||||
const [showAccount, setShowAccount] = useShowPublicAccount();
|
const [showAccount, setShowAccount] = useShowPublicAccount();
|
||||||
const { data, error } = useSWR("access-api/public-accounts");
|
const { data, error } = useSWR("access-api/public-accounts");
|
||||||
const { i18n } = useTranslationContext();
|
const { i18n } = useTranslationContext();
|
||||||
@ -81,10 +68,10 @@ function PublicHistories(Props: any): VNode {
|
|||||||
switch (error.status) {
|
switch (error.status) {
|
||||||
case 404:
|
case 404:
|
||||||
console.log("public accounts: 404", error);
|
console.log("public accounts: 404", error);
|
||||||
Props.pageStateSetter((prevState: PageStateType) => ({
|
route("/account");
|
||||||
|
pageStateSetter((prevState: PageStateType) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
|
|
||||||
showPublicHistories: false,
|
|
||||||
error: {
|
error: {
|
||||||
title: i18n.str`List of public accounts was not found.`,
|
title: i18n.str`List of public accounts was not found.`,
|
||||||
debug: JSON.stringify(error),
|
debug: JSON.stringify(error),
|
||||||
@ -93,10 +80,10 @@ function PublicHistories(Props: any): VNode {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log("public accounts: non-404 error", error);
|
console.log("public accounts: non-404 error", error);
|
||||||
Props.pageStateSetter((prevState: PageStateType) => ({
|
route("/account");
|
||||||
|
pageStateSetter((prevState: PageStateType) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
|
|
||||||
showPublicHistories: false,
|
|
||||||
error: {
|
error: {
|
||||||
title: i18n.str`List of public accounts could not be retrieved.`,
|
title: i18n.str`List of public accounts could not be retrieved.`,
|
||||||
debug: JSON.stringify(error),
|
debug: JSON.stringify(error),
|
||||||
@ -155,7 +142,10 @@ function PublicHistories(Props: any): VNode {
|
|||||||
) : (
|
) : (
|
||||||
<p>No public transactions found.</p>
|
<p>No public transactions found.</p>
|
||||||
)}
|
)}
|
||||||
{Props.children}
|
<br />
|
||||||
|
<a href="/account" class="pure-button">
|
||||||
|
Go back
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</section>
|
</section>
|
||||||
|
Loading…
Reference in New Issue
Block a user