aboutsummaryrefslogtreecommitdiff
path: root/packages/bank-ui
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-04-26 14:31:08 -0300
committerSebastian <sebasjm@gmail.com>2024-04-26 14:31:08 -0300
commitce251b9bd38eccaca9dd43efdcf7ecf9a6a66b29 (patch)
tree7897c066937f314e9221404dc83c4178dd80bb0c /packages/bank-ui
parentdbe5a5e5ee646b0d6824bc461c95f3c8c1572ced (diff)
downloadwallet-core-ce251b9bd38eccaca9dd43efdcf7ecf9a6a66b29.tar.xz
show error like bank
Diffstat (limited to 'packages/bank-ui')
-rw-r--r--packages/bank-ui/src/app.tsx4
-rw-r--r--packages/bank-ui/src/context/settings.ts8
-rw-r--r--packages/bank-ui/src/pages/RegistrationPage.tsx7
-rw-r--r--packages/bank-ui/src/settings.ts14
4 files changed, 16 insertions, 17 deletions
diff --git a/packages/bank-ui/src/app.tsx b/packages/bank-ui/src/app.tsx
index 29dabddd6..1ea8c69ca 100644
--- a/packages/bank-ui/src/app.tsx
+++ b/packages/bank-ui/src/app.tsx
@@ -37,7 +37,7 @@ import { Routing } from "./Routing.js";
import { SettingsProvider } from "./context/settings.js";
import { strings } from "./i18n/strings.js";
import { BankFrame } from "./pages/BankFrame.js";
-import { BankUiSettings, fetchSettings } from "./settings.js";
+import { UiSettings, fetchSettings } from "./settings.js";
import {
revalidateAccountDetails,
revalidatePublicAccounts,
@@ -51,7 +51,7 @@ import {
const WITH_LOCAL_STORAGE_CACHE = false;
export function App() {
- const [settings, setSettings] = useState<BankUiSettings>();
+ const [settings, setSettings] = useState<UiSettings>();
useEffect(() => {
fetchSettings(setSettings);
}, []);
diff --git a/packages/bank-ui/src/context/settings.ts b/packages/bank-ui/src/context/settings.ts
index 053fcbd12..6c61a7b4a 100644
--- a/packages/bank-ui/src/context/settings.ts
+++ b/packages/bank-ui/src/context/settings.ts
@@ -16,16 +16,16 @@
import { ComponentChildren, createContext, h, VNode } from "preact";
import { useContext } from "preact/hooks";
-import { BankUiSettings } from "../settings.js";
+import { UiSettings } from "../settings.js";
/**
*
* @author Sebastian Javier Marchano (sebasjm)
*/
-export type Type = BankUiSettings;
+export type Type = UiSettings;
-const initial: BankUiSettings = {};
+const initial: UiSettings = {};
const Context = createContext<Type>(initial);
export const useSettingsContext = (): Type => useContext(Context);
@@ -34,7 +34,7 @@ export const SettingsProvider = ({
children,
value,
}: {
- value: BankUiSettings;
+ value: UiSettings;
children: ComponentChildren;
}): VNode => {
return h(Context.Provider, {
diff --git a/packages/bank-ui/src/pages/RegistrationPage.tsx b/packages/bank-ui/src/pages/RegistrationPage.tsx
index 18f926e00..5dd19a63f 100644
--- a/packages/bank-ui/src/pages/RegistrationPage.tsx
+++ b/packages/bank-ui/src/pages/RegistrationPage.tsx
@@ -14,21 +14,20 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
import {
- AccessToken,
HttpStatusCode,
- TalerErrorCode,
+ TalerErrorCode
} from "@gnu-taler/taler-util";
import {
LocalNotificationBanner,
+ RouteDefinition,
ShowInputErrorLabel,
+ useBankCoreApiContext,
useLocalNotification,
useTranslationContext,
} from "@gnu-taler/web-util/browser";
import { Fragment, VNode, h } from "preact";
import { useState } from "preact/hooks";
-import { useBankCoreApiContext } from "@gnu-taler/web-util/browser";
import { useSettingsContext } from "../context/settings.js";
-import { RouteDefinition } from "@gnu-taler/web-util/browser";
import { undefinedIfEmpty } from "../utils.js";
import { getRandomPassword, getRandomUsername } from "./rnd.js";
diff --git a/packages/bank-ui/src/settings.ts b/packages/bank-ui/src/settings.ts
index 968fe6248..c085c7cd8 100644
--- a/packages/bank-ui/src/settings.ts
+++ b/packages/bank-ui/src/settings.ts
@@ -24,7 +24,7 @@ import {
codecOptional,
} from "@gnu-taler/taler-util";
-export interface BankUiSettings {
+export interface UiSettings {
// Where libeufin backend is localted
// default: window.origin without "webui/"
backendBaseURL?: string;
@@ -50,7 +50,7 @@ export interface BankUiSettings {
/**
* Global settings for the bank UI.
*/
-const defaultSettings: BankUiSettings = {
+const defaultSettings: UiSettings = {
backendBaseURL: buildDefaultBackendBaseURL(),
iconLinkURL: undefined,
simplePasswordForRandomAccounts: false,
@@ -58,8 +58,8 @@ const defaultSettings: BankUiSettings = {
topNavSites: {},
};
-const codecForBankUISettings = (): Codec<BankUiSettings> =>
- buildCodecForObject<BankUiSettings>()
+const codecForUISettings = (): Codec<UiSettings> =>
+ buildCodecForObject<UiSettings>()
.property("backendBaseURL", codecOptional(codecForString()))
.property("allowRandomAccountCreation", codecOptional(codecForBoolean()))
.property(
@@ -68,7 +68,7 @@ const codecForBankUISettings = (): Codec<BankUiSettings> =>
)
.property("iconLinkURL", codecOptional(codecForString()))
.property("topNavSites", codecOptional(codecForMap(codecForString())))
- .build("BankUiSettings");
+ .build("UiSettings");
function removeUndefineField<T extends object>(obj: T): T {
const keys = Object.keys(obj) as Array<keyof T>;
@@ -80,10 +80,10 @@ function removeUndefineField<T extends object>(obj: T): T {
}, obj);
}
-export function fetchSettings(listener: (s: BankUiSettings) => void): void {
+export function fetchSettings(listener: (s: UiSettings) => void): void {
fetch("./settings.json")
.then((resp) => resp.json())
- .then((json) => codecForBankUISettings().decode(json))
+ .then((json) => codecForUISettings().decode(json))
.then((result) =>
listener({
...defaultSettings,