From 7a600514c6d43bbaeba6b962533415e59fc46057 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 8 Aug 2022 14:09:28 -0300 Subject: fixing #6096 merchant details and contract terms details factored out, to be used by other components tests and stories updated payment completed != confirmed (confirmed if paid by someone else) --- .../src/wallet/Transaction.tsx | 174 +++++++++++---------- 1 file changed, 95 insertions(+), 79 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 c42bf7066..e643fef18 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx @@ -16,18 +16,18 @@ import { AbsoluteTime, - amountFractionalLength, AmountJson, Amounts, Location, + MerchantInfo, NotificationType, + OrderShortInfo, parsePaytoUri, PaytoUri, stringifyPaytoUri, TalerProtocolTimestamp, Transaction, TransactionDeposit, - TransactionPayment, TransactionRefresh, TransactionRefund, TransactionTip, @@ -46,6 +46,7 @@ import { ErrorTalerOperation } from "../components/ErrorTalerOperation.js"; import { Loading } from "../components/Loading.js"; import { LoadingError } from "../components/LoadingError.js"; import { Kind, Part, PartCollapsible, PartPayto } from "../components/Part.js"; +import { ShowFullContractTermPopup } from "../components/ShowFullContractTermPopup.js"; import { CenteredDialog, InfoBox, @@ -319,10 +320,15 @@ export function TransactionView({ ? undefined : Amounts.parseOrThrow(transaction.refundPending); - const total = Amounts.sub( - Amounts.parseOrThrow(transaction.amountEffective), - Amounts.parseOrThrow(transaction.totalRefundEffective), - ).amount; + const price = { + raw: Amounts.parseOrThrow(transaction.amountRaw), + effective: Amounts.parseOrThrow(transaction.amountEffective), + }; + const refund = { + raw: Amounts.parseOrThrow(transaction.totalRefundRaw), + effective: Amounts.parseOrThrow(transaction.totalRefundEffective), + }; + const total = Amounts.sub(price.effective, refund.effective).amount; return ( @@ -404,45 +410,7 @@ export function TransactionView({ )} Merchant} - text={ - -
- {transaction.info.merchant.logo && ( -
- -
- )} -
-

{transaction.info.merchant.name}

- {transaction.info.merchant.website && ( - - - {transaction.info.merchant.website} - - - )} - {transaction.info.merchant.email && ( - - - {transaction.info.merchant.email} - - - )} -
-
-
- } + text={} kind="neutral" /> Details} - text={} + text={ + + } kind="neutral" />
@@ -521,12 +496,7 @@ export function TransactionView({ {/* Merchant} - text={transaction.info.merchant.name} - kind="neutral" - /> - Invoice ID} - text={transaction.info.orderId} + text={} kind="neutral" /> */} ; } +export function MerchantDetails({ + merchant, +}: { + merchant: MerchantInfo; +}): VNode { + return ( +
+ {merchant.logo && ( +
+ +
+ )} +
+

{merchant.name}

+ {merchant.website && ( + + {merchant.website} + + )} + {merchant.email && ( + + {merchant.email} + + )} +
+
+ ); +} + function DeliveryDetails({ date, location, @@ -703,57 +713,58 @@ function DeliveryDetails({ ); } -function PurchaseDetails({ - transaction, +export interface AmountWithFee { + effective: AmountJson; + raw: AmountJson; +} +export function PurchaseDetails({ + price, + refund, + info, + proposalId, }: { - transaction: TransactionPayment; + price: AmountWithFee; + refund?: AmountWithFee; + info: OrderShortInfo; + proposalId: string; }): VNode { const { i18n } = useTranslationContext(); - const partialFee = Amounts.sub( - Amounts.parseOrThrow(transaction.amountEffective), - Amounts.parseOrThrow(transaction.amountRaw), - ).amount; + const partialFee = Amounts.sub(price.effective, price.raw).amount; - const refundRaw = Amounts.parseOrThrow(transaction.totalRefundRaw); - - const refundFee = Amounts.sub( - refundRaw, - Amounts.parseOrThrow(transaction.totalRefundEffective), - ).amount; + const refundFee = !refund + ? Amounts.getZero(price.effective.currency) + : Amounts.sub(refund.raw, refund.effective).amount; const fee = Amounts.sum([partialFee, refundFee]).amount; - const hasProducts = - transaction.info.products && transaction.info.products.length > 0; + const hasProducts = info.products && info.products.length > 0; const hasShipping = - transaction.info.delivery_date !== undefined || - transaction.info.delivery_location !== undefined; + info.delivery_date !== undefined || info.delivery_location !== undefined; const showLargePic = (): void => { return; }; - const total = Amounts.sub( - Amounts.parseOrThrow(transaction.amountEffective), - Amounts.parseOrThrow(transaction.totalRefundEffective), - ).amount; + const total = !refund + ? price.effective + : Amounts.sub(price.effective, refund.effective).amount; return ( Price - + - {Amounts.isNonZero(refundRaw) && ( + {refund && Amounts.isNonZero(refund.raw) && ( Refunded - + )} @@ -784,7 +795,7 @@ function PurchaseDetails({ title={Products} text={ - {transaction.info.products?.map((p, k) => ( + {info.products?.map((p, k) => ( @@ -813,14 +824,19 @@ function PurchaseDetails({ title={Delivery} text={ } /> )} + + + + + ); } -- cgit v1.2.3