From 9b04d8bf3581d162cbd631892ca115df811c46f8 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 9 Jan 2023 08:38:48 -0300 Subject: fix #7152 --- .../src/wallet/ManageAccount/index.ts | 11 ++++++----- .../src/wallet/ManageAccount/state.ts | 7 +++++-- .../src/wallet/ManageAccount/views.tsx | 21 ++++----------------- 3 files changed, 15 insertions(+), 24 deletions(-) (limited to 'packages/taler-wallet-webextension/src/wallet/ManageAccount') 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 = { 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 ( - Could not load} - error={error} - /> - ); -} - export function ReadyView({ currency, error, @@ -118,14 +105,14 @@ export function ReadyView({ {error && ( Unable add this account} + title={i18n.str`Unable add this account`} description={error} /> )}

Select account type} + label={i18n.str`Select account type`} list={accountType.list} name="accountType" value={accountType.value} -- cgit v1.2.3