summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/wallet/ManageAccount
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-01-09 08:38:48 -0300
committerSebastian <sebasjm@gmail.com>2023-01-09 08:38:48 -0300
commit9b04d8bf3581d162cbd631892ca115df811c46f8 (patch)
tree42b7da7cc3a3f8186823a7571aa221dc8e9aa7a5 /packages/taler-wallet-webextension/src/wallet/ManageAccount
parent14f3d1e06dda003d457f2b3531e197011a284244 (diff)
downloadwallet-core-9b04d8bf3581d162cbd631892ca115df811c46f8.tar.gz
wallet-core-9b04d8bf3581d162cbd631892ca115df811c46f8.tar.bz2
wallet-core-9b04d8bf3581d162cbd631892ca115df811c46f8.zip
fix #7152
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet/ManageAccount')
-rw-r--r--packages/taler-wallet-webextension/src/wallet/ManageAccount/index.ts11
-rw-r--r--packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts7
-rw-r--r--packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx21
3 files changed, 15 insertions, 24 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/ManageAccount/index.ts b/packages/taler-wallet-webextension/src/wallet/ManageAccount/index.ts
index 8541821b7..3a00d48ce 100644
--- a/packages/taler-wallet-webextension/src/wallet/ManageAccount/index.ts
+++ b/packages/taler-wallet-webextension/src/wallet/ManageAccount/index.ts
@@ -15,8 +15,9 @@
*/
import { KnownBankAccountsInfo } from "@gnu-taler/taler-util";
+import { ErrorAlertView } from "../../components/CurrentAlerts.js";
import { Loading } from "../../components/Loading.js";
-import { HookError } from "../../hooks/useAsyncAsHook.js";
+import { ErrorAlert } from "../../context/alert.js";
import {
ButtonHandler,
SelectFieldHandler,
@@ -24,7 +25,7 @@ import {
} from "../../mui/handlers.js";
import { compose, StateViewMap } from "../../utils/index.js";
import { useComponentState } from "./state.js";
-import { LoadingUriView, ReadyView } from "./views.js";
+import { ReadyView } from "./views.js";
export interface Props {
currency: string;
@@ -41,8 +42,8 @@ export namespace State {
}
export interface LoadingUriError {
- status: "loading-error";
- error: HookError;
+ status: "error";
+ error: ErrorAlert;
}
export interface BaseInfo {
@@ -68,7 +69,7 @@ export type AccountByType = {
const viewMapping: StateViewMap<State> = {
loading: Loading,
- "loading-error": LoadingUriView,
+ error: ErrorAlertView,
ready: ReadyView,
};
diff --git a/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts b/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts
index 9690a5c79..176a8d100 100644
--- a/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts
+++ b/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts
@@ -21,7 +21,9 @@ import {
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { useState } from "preact/hooks";
+import { alertFromError } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js";
+import { useTranslationContext } from "../../context/translation.js";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { AccountByType, Props, State } from "./index.js";
@@ -31,6 +33,7 @@ export function useComponentState({
onCancel,
}: Props): State {
const api = useBackendContext();
+ const { i18n } = useTranslationContext();
const hook = useAsyncAsHook(() =>
api.wallet.call(WalletApiOperation.ListKnownBankAccounts, { currency }),
);
@@ -47,8 +50,8 @@ export function useComponentState({
}
if (hook.hasError) {
return {
- status: "loading-error",
- error: hook,
+ status: "error",
+ error: alertFromError(i18n.str`Could not load known bank accounts`, hook),
};
}
diff --git a/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx b/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx
index 3af0d5505..e5be8d17d 100644
--- a/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx
@@ -23,11 +23,10 @@ import {
import { styled } from "@linaria/react";
import { Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks";
-import { LoadingError } from "../../components/LoadingError.js";
+import { ErrorMessage } from "../../components/ErrorMessage.js";
import { SelectList } from "../../components/SelectList.js";
import {
Input,
- LightText,
SubTitle,
SvgIcon,
WarningText,
@@ -37,10 +36,9 @@ import { Button } from "../../mui/Button.js";
import { TextFieldHandler } from "../../mui/handlers.js";
import { TextField } from "../../mui/TextField.js";
import checkIcon from "../../svg/check_24px.svg";
-import warningIcon from "../../svg/warning_24px.svg";
import deleteIcon from "../../svg/delete_24px.svg";
+import warningIcon from "../../svg/warning_24px.svg";
import { State } from "./index.js";
-import { ErrorMessage } from "../../components/ErrorMessage.js";
type AccountType = "bitcoin" | "x-taler-bank" | "iban";
type ComponentFormByAccountType = {
@@ -80,17 +78,6 @@ const AccountTable = styled.table`
}
`;
-export function LoadingUriView({ error }: State.LoadingUriError): VNode {
- const { i18n } = useTranslationContext();
-
- return (
- <LoadingError
- title={<i18n.Translate>Could not load</i18n.Translate>}
- error={error}
- />
- );
-}
-
export function ReadyView({
currency,
error,
@@ -118,14 +105,14 @@ export function ReadyView({
{error && (
<ErrorMessage
- title={<i18n.Translate>Unable add this account</i18n.Translate>}
+ title={i18n.str`Unable add this account`}
description={error}
/>
)}
<p>
<Input>
<SelectList
- label={<i18n.Translate>Select account type</i18n.Translate>}
+ label={i18n.str`Select account type`}
list={accountType.list}
name="accountType"
value={accountType.value}