diff options
author | Sebastian <sebasjm@gmail.com> | 2023-12-08 12:57:28 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-12-08 12:57:28 -0300 |
commit | be741548a5c9325164bccc90056d490e85842e69 (patch) | |
tree | 13df131a95e3b08be39e0a4f5c6a555d57518ed7 /packages/demobank-ui/src/components | |
parent | 13f397521c0bb2b1587fa287de5be49c74f69d12 (diff) | |
download | wallet-core-be741548a5c9325164bccc90056d490e85842e69.tar.xz |
error handling
Diffstat (limited to 'packages/demobank-ui/src/components')
6 files changed, 19 insertions, 42 deletions
diff --git a/packages/demobank-ui/src/components/Cashouts/index.ts b/packages/demobank-ui/src/components/Cashouts/index.ts index ca58de98f..571f23184 100644 --- a/packages/demobank-ui/src/components/Cashouts/index.ts +++ b/packages/demobank-ui/src/components/Cashouts/index.ts @@ -14,14 +14,11 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { ErrorLoading, HttpError, utils } from "@gnu-taler/web-util/browser"; -import { Loading } from "@gnu-taler/web-util/browser"; -// import { compose, StateViewMap } from "../../utils/index.js"; -// import { wxApi } from "../../wxApi.js"; +import { Loading, utils } from "@gnu-taler/web-util/browser"; import { AbsoluteTime, AmountJson, TalerCoreBankErrorsByMethod, TalerCorebankApi, TalerError } from "@gnu-taler/taler-util"; +import { ErrorLoadingWithDebug } from "../ErrorLoadingWithDebug.js"; import { useComponentState } from "./state.js"; -import { FailedView, LoadingUriView, ReadyView } from "./views.js"; -import { h } from "preact"; +import { FailedView, ReadyView } from "./views.js"; export interface Props { account: string; @@ -67,9 +64,7 @@ export interface Transaction { const viewMapping: utils.StateViewMap<State> = { loading: Loading, - "loading-error": ({error}) => { - return h(ErrorLoading, {error, showDetail:true}); - }, + "loading-error": ErrorLoadingWithDebug, "failed": FailedView, ready: ReadyView, }; diff --git a/packages/demobank-ui/src/components/Cashouts/views.tsx b/packages/demobank-ui/src/components/Cashouts/views.tsx index 115a2e014..341c43b48 100644 --- a/packages/demobank-ui/src/components/Cashouts/views.tsx +++ b/packages/demobank-ui/src/components/Cashouts/views.tsx @@ -15,23 +15,14 @@ */ import { Amounts, TalerError, assertUnreachable } from "@gnu-taler/taler-util"; -import { Attention, ErrorLoading, Loading, useTranslationContext } from "@gnu-taler/web-util/browser"; +import { Attention, Loading, useTranslationContext } from "@gnu-taler/web-util/browser"; import { format } from "date-fns"; -import { Fragment, h, VNode } from "preact"; -import { RenderAmount } from "../../pages/PaytoWireTransferForm.js"; -import { State } from "./index.js"; +import { Fragment, VNode, h } from "preact"; import { useConversionInfo } from "../../hooks/circuit.js"; +import { RenderAmount } from "../../pages/PaytoWireTransferForm.js"; import { ErrorLoadingWithDebug } from "../ErrorLoadingWithDebug.js"; +import { State } from "./index.js"; -export function LoadingUriView({ error }: State.LoadingUriError): VNode { - const { i18n } = useTranslationContext(); - - return ( - <div> - <i18n.Translate>Could not load</i18n.Translate> - </div> - ); -} export function FailedView({ error }: State.Failed) { const { i18n } = useTranslationContext(); switch (error.case) { diff --git a/packages/demobank-ui/src/components/EmptyComponentExample/views.tsx b/packages/demobank-ui/src/components/EmptyComponentExample/views.tsx index 6c2ce8013..5e0a5f0d2 100644 --- a/packages/demobank-ui/src/components/EmptyComponentExample/views.tsx +++ b/packages/demobank-ui/src/components/EmptyComponentExample/views.tsx @@ -23,7 +23,6 @@ export function LoadingUriView({ error }: State.LoadingUriError): VNode { return ( <div> - <i18n.Translate>Could not load</i18n.Translate> </div> ); } diff --git a/packages/demobank-ui/src/components/ErrorLoadingWithDebug.tsx b/packages/demobank-ui/src/components/ErrorLoadingWithDebug.tsx index 8cdac4561..25e79e9e0 100644 --- a/packages/demobank-ui/src/components/ErrorLoadingWithDebug.tsx +++ b/packages/demobank-ui/src/components/ErrorLoadingWithDebug.tsx @@ -1,7 +1,7 @@ +import { TalerError } from "@gnu-taler/taler-util"; import { ErrorLoading } from "@gnu-taler/web-util/browser"; -import { usePreferences } from "../hooks/preferences.js"; import { VNode, h } from "preact"; -import { TalerError } from "@gnu-taler/taler-util"; +import { usePreferences } from "../hooks/preferences.js"; export function ErrorLoadingWithDebug({ error }: { error: TalerError }): VNode { const [pref] = usePreferences(); diff --git a/packages/demobank-ui/src/components/Transactions/index.ts b/packages/demobank-ui/src/components/Transactions/index.ts index b95aa4cb1..b6a78deb1 100644 --- a/packages/demobank-ui/src/components/Transactions/index.ts +++ b/packages/demobank-ui/src/components/Transactions/index.ts @@ -14,10 +14,11 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { Loading, utils } from "@gnu-taler/web-util/browser"; import { AbsoluteTime, AmountJson, TalerError } from "@gnu-taler/taler-util"; +import { Loading, utils } from "@gnu-taler/web-util/browser"; +import { ErrorLoadingWithDebug } from "../ErrorLoadingWithDebug.js"; import { useComponentState } from "./state.js"; -import { LoadingUriView, ReadyView } from "./views.js"; +import { ReadyView } from "./views.js"; export interface Props { account: string; @@ -58,7 +59,7 @@ export interface Transaction { const viewMapping: utils.StateViewMap<State> = { loading: Loading, - "loading-error": LoadingUriView, + "loading-error": ErrorLoadingWithDebug, ready: ReadyView, }; diff --git a/packages/demobank-ui/src/components/Transactions/views.tsx b/packages/demobank-ui/src/components/Transactions/views.tsx index 1613cb06a..8a8a8f72e 100644 --- a/packages/demobank-ui/src/components/Transactions/views.tsx +++ b/packages/demobank-ui/src/components/Transactions/views.tsx @@ -17,23 +17,14 @@ import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { format } from "date-fns"; import { Fragment, h, VNode } from "preact"; -import { doAutoFocus, RenderAmount } from "../../pages/PaytoWireTransferForm.js"; -import { State } from "./index.js"; import { useBankCoreApiContext } from "../../context/config.js"; +import { RenderAmount } from "../../pages/PaytoWireTransferForm.js"; +import { State } from "./index.js"; -export function LoadingUriView({ error }: State.LoadingUriError): VNode { - const { i18n } = useTranslationContext(); - - return ( - <div> - <i18n.Translate>Could not load</i18n.Translate> - </div> - ); -} export function ReadyView({ transactions, onNext, onPrev }: State.Ready): VNode { const { i18n } = useTranslationContext(); - const {config} = useBankCoreApiContext(); + const { config } = useBankCoreApiContext(); if (!transactions.length) return <div /> const txByDate = transactions.reduce((prev, cur) => { const d = cur.when.t_ms === "never" @@ -80,7 +71,7 @@ export function ReadyView({ transactions, onNext, onPrev }: State.Ready): VNode <dd class="mt-1 truncate text-gray-700"> {item.negative ? i18n.str`sent` : i18n.str`received`} {item.amount ? ( <span data-negative={item.negative ? "true" : "false"} class="data-[negative=false]:text-green-600 data-[negative=true]:text-red-600"> - <RenderAmount value={item.amount} spec={config.currency_specification}/> + <RenderAmount value={item.amount} spec={config.currency_specification} /> </span> ) : ( <span style={{ color: "grey" }}><{i18n.str`invalid value`}></span> @@ -101,7 +92,7 @@ export function ReadyView({ transactions, onNext, onPrev }: State.Ready): VNode </td> <td data-negative={item.negative ? "true" : "false"} class="hidden sm:table-cell px-3 py-3.5 text-sm text-gray-500 "> - {item.amount ? (<RenderAmount value={item.amount} negative={item.negative} withColor spec={config.currency_specification}/> + {item.amount ? (<RenderAmount value={item.amount} negative={item.negative} withColor spec={config.currency_specification} /> ) : ( <span style={{ color: "grey" }}><{i18n.str`invalid value`}></span> )} |