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 --- .../src/wallet/Transaction.tsx | 55 ++++++++++------------ 1 file changed, 25 insertions(+), 30 deletions(-) (limited to 'packages/taler-wallet-webextension/src/wallet/Transaction.tsx') diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx index 8fe6f9f32..62e40d029 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx @@ -28,6 +28,7 @@ import { differenceInSeconds } from "date-fns"; import { ComponentChildren, Fragment, h, VNode } from "preact"; import { useState } from "preact/hooks"; import emptyImg from "../../static/img/empty.png"; +import { Amount } from "../components/Amount.js"; import { BankDetailsByPaytoType } from "../components/BankDetailsByPaytoType.js"; import { ErrorTalerOperation } from "../components/ErrorTalerOperation.js"; import { Loading } from "../components/Loading.js"; @@ -180,12 +181,6 @@ export function TransactionView({ ); } - function amountToString(text: AmountLike): string { - const aj = Amounts.jsonifyAmount(text); - const amount = Amounts.stringifyValue(aj); - return `${amount} ${aj.currency}`; - } - if (transaction.type === TransactionType.Withdrawal) { const fee = Amounts.sub( Amounts.parseOrThrow(transaction.amountRaw), @@ -229,7 +224,7 @@ export function TransactionView({ WithdrawalType.ManualTransfer ? ( } exchangeBaseUrl={transaction.exchangeBaseUrl} payto={parsePaytoUri( transaction.withdrawalDetails.exchangePaytoUris[0], @@ -247,13 +242,13 @@ export function TransactionView({ Total withdrawn} - text={amountToString(transaction.amountEffective)} + text={} kind="positive" /> Exchange fee} - text={amountToString(fee)} + text={} kind="negative" /> @@ -284,19 +279,19 @@ export function TransactionView({ Total withdrawn} - text={amountToString(transaction.amountEffective)} + text={} kind="positive" /> Chosen amount} - text={amountToString(transaction.amountRaw)} + text={} kind="neutral" /> Exchange fee} - text={amountToString(fee)} + text={} kind="negative" /> @@ -306,19 +301,19 @@ export function TransactionView({ Total withdrawn} - text={amountToString(transaction.amountEffective)} + text={} kind="positive" /> Chosen amount} - text={amountToString(transaction.amountRaw)} + text={} kind="neutral" /> Exchange fee} - text={amountToString(fee)} + text={} kind="negative" /> @@ -355,19 +350,19 @@ export function TransactionView({ Total paid} - text={amountToString(transaction.amountEffective)} + text={} kind="negative" /> Purchase amount} - text={amountToString(transaction.amountRaw)} + text={} kind="neutral" /> Fee} - text={amountToString(fee)} + text={} kind="negative" /> Total send} - text={amountToString(transaction.amountEffective)} + text={} kind="neutral" /> Deposit amount} - text={amountToString(transaction.amountRaw)} + text={} kind="positive" /> Fee} - text={amountToString(fee)} + text={} kind="negative" /> @@ -478,19 +473,19 @@ export function TransactionView({ Total refresh} - text={amountToString(transaction.amountEffective)} + text={} kind="negative" /> Refresh amount} - text={amountToString(transaction.amountRaw)} + text={} kind="neutral" /> Fee} - text={amountToString(fee)} + text={} kind="negative" /> @@ -515,19 +510,19 @@ export function TransactionView({ Total tip} - text={amountToString(transaction.amountEffective)} + text={} kind="positive" /> Received amount} - text={amountToString(transaction.amountRaw)} + text={} kind="neutral" /> Fee} - text={amountToString(fee)} + text={} kind="negative" /> @@ -552,19 +547,19 @@ export function TransactionView({ Total refund} - text={amountToString(transaction.amountEffective)} + text={} kind="positive" /> Refund amount} - text={amountToString(transaction.amountRaw)} + text={} kind="neutral" /> Fee} - text={amountToString(fee)} + text={} kind="negative" />