From 9b04d8bf3581d162cbd631892ca115df811c46f8 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 9 Jan 2023 08:38:48 -0300 Subject: fix #7152 --- .../src/cta/Recovery/index.ts | 11 ++++++----- .../src/cta/Recovery/state.ts | 23 ++++++++++++++-------- .../src/cta/Recovery/views.tsx | 16 --------------- 3 files changed, 21 insertions(+), 29 deletions(-) (limited to 'packages/taler-wallet-webextension/src/cta/Recovery') diff --git a/packages/taler-wallet-webextension/src/cta/Recovery/index.ts b/packages/taler-wallet-webextension/src/cta/Recovery/index.ts index 4a6fc79c9..79056c15b 100644 --- a/packages/taler-wallet-webextension/src/cta/Recovery/index.ts +++ b/packages/taler-wallet-webextension/src/cta/Recovery/index.ts @@ -14,12 +14,13 @@ GNU Taler; see the file COPYING. If not, see */ +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 } 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 { talerRecoveryUri?: string; @@ -36,8 +37,8 @@ export namespace State { } export interface LoadingUriError { - status: "loading-uri"; - error: HookError; + status: "error"; + error: ErrorAlert; } export interface BaseInfo { @@ -53,7 +54,7 @@ export namespace State { const viewMapping: StateViewMap = { loading: Loading, - "loading-uri": LoadingUriView, + error: ErrorAlertView, ready: ReadyView, }; diff --git a/packages/taler-wallet-webextension/src/cta/Recovery/state.ts b/packages/taler-wallet-webextension/src/cta/Recovery/state.ts index 4fef2c862..078e53bf9 100644 --- a/packages/taler-wallet-webextension/src/cta/Recovery/state.ts +++ b/packages/taler-wallet-webextension/src/cta/Recovery/state.ts @@ -16,7 +16,9 @@ import { parseRecoveryUri } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { Alert } from "../../context/alert.js"; import { useBackendContext } from "../../context/backend.js"; +import { useTranslationContext } from "../../context/translation.js"; import { Props, State } from "./index.js"; export function useComponentState({ @@ -25,13 +27,16 @@ export function useComponentState({ onSuccess, }: Props): State { const api = useBackendContext(); + const { i18n } = useTranslationContext(); if (!talerRecoveryUri) { return { - status: "loading-uri", + status: "error", error: { - operational: false, - hasError: true, - message: "Missing URI", + type: "error", + message: i18n.str`Missing URI`, + description: i18n.str``, + cause: new Error("something"), + context: {}, }, }; } @@ -39,11 +44,13 @@ export function useComponentState({ if (!info) { return { - status: "loading-uri", + status: "error", error: { - operational: false, - hasError: true, - message: "Could not be read", + type: "error", + message: i18n.str`Could not parse the recovery URI`, + description: i18n.str``, + cause: new Error("something"), + context: {}, }, }; } diff --git a/packages/taler-wallet-webextension/src/cta/Recovery/views.tsx b/packages/taler-wallet-webextension/src/cta/Recovery/views.tsx index 371516932..858349ef3 100644 --- a/packages/taler-wallet-webextension/src/cta/Recovery/views.tsx +++ b/packages/taler-wallet-webextension/src/cta/Recovery/views.tsx @@ -15,28 +15,12 @@ */ import { Fragment, h, VNode } from "preact"; -import { LoadingError } from "../../components/LoadingError.js"; import { LogoHeader } from "../../components/LogoHeader.js"; import { SubTitle, WalletAction } from "../../components/styled/index.js"; import { useTranslationContext } from "../../context/translation.js"; import { Button } from "../../mui/Button.js"; import { State } from "./index.js"; -export function LoadingUriView({ error }: State.LoadingUriError): VNode { - const { i18n } = useTranslationContext(); - - return ( - - Could not load backup recovery information - - } - error={error} - /> - ); -} - export function ReadyView({ accept, cancel }: State.Ready): VNode { const { i18n } = useTranslationContext(); return ( -- cgit v1.2.3