From 236d4347f5884bb1d9ca1d3bb4ad0ba776577fd2 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 23 Jan 2024 18:00:42 -0300 Subject: many changes activate eslint update file headers removed history and preact-router remove eslint errors and more applied prettier --- packages/demobank-ui/src/pages/BankFrame.tsx | 244 ++++++++++++++++----------- 1 file changed, 148 insertions(+), 96 deletions(-) (limited to 'packages/demobank-ui/src/pages/BankFrame.tsx') diff --git a/packages/demobank-ui/src/pages/BankFrame.tsx b/packages/demobank-ui/src/pages/BankFrame.tsx index 73e87d9d2..a106f370d 100644 --- a/packages/demobank-ui/src/pages/BankFrame.tsx +++ b/packages/demobank-ui/src/pages/BankFrame.tsx @@ -15,143 +15,195 @@ */ import { Amounts, TalerError, TranslatedString } from "@gnu-taler/taler-util"; -import { Footer, GlobalNotificationsBanner, Header, Loading, notifyError, notifyException, useTranslationContext } from "@gnu-taler/web-util/browser"; -import { ComponentChildren, Fragment, VNode, h } from "preact"; -import { useEffect, useErrorBoundary, useState } from "preact/hooks"; +import { + Footer, + GlobalNotificationsBanner, + Header, + Loading, + notifyError, + notifyException, + useTranslationContext, +} from "@gnu-taler/web-util/browser"; +import { ComponentChildren, VNode, h } from "preact"; +import { useEffect, useErrorBoundary } from "preact/hooks"; +import { privatePages } from "../Routing.js"; +import { useBankCoreApiContext } from "../context/config.js"; +import { useSettingsContext } from "../context/settings.js"; import { useAccountDetails } from "../hooks/access.js"; import { useBackendState } from "../hooks/backend.js"; -import { getAllBooleanPreferences, getLabelForPreferences, usePreferences } from "../hooks/preferences.js"; -import { RenderAmount } from "./PaytoWireTransferForm.js"; -import { useSettingsContext } from "../context/settings.js"; -import { useBankCoreApiContext } from "../context/config.js"; import { useBankState } from "../hooks/bank-state.js"; +import { + getAllBooleanPreferences, + getLabelForPreferences, + usePreferences, +} from "../hooks/preferences.js"; +import { RenderAmount } from "./PaytoWireTransferForm.js"; const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined; const VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : undefined; - export function BankFrame({ children, account, }: { - account?: string, + account?: string; children: ComponentChildren; }): VNode { const { i18n } = useTranslationContext(); const backend = useBackendState(); const settings = useSettingsContext(); const [preferences, updatePreferences] = usePreferences(); - const [, , resetBankState] = useBankState() + const [, , resetBankState] = useBankState(); const [error, resetError] = useErrorBoundary(); useEffect(() => { if (error) { - const desc = (error instanceof Error ? error.stack : String(error)) as TranslatedString if (error instanceof Error) { - console.log("Internal error, please report", error) - notifyException(i18n.str`Internal error, please report.`, error) + console.log("Internal error, please report", error); + notifyException(i18n.str`Internal error, please report.`, error); } else { - console.log("Internal error, please report", error) - notifyError(i18n.str`Internal error, please report.`, String(error) as TranslatedString) + console.log("Internal error, please report", error); + notifyError( + i18n.str`Internal error, please report.`, + String(error) as TranslatedString, + ); } - resetError() + resetError(); } - }, [error]) - - return (
- -
-
{ - backend.logOut() - resetBankState(); - }} - sites={!settings.topNavSites ? [] : Object.entries(settings.topNavSites)} - supportedLangs={["en", "es", "de"]} - > -
  • -
    - Preferences -
    -
      - {getAllBooleanPreferences().map(set => { - const isOn: boolean = !!preferences[set] - return
    • -
      - - - {getLabelForPreferences(set, i18n)} - - - -
      -
    • - })} -
    -
  • -
    -
    - - - -
    - {account && -
    -
    -

    - - -

    -
    -
    - } - -
    -
    - {children} -
    + }, [error]); + + return ( +
    +
    +
    { + backend.logOut(); + resetBankState(); + } + } + sites={ + !settings.topNavSites ? [] : Object.entries(settings.topNavSites) + } + supportedLangs={["en", "es", "de"]} + > +
  • +
    + Preferences +
    +
      + {getAllBooleanPreferences().map((set) => { + const isOn: boolean = !!preferences[set]; + return ( +
    • +
      + + + {getLabelForPreferences(set, i18n)} + + + +
      +
    • + ); + })} +
    +
  • +
    -
    - -
    - -
    + + +
    + {account && ( +
    +
    +

    + + + + + + +

    +
    +
    + )} + +
    +
    + {children} +
    +
    +
    + +