commit e7d8c560ad9e9ac940cab3f5f0b938290843b1ca parent 0180eb059aad601c49721aec57b0f3cd60c1d079 Author: Sebastian <sebasjm@taler-systems.com> Date: Thu, 5 Feb 2026 16:02:54 -0300 use the commong render amount Diffstat:
14 files changed, 26 insertions(+), 63 deletions(-)
diff --git a/packages/bank-ui/src/components/Cashouts/views.tsx b/packages/bank-ui/src/components/Cashouts/views.tsx @@ -25,12 +25,12 @@ import { Attention, ErrorLoading, Loading, + RenderAmount, Time, useTranslationContext, } from "@gnu-taler/web-util/browser"; import { format } from "date-fns"; import { Fragment, VNode, h } from "preact"; -import { RenderAmount } from "../../pages/PaytoWireTransferForm.js"; import { State } from "./index.js"; import { useConversionInfo } from "../../hooks/regional.js"; diff --git a/packages/bank-ui/src/components/Transactions/views.tsx b/packages/bank-ui/src/components/Transactions/views.tsx @@ -16,13 +16,13 @@ import { Attention, + RenderAmount, Time, useBankCoreApiContext, useTranslationContext, } from "@gnu-taler/web-util/browser"; import { format } from "date-fns"; import { Fragment, VNode, h } from "preact"; -import { RenderAmount } from "../../pages/PaytoWireTransferForm.js"; import { State } from "./index.js"; const TALER_SCREEN_ID = 4; diff --git a/packages/bank-ui/src/pages/BankFrame.tsx b/packages/bank-ui/src/pages/BankFrame.tsx @@ -26,6 +26,7 @@ import { Footer, Header, Loading, + RenderAmount, RouteDefinition, ToastBanner, logBugForDevelopers, @@ -46,7 +47,6 @@ import { usePreferences, } from "../hooks/preferences.js"; import { useSessionState } from "../hooks/session.js"; -import { RenderAmount } from "./PaytoWireTransferForm.js"; const TALER_SCREEN_ID = 103; diff --git a/packages/bank-ui/src/pages/OperationState/views.tsx b/packages/bank-ui/src/pages/OperationState/views.tsx @@ -27,6 +27,7 @@ import { ButtonBetter, LocalNotificationBanner, notifyInfo, + RenderAmount, useBankCoreApiContext, useChallengeHandler, useLocalNotificationBetter, @@ -38,7 +39,7 @@ import { useEffect } from "preact/hooks"; import { QR } from "../../components/QR.js"; import { usePreferences } from "../../hooks/preferences.js"; import { LoggedIn, useSessionState } from "../../hooks/session.js"; -import { RenderAmount } from "../PaytoWireTransferForm.js"; + import { SolveMFAChallenges } from "../SolveMFA.js"; import { ShouldBeSameUser } from "../WithdrawalConfirmationQuestion.js"; import { State } from "./index.js"; diff --git a/packages/bank-ui/src/pages/PaytoWireTransferForm.tsx b/packages/bank-ui/src/pages/PaytoWireTransferForm.tsx @@ -18,7 +18,6 @@ import { AmountJson, AmountString, Amounts, - CurrencySpecification, FRAC_SEPARATOR, HostPortPath, HttpStatusCode, @@ -33,6 +32,7 @@ import { ButtonBetter, InternationalizationAPI, LocalNotificationBanner, + RenderAmount, RouteDefinition, ShowInputErrorLabel, notifyInfo, @@ -734,45 +734,6 @@ export function InputAmount( ); } -/** - * send to web-utils - * @param param0 - * @returns - */ -export function RenderAmount({ - value, - spec, - negative = false, - withColor = false, - hideSmall = false, - withSign = false, -}: { - spec: CurrencySpecification; - value: AmountJson; - hideSmall?: boolean; - negative?: boolean; - withColor?: boolean; - withSign?: boolean; -}): VNode { - const neg = !!negative; // convert to true or false - - const { currency, normal, small } = Amounts.stringifyValueWithSpec( - value, - spec, - ); - - return ( - <span - data-negative={withColor ? neg : undefined} - class="whitespace-nowrap data-[negative=false]:text-green-600 data-[negative=true]:text-red-600" - > - {withSign && negative ? "- " : undefined} - {currency} {normal}{" "} - {!hideSmall && small && <sup class="-ml-1">{small}</sup>} - </span> - ); -} - function validateRawPayto( parsed: Paytos.URI, limit: AmountJson, diff --git a/packages/bank-ui/src/pages/WalletWithdrawForm.tsx b/packages/bank-ui/src/pages/WalletWithdrawForm.tsx @@ -16,18 +16,19 @@ import { AmountJson, + AmountString, Amounts, HttpStatusCode, - TalerCorebankApi, TalerUriAction, TalerUris, UserAndToken, - assertUnreachable, + assertUnreachable } from "@gnu-taler/taler-util"; import { Attention, ButtonBetter, LocalNotificationBanner, + RenderAmount, RouteDefinition, ShowInputErrorLabel, notifyError, @@ -46,11 +47,9 @@ import { undefinedIfEmpty } from "../utils.js"; import { OperationState } from "./OperationState/index.js"; import { InputAmount, - RenderAmount, doAutoFocus, } from "./PaytoWireTransferForm.js"; import { IntAmountJson } from "./regional/CreateCashout.js"; -import { AmountString } from "@gnu-taler/taler-util"; const TALER_SCREEN_ID = 112; diff --git a/packages/bank-ui/src/pages/WithdrawalConfirmationQuestion.tsx b/packages/bank-ui/src/pages/WithdrawalConfirmationQuestion.tsx @@ -28,6 +28,7 @@ import { Attention, ButtonBetter, LocalNotificationBanner, + RenderAmount, useBankCoreApiContext, useChallengeHandler, useLocalNotificationBetter, @@ -37,7 +38,6 @@ import { ComponentChildren, Fragment, VNode, h } from "preact"; import { mutate } from "swr"; import { LoggedIn, useSessionState } from "../hooks/session.js"; import { LoginForm } from "./LoginForm.js"; -import { RenderAmount } from "./PaytoWireTransferForm.js"; import { SolveMFAChallenges } from "./SolveMFA.js"; const TALER_SCREEN_ID = 114; diff --git a/packages/bank-ui/src/pages/admin/AccountList.tsx b/packages/bank-ui/src/pages/admin/AccountList.tsx @@ -22,6 +22,7 @@ import { import { ErrorLoading, Loading, + RenderAmount, RouteDefinition, useBankCoreApiContext, useTranslationContext, @@ -29,7 +30,6 @@ import { import { Fragment, VNode, h } from "preact"; import { useBusinessAccounts } from "../../hooks/regional.js"; -import { RenderAmount } from "../PaytoWireTransferForm.js"; const TALER_SCREEN_ID = 121; diff --git a/packages/bank-ui/src/pages/admin/AdminHome.tsx b/packages/bank-ui/src/pages/admin/AdminHome.tsx @@ -27,6 +27,7 @@ import { import { Attention, ErrorLoading, + RenderAmount, RouteDefinition, useBankCoreApiContext, useTranslationContext, @@ -37,7 +38,7 @@ import { useState } from "preact/hooks"; import { Transactions } from "../../components/Transactions/index.js"; import { useConversionInfo, useLastMonitorInfo } from "../../hooks/regional.js"; -import { RenderAmount } from "../PaytoWireTransferForm.js"; + import { WireTransfer } from "../WireTransfer.js"; import { AccountList } from "./AccountList.js"; import { ConversionClassList } from "./ConversionClassList.js"; diff --git a/packages/bank-ui/src/pages/admin/ConversionClassList.tsx b/packages/bank-ui/src/pages/admin/ConversionClassList.tsx @@ -26,6 +26,7 @@ import { Attention, ErrorLoading, Loading, + RenderAmount, RouteDefinition, useTranslationContext } from "@gnu-taler/web-util/browser"; @@ -36,7 +37,7 @@ import { useConversionInfo, useConversionRateClasses, } from "../../hooks/regional.js"; -import { RenderAmount } from "../PaytoWireTransferForm.js"; + const TALER_SCREEN_ID = 130; diff --git a/packages/bank-ui/src/pages/regional/ConversionConfig.tsx b/packages/bank-ui/src/pages/regional/ConversionConfig.tsx @@ -15,14 +15,12 @@ */ import { - AbsoluteTime, AmountJson, Amounts, HttpStatusCode, TalerBankConversionApi, TalerError, - TranslatedString, - assertUnreachable, + assertUnreachable } from "@gnu-taler/taler-util"; import { Attention, @@ -31,6 +29,7 @@ import { InternationalizationAPI, Loading, LocalNotificationBanner, + RenderAmount, RouteDefinition, ShowInputErrorLabel, useBankCoreApiContext, @@ -56,13 +55,11 @@ import { } from "../../hooks/regional.js"; import { useSessionState } from "../../hooks/session.js"; import { undefinedIfEmpty } from "../../utils.js"; -import { InputAmount, RenderAmount } from "../PaytoWireTransferForm.js"; +import { InputAmount } from "../PaytoWireTransferForm.js"; import { ProfileNavigation } from "../ProfileNavigation.js"; +import { TalerErrorCode, opFixedSuccess } from "@gnu-taler/taler-util"; import { DescribeConversion } from "../admin/ConversionClassList.js"; -import { opEmptySuccess } from "@gnu-taler/taler-util"; -import { opFixedSuccess } from "@gnu-taler/taler-util"; -import { TalerErrorCode } from "@gnu-taler/taler-util"; const TALER_SCREEN_ID = 126; diff --git a/packages/bank-ui/src/pages/regional/CreateCashout.tsx b/packages/bank-ui/src/pages/regional/CreateCashout.tsx @@ -31,6 +31,7 @@ import { ErrorLoading, Loading, LocalNotificationBanner, + RenderAmount, RouteDefinition, ShowInputErrorLabel, notifyInfo, @@ -60,7 +61,6 @@ import { TanChannel, undefinedIfEmpty } from "../../utils.js"; import { LoginForm } from "../LoginForm.js"; import { InputAmount, - RenderAmount, doAutoFocus, } from "../PaytoWireTransferForm.js"; import { SolveMFAChallenges } from "../SolveMFA.js"; diff --git a/packages/bank-ui/src/pages/regional/ShowCashoutDetails.tsx b/packages/bank-ui/src/pages/regional/ShowCashoutDetails.tsx @@ -24,6 +24,7 @@ import { Attention, ErrorLoading, Loading, + RenderAmount, RouteDefinition, Time, useTranslationContext, @@ -31,7 +32,6 @@ import { import { VNode, h } from "preact"; import { useCashoutDetails, useConversionInfo } from "../../hooks/regional.js"; -import { RenderAmount } from "../PaytoWireTransferForm.js"; const TALER_SCREEN_ID = 128; diff --git a/packages/web-util/src/components/RenderAmount.tsx b/packages/web-util/src/components/RenderAmount.tsx @@ -7,8 +7,9 @@ import { h, VNode } from "preact"; * @param value the amount to be rendered * @param spec currency specification * @param hideSmall don't show very tiny value + * @param negative if the value specified by amount is negative * @param withColor show negative as red and positive as green - * @param negative show a minus sign on negative value + * @param withSign include a minus for negatives * @returns */ export function RenderAmount({ @@ -16,6 +17,7 @@ export function RenderAmount({ spec, negative, withColor, + withSign, hideSmall, }: { spec: CurrencySpecification; @@ -23,6 +25,7 @@ export function RenderAmount({ hideSmall?: boolean; negative?: boolean; withColor?: boolean; + withSign?: boolean; }): VNode { const neg = !!negative; // convert to true or false @@ -36,7 +39,7 @@ export function RenderAmount({ data-negative={withColor ? neg : undefined} class="whitespace-nowrap data-[negative=false]:text-green-600 data-[negative=true]:text-red-600" > - {negative ? "- " : undefined} + {withSign && negative ? "- " : undefined} {currency} {normal}{" "} {!hideSmall && small && <sup class="-ml-1">{small}</sup>} </span>