diff options
author | Sebastian <sebasjm@gmail.com> | 2023-01-09 08:38:48 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-01-09 08:38:48 -0300 |
commit | 9b04d8bf3581d162cbd631892ca115df811c46f8 (patch) | |
tree | 42b7da7cc3a3f8186823a7571aa221dc8e9aa7a5 /packages/taler-wallet-webextension/src/wallet/ExchangeSelection | |
parent | 14f3d1e06dda003d457f2b3531e197011a284244 (diff) | |
download | wallet-core-9b04d8bf3581d162cbd631892ca115df811c46f8.tar.xz |
fix #7152
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet/ExchangeSelection')
3 files changed, 15 insertions, 28 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/index.ts b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/index.ts index 10e44ce7d..299c236c4 100644 --- a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/index.ts +++ b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/index.ts @@ -20,7 +20,9 @@ import { ExchangeListItem, FeeDescriptionPair, } from "@gnu-taler/taler-util"; +import { ErrorAlertView } from "../../components/CurrentAlerts.js"; import { Loading } from "../../components/Loading.js"; +import { ErrorAlert } from "../../context/alert.js"; import { HookError } from "../../hooks/useAsyncAsHook.js"; import { State as SelectExchangeState } from "../../hooks/useSelectedExchange.js"; import { ButtonHandler, SelectFieldHandler } from "../../mui/handlers.js"; @@ -28,7 +30,6 @@ import { compose, StateViewMap } from "../../utils/index.js"; import { useComponentState } from "./state.js"; import { ComparingView, - ErrorLoadingView, NoExchangesView, PrivacyContentView, ReadyView, @@ -58,8 +59,8 @@ export namespace State { } export interface LoadingUriError { - status: "error-loading"; - error: HookError; + status: "error"; + error: ErrorAlert; } export interface BaseInfo { @@ -99,7 +100,7 @@ export namespace State { const viewMapping: StateViewMap<State> = { loading: Loading, - "error-loading": ErrorLoadingView, + error: ErrorAlertView, comparing: ComparingView, "no-exchange": NoExchangesView, "showing-tos": TosContentView, diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts index 3c10febd9..cfb32cbbb 100644 --- a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts +++ b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts @@ -20,7 +20,9 @@ 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 { Props, State } from "./index.js"; @@ -31,6 +33,7 @@ export function useComponentState({ currentExchange, }: Props): State { const api = useBackendContext(); + const { i18n } = useTranslationContext(); const initialValue = exchanges.findIndex( (e) => e.exchangeBaseUrl === currentExchange, ); @@ -84,8 +87,11 @@ export function useComponentState({ } if (hook.hasError) { return { - status: "error-loading", - error: hook, + status: "error", + error: alertFromError( + i18n.str`Could not load exchange details info`, + hook, + ), }; } diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/views.tsx b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/views.tsx index 26ff2c0d3..d01ce7ca0 100644 --- a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/views.tsx +++ b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/views.tsx @@ -20,7 +20,6 @@ import { Fragment, h, VNode } from "preact"; import { useState } from "preact/hooks"; import { Amount } from "../../components/Amount.js"; import { ErrorMessage } from "../../components/ErrorMessage.js"; -import { LoadingError } from "../../components/LoadingError.js"; import { SelectList } from "../../components/SelectList.js"; import { Input, SvgIcon } from "../../components/styled/index.js"; import { TermsOfService } from "../../components/TermsOfService/index.js"; @@ -110,17 +109,6 @@ const Container = styled.div` } `; -export function ErrorLoadingView({ error }: State.LoadingUriError): VNode { - const { i18n } = useTranslationContext(); - - return ( - <LoadingError - title={<i18n.Translate>Could not load exchange fees</i18n.Translate>} - error={error} - /> - ); -} - export function PrivacyContentView({ exchangeUrl, onClose, @@ -156,19 +144,11 @@ export function NoExchangesView({ }: SelectExchangeState.NoExchange): VNode { const { i18n } = useTranslationContext(); if (!currency) { - return ( - <ErrorMessage - title={<i18n.Translate>Could not find any exchange</i18n.Translate>} - /> - ); + return <ErrorMessage title={i18n.str`Could not find any exchange`} />; } return ( <ErrorMessage - title={ - <i18n.Translate> - Could not find any exchange for the currency {currency} - </i18n.Translate> - } + title={i18n.str`Could not find any exchange for the currency ${currency}`} /> ); } |