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/popup | |
parent | 14f3d1e06dda003d457f2b3531e197011a284244 (diff) | |
download | wallet-core-9b04d8bf3581d162cbd631892ca115df811c46f8.tar.xz |
fix #7152
Diffstat (limited to 'packages/taler-wallet-webextension/src/popup')
-rw-r--r-- | packages/taler-wallet-webextension/src/popup/BalancePage.tsx | 24 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/popup/NoBalanceHelp.tsx | 2 |
2 files changed, 9 insertions, 17 deletions
diff --git a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx index 8786b2ff7..96f0f6dd9 100644 --- a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx +++ b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx @@ -19,12 +19,13 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { Fragment, h, VNode } from "preact"; import { useEffect, useState } from "preact/hooks"; import { BalanceTable } from "../components/BalanceTable.js"; +import { ErrorAlertView } from "../components/CurrentAlerts.js"; import { Loading } from "../components/Loading.js"; -import { LoadingError } from "../components/LoadingError.js"; import { MultiActionButton } from "../components/MultiActionButton.js"; +import { alertFromError, ErrorAlert } from "../context/alert.js"; import { useBackendContext } from "../context/backend.js"; import { useTranslationContext } from "../context/translation.js"; -import { HookError, useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; +import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { Button } from "../mui/Button.js"; import { ButtonHandler } from "../mui/handlers.js"; import { compose, StateViewMap } from "../utils/index.js"; @@ -47,7 +48,7 @@ export namespace State { export interface Error { status: "error"; - error: HookError; + error: ErrorAlert; } export interface Action { @@ -73,6 +74,7 @@ function useComponentState({ goToWalletManualWithdraw, }: Props): State { const api = useBackendContext(); + const { i18n } = useTranslationContext(); const [addingAction, setAddingAction] = useState(false); const state = useAsyncAsHook(() => api.wallet.call(WalletApiOperation.GetBalances, {}), @@ -94,7 +96,7 @@ function useComponentState({ if (state.hasError) { return { status: "error", - error: state, + error: alertFromError(i18n.str`Could not load the balance`, state), }; } if (addingAction) { @@ -123,7 +125,7 @@ function useComponentState({ const viewMapping: StateViewMap<State> = { loading: Loading, - error: ErrorView, + error: ErrorAlertView, action: ActionView, balance: BalanceView, }; @@ -134,16 +136,6 @@ export const BalancePage = compose( viewMapping, ); -function ErrorView({ error }: State.Error): VNode { - const { i18n } = useTranslationContext(); - return ( - <LoadingError - title={<i18n.Translate>Could not load balance page</i18n.Translate>} - error={error} - /> - ); -} - function ActionView({ cancel }: State.Action): VNode { return <AddNewActionView onCancel={cancel.onClick!} />; } @@ -179,7 +171,7 @@ export function BalanceView(state: State.Balances): VNode { </Button> {currencyWithNonZeroAmount.length > 0 && ( <MultiActionButton - label={(s) => <i18n.Translate>Send {s}</i18n.Translate>} + label={(s) => i18n.str`Send ${s}`} actions={currencyWithNonZeroAmount} onClick={(c) => state.goToWalletDeposit(c)} /> diff --git a/packages/taler-wallet-webextension/src/popup/NoBalanceHelp.tsx b/packages/taler-wallet-webextension/src/popup/NoBalanceHelp.tsx index 7d2e15726..5eb31ba46 100644 --- a/packages/taler-wallet-webextension/src/popup/NoBalanceHelp.tsx +++ b/packages/taler-wallet-webextension/src/popup/NoBalanceHelp.tsx @@ -33,7 +33,7 @@ export function NoBalanceHelp({ const { i18n } = useTranslationContext(); return ( <Paper class={margin}> - <Alert title="Your wallet is empty." severity="info"> + <Alert title={i18n.str`Your wallet is empty.`} severity="info"> <Button fullWidth color="info" |