From 2bd6dae00d420d3b17a636c206785f06f2f7ae29 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 11 Apr 2022 11:33:55 -0300 Subject: show amount nicely, into a component --- packages/taler-wallet-webextension/src/cta/Pay.tsx | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'packages/taler-wallet-webextension/src/cta/Pay.tsx') diff --git a/packages/taler-wallet-webextension/src/cta/Pay.tsx b/packages/taler-wallet-webextension/src/cta/Pay.tsx index 359625999..f2661308c 100644 --- a/packages/taler-wallet-webextension/src/cta/Pay.tsx +++ b/packages/taler-wallet-webextension/src/cta/Pay.tsx @@ -29,6 +29,7 @@ import { AmountJson, AmountLike, Amounts, + AmountString, ConfirmPayResult, ConfirmPayResultDone, ConfirmPayResultType, @@ -41,6 +42,7 @@ import { import { TalerError } from "@gnu-taler/taler-wallet-core"; import { Fragment, h, VNode } from "preact"; import { useEffect, useState } from "preact/hooks"; +import { Amount } from "../components/Amount.js"; import { ErrorMessage } from "../components/ErrorMessage.js"; import { Loading } from "../components/Loading.js"; import { LoadingError } from "../components/LoadingError.js"; @@ -261,7 +263,7 @@ export function PaymentRequestView({
- Pay {amountToString(payStatus.amountEffective)} + Pay {}
@@ -276,8 +278,8 @@ export function PaymentRequestView({ {balance ? ( - Your balance of {amountToString(balance)} is not enough to pay - for this purchase + Your balance of {} is not enough to + pay for this purchase ) : ( @@ -374,14 +376,14 @@ export function PaymentRequestView({ Total to pay} - text={amountToString(payStatus.amountEffective)} + text={} kind="negative" /> )} Purchase amount} - text={amountToString(payStatus.amountRaw)} + text={} kind="neutral" /> {Amounts.isNonZero(totalFees) && ( @@ -389,7 +391,7 @@ export function PaymentRequestView({ Fee} - text={amountToString(totalFees)} + text={} kind="negative" /> @@ -493,9 +495,3 @@ function ProductList({ products }: { products: Product[] }): VNode { ); } - -function amountToString(text: AmountLike): string { - const aj = Amounts.jsonifyAmount(text); - const amount = Amounts.stringifyValue(aj, 2); - return `${amount} ${aj.currency}`; -} -- cgit v1.2.3