diff options
Diffstat (limited to 'packages/demobank-ui/src/pages/admin')
-rw-r--r-- | packages/demobank-ui/src/pages/admin/AdminHome.tsx | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/packages/demobank-ui/src/pages/admin/AdminHome.tsx b/packages/demobank-ui/src/pages/admin/AdminHome.tsx index c03f228cd..b7ef3aa00 100644 --- a/packages/demobank-ui/src/pages/admin/AdminHome.tsx +++ b/packages/demobank-ui/src/pages/admin/AdminHome.tsx @@ -1,5 +1,5 @@ -import { AmountString, Amounts, CurrencySpecification, TalerCorebankApi, TalerError, assertUnreachable } from "@gnu-taler/taler-util"; -import { useLang, useTranslationContext } from "@gnu-taler/web-util/browser"; +import { AmountString, Amounts, CurrencySpecification, HttpStatusCode, TalerCorebankApi, TalerError, assertUnreachable } from "@gnu-taler/taler-util"; +import { Attention, useLang, useTranslationContext } from "@gnu-taler/web-util/browser"; import { format, getDate, getHours, getMonth, getYear, setDate, setHours, setMonth, setYear, sub } from "date-fns"; import { Fragment, VNode, h } from "preact"; import { useState } from "preact/hooks"; @@ -90,10 +90,23 @@ function Metrics(): VNode { if (resp instanceof TalerError) { return <ErrorLoadingWithDebug error={resp} /> } + if (!respInfo) return <Fragment />; + if (respInfo instanceof TalerError) { + return <ErrorLoadingWithDebug error={respInfo} /> + } + if (respInfo.type === "fail") { + switch (respInfo.case) { + case HttpStatusCode.NotImplemented: { + return <Attention type="danger" title={i18n.str`Cashout not implemented`}> + </Attention>; + } + default: assertUnreachable(respInfo.case) + } + } + if (resp.current.type !== "ok" || resp.previous.type !== "ok") { return <Fragment /> } - const fiatSpec = respInfo && (!(respInfo instanceof TalerError)) ? respInfo.body.fiat_currency_specification : undefined return <Fragment> <div class="sm:hidden"> <label for="tabs" class="sr-only"><i18n.Translate>Select a section</i18n.Translate></label> @@ -135,7 +148,7 @@ function Metrics(): VNode { </div> <dl class="mt-5 grid grid-cols-1 md:grid-cols-2 divide-y divide-gray-200 overflow-hidden rounded-lg bg-white shadow-lg md:divide-x md:divide-y-0"> - {!fiatSpec || resp.current.body.type !== "with-conversions" || resp.previous.body.type !== "with-conversions" ? undefined : + {resp.current.body.type !== "with-conversions" || resp.previous.body.type !== "with-conversions" ? undefined : <Fragment> <div class="px-4 py-5 sm:p-6"> <dt class="text-base font-normal text-gray-900"> @@ -144,7 +157,7 @@ function Metrics(): VNode { <MetricValue current={resp.current.body.cashinFiatVolume} previous={resp.previous.body.cashinFiatVolume} - spec={fiatSpec} + spec={respInfo.body.fiat_currency_specification} /> </div> <div class="px-4 py-5 sm:p-6"> @@ -154,7 +167,7 @@ function Metrics(): VNode { <MetricValue current={resp.current.body.cashoutFiatVolume} previous={resp.previous.body.cashoutFiatVolume} - spec={fiatSpec} + spec={respInfo.body.fiat_currency_specification} /> </div> </Fragment> |