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/cta/TransferCreate | |
parent | 14f3d1e06dda003d457f2b3531e197011a284244 (diff) | |
download | wallet-core-9b04d8bf3581d162cbd631892ca115df811c46f8.tar.xz |
fix #7152
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/TransferCreate')
3 files changed, 23 insertions, 36 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/TransferCreate/index.ts b/packages/taler-wallet-webextension/src/cta/TransferCreate/index.ts index 0715bb60e..b191b4efa 100644 --- a/packages/taler-wallet-webextension/src/cta/TransferCreate/index.ts +++ b/packages/taler-wallet-webextension/src/cta/TransferCreate/index.ts @@ -15,12 +15,13 @@ */ import { AmountJson, TalerErrorDetail } 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, TextFieldHandler } 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 { amount: string; @@ -37,8 +38,8 @@ export namespace State { } export interface LoadingUriError { - status: "loading-uri"; - error: HookError; + status: "error"; + error: ErrorAlert; } export interface BaseInfo { @@ -59,7 +60,7 @@ export namespace State { const viewMapping: StateViewMap<State> = { loading: Loading, - "loading-uri": LoadingUriView, + error: ErrorAlertView, ready: ReadyView, }; diff --git a/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts b/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts index c09a524c8..ecea53848 100644 --- a/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts +++ b/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts @@ -22,7 +22,9 @@ import { import { TalerError, WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { isFuture, parse } from "date-fns"; 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"; @@ -33,6 +35,7 @@ export function useComponentState({ }: Props): State { const api = useBackendContext(); const amount = Amounts.parseOrThrow(amountStr); + const { i18n } = useTranslationContext(); const [subject, setSubject] = useState<string | undefined>(); const [timestamp, setTimestamp] = useState<string | undefined>(); @@ -59,10 +62,19 @@ export function useComponentState({ } if (hook.hasError) { return { - status: "loading-uri", - error: hook, + status: "error", + error: alertFromError( + i18n.str`Could not load the status of the term of service`, + hook, + ), }; } + // if (hook.hasError) { + // return { + // status: "loading-uri", + // error: hook, + // }; + // } const { amountEffective, amountRaw } = hook.response; const debitAmount = Amounts.parseOrThrow(amountRaw); diff --git a/packages/taler-wallet-webextension/src/cta/TransferCreate/views.tsx b/packages/taler-wallet-webextension/src/cta/TransferCreate/views.tsx index 0b034e3fb..cee61b3b8 100644 --- a/packages/taler-wallet-webextension/src/cta/TransferCreate/views.tsx +++ b/packages/taler-wallet-webextension/src/cta/TransferCreate/views.tsx @@ -17,10 +17,8 @@ import { format } from "date-fns"; import { h, VNode } from "preact"; import { ErrorTalerOperation } from "../../components/ErrorTalerOperation.js"; -import { LoadingError } from "../../components/LoadingError.js"; import { LogoHeader } from "../../components/LogoHeader.js"; import { Part } from "../../components/Part.js"; -import { QR } from "../../components/QR.js"; import { Link, SubTitle, WalletAction } from "../../components/styled/index.js"; import { useTranslationContext } from "../../context/translation.js"; import { Button } from "../../mui/Button.js"; @@ -28,17 +26,6 @@ import { TextField } from "../../mui/TextField.js"; import { TransferDetails } from "../../wallet/Transaction.js"; import { State } from "./index.js"; -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({ subject, expiration, @@ -80,11 +67,7 @@ export function ReadyView({ </SubTitle> {operationError && ( <ErrorTalerOperation - title={ - <i18n.Translate> - Could not finish the transfer creation - </i18n.Translate> - } + title={i18n.str`Could not finish the transfer creation`} error={operationError} /> )} @@ -93,9 +76,7 @@ export function ReadyView({ <TextField label="Subject" variant="filled" - helperText={ - <i18n.Translate>Short description of the transfer</i18n.Translate> - } + helperText={i18n.str`Short description of the transfer`} error={subject.error} required fullWidth @@ -138,7 +119,7 @@ export function ReadyView({ </p> </p> <Part - title={<i18n.Translate>Details</i18n.Translate>} + title={i18n.str`Details`} text={ <TransferDetails amount={{ @@ -154,13 +135,6 @@ export function ReadyView({ <i18n.Translate>Create</i18n.Translate> </Button> </section> - <section> - <section> - <Link upperCased onClick={cancel.onClick}> - <i18n.Translate>Cancel</i18n.Translate> - </Link> - </section> - </section> </WalletAction> ); } |