diff options
Diffstat (limited to 'packages/demobank-ui/src/pages/admin/AdminHome.tsx')
-rw-r--r-- | packages/demobank-ui/src/pages/admin/AdminHome.tsx | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/packages/demobank-ui/src/pages/admin/AdminHome.tsx b/packages/demobank-ui/src/pages/admin/AdminHome.tsx index f0f8f71be..1a7edd6b9 100644 --- a/packages/demobank-ui/src/pages/admin/AdminHome.tsx +++ b/packages/demobank-ui/src/pages/admin/AdminHome.tsx @@ -37,21 +37,22 @@ import { } from "date-fns"; import { Fragment, VNode, h } from "preact"; import { useState } from "preact/hooks"; -import { privatePages } from "../../Routing.js"; import { ErrorLoadingWithDebug } from "../../components/ErrorLoadingWithDebug.js"; import { Transactions } from "../../components/Transactions/index.js"; import { useBankCoreApiContext } from "../../context/config.js"; import { useConversionInfo, useLastMonitorInfo } from "../../hooks/circuit.js"; +import { RouteDefinition } from "../../route.js"; import { RenderAmount } from "../PaytoWireTransferForm.js"; import { WireTransfer } from "../WireTransfer.js"; import { AccountList } from "./AccountList.js"; -import { RouteDefinition } from "../../route.js"; /** * Query account information and show QR code if there is pending withdrawal */ interface Props { routeCreate: RouteDefinition<Record<string, never>>; + routeDownloadStats: RouteDefinition<Record<string, never>>; + routeCreateWireTransfer: RouteDefinition<{ destination: string }>; routeShowAccount: RouteDefinition<{ account: string }>; routeRemoveAccount: RouteDefinition<{ account: string }>; @@ -65,14 +66,16 @@ export function AdminHome({ routeShowAccount, routeShowCashoutsAccount, routeUpdatePasswordAccount, + routeDownloadStats, + routeCreateWireTransfer, onAuthorizationRequired, }: Props): VNode { return ( <Fragment> - <Metrics /> + <Metrics routeDownloadStats={routeDownloadStats} /> <WireTransfer onAuthorizationRequired={onAuthorizationRequired} /> - <Transactions account="admin" /> + <Transactions account="admin" routeCreateWireTransfer={routeCreateWireTransfer} /> <AccountList routeCreate={routeCreate} routeRemoveAccount={routeRemoveAccount} @@ -140,7 +143,9 @@ export function getTimeframesForDate( } } -function Metrics(): VNode { +function Metrics({ routeDownloadStats }: { + routeDownloadStats: RouteDefinition<Record<string, never>>; +}): VNode { const { i18n, dateLocale } = useTranslationContext(); const [metricType, setMetricType] = useState<TalerCorebankApi.MonitorTimeframeParam>( @@ -335,7 +340,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"> {resp.current.body.type !== "with-conversions" || - resp.previous.body.type !== "with-conversions" ? undefined : ( + 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"> @@ -382,7 +387,7 @@ function Metrics(): VNode { </dl> <div class="flex justify-end mt-2"> <a - href={privatePages.statsDownload.url({})} + href={routeDownloadStats.url({})} class="disabled:opacity-50 disabled:cursor-default cursor-pointer rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" > <i18n.Translate>Download stats as CSV</i18n.Translate> @@ -411,9 +416,9 @@ function MetricValue({ const rate = !currAmount || - Number.isNaN(currAmount) || - !prevAmount || - Number.isNaN(prevAmount) + Number.isNaN(currAmount) || + !prevAmount || + Number.isNaN(prevAmount) ? 0 : cmp === -1 ? 1 - Math.round(currAmount) / Math.round(prevAmount) |