From e22bdd52f7dc878738d1b1306a15ae0f573c30a2 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 24 Aug 2021 15:16:11 -0300 Subject: transaction details new ui --- .../src/wallet/Transaction.tsx | 117 +++++++++++++-------- 1 file changed, 75 insertions(+), 42 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 d00abc16a..ad00b3d1b 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx @@ -14,7 +14,7 @@ TALER; see the file COPYING. If not, see */ -import { AmountJson, Amounts, i18n, Transaction, TransactionType } from "@gnu-taler/taler-util"; +import { AmountJson, AmountLike, Amounts, i18n, Transaction, TransactionType } from "@gnu-taler/taler-util"; import { format } from "date-fns"; import { Fragment, JSX, VNode, h } from "preact"; import { route } from 'preact-router'; @@ -22,7 +22,7 @@ import { useEffect, useState } from "preact/hooks"; import * as wxApi from "../wxApi"; import { Pages } from "../NavigationBar"; import emptyImg from "../../static/img/empty.png" -import { Button, ButtonDestructive, ButtonPrimary, ListOfProducts, PopupBox, Row, RowBorderGray, SmallTextLight, WalletBox } from "../components/styled"; +import { Button, ButtonBox, ButtonBoxDestructive, ButtonDestructive, ButtonPrimary, ExtraLargeText, FontIcon, LargeText, ListOfProducts, PopupBox, Row, RowBorderGray, SmallTextLight, WalletBox } from "../components/styled"; import { ErrorMessage } from "../components/ErrorMessage"; export function TransactionPage({ tid }: { tid: string; }): JSX.Element { @@ -73,43 +73,54 @@ export function TransactionView({ transaction, onDelete, onRetry, onBack }: Wall return null } - function Fee({ value }: { value: AmountJson }) { - if (Amounts.isZero(value)) return null - return (fee {Amounts.stringify(value)}) - } - - function TransactionTemplate({ upperRight, children }: { upperRight: VNode, children: VNode[] }) { + function TransactionTemplate({ children }: { children: VNode[] }) { return -
- - {transaction.timestamp.t_ms === "never" ? "never" : format(transaction.timestamp.t_ms, 'dd/MM/yyyy HH:mm:ss')} - - - {upperRight} - -
- {children} +
+ {children} +
- +
{transaction?.error ? retry : null} - delete + 🗑
} + type Kind = 'positive' | 'negative' | 'neutral'; + function Part({ text, title, kind, big }: { title: string, text: AmountLike, kind: Kind, big?: boolean }) { + const Text = big ? ExtraLargeText : LargeText; + return
+ {title} + + {text} + +
+ } + + function amountToString(text: AmountLike) { + 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), Amounts.parseOrThrow(transaction.amountEffective), ).amount - return From {transaction.exchangeBaseUrl}}> -

Withdraw

-

{transaction.amountEffective}

+ return +

Withdrawal

+
{transaction.timestamp.t_ms === 'never' ? 'never': format(transaction.timestamp.t_ms, 'dd MMMM yyyy, HH:mm')}
+
+ + + +
} @@ -123,13 +134,17 @@ export function TransactionView({ transaction, onDelete, onRetry, onBack }: Wall Amounts.parseOrThrow(transaction.amountRaw), ).amount - return To {transaction.info.merchant.name}}> -

Payment

-

{transaction.amountEffective}

- #{transaction.info.orderId} -

- {transaction.info.summary} -

+ return +

Payment

+
{transaction.timestamp.t_ms === 'never' ? 'never': format(transaction.timestamp.t_ms, 'dd MMMM yyyy, HH:mm')}
+
+ + + + + + +
{transaction.info.products && transaction.info.products.length > 0 && @@ -153,9 +168,13 @@ export function TransactionView({ transaction, onDelete, onRetry, onBack }: Wall Amounts.parseOrThrow(transaction.amountRaw), Amounts.parseOrThrow(transaction.amountEffective), ).amount - return To {transaction.targetPaytoUri}}> -

Deposit

-

{transaction.amountEffective}

+ return +

Deposit

+
{transaction.timestamp.t_ms === 'never' ? 'never': format(transaction.timestamp.t_ms, 'dd MMMM yyyy, HH:mm')}
+
+ + +
} @@ -164,9 +183,13 @@ export function TransactionView({ transaction, onDelete, onRetry, onBack }: Wall Amounts.parseOrThrow(transaction.amountRaw), Amounts.parseOrThrow(transaction.amountEffective), ).amount - return From {transaction.exchangeBaseUrl}}> -

Refresh

-

{transaction.amountEffective}

+ return +

Refresh

+
{transaction.timestamp.t_ms === 'never' ? 'never': format(transaction.timestamp.t_ms, 'dd MMMM yyyy, HH:mm')}
+
+ + +
} @@ -175,9 +198,13 @@ export function TransactionView({ transaction, onDelete, onRetry, onBack }: Wall Amounts.parseOrThrow(transaction.amountRaw), Amounts.parseOrThrow(transaction.amountEffective), ).amount - return From {transaction.merchantBaseUrl}}> -

Tip

-

{transaction.amountEffective}

+ return +

Tip

+
{transaction.timestamp.t_ms === 'never' ? 'never': format(transaction.timestamp.t_ms, 'dd MMMM yyyy, HH:mm')}
+
+ + +
} @@ -186,11 +213,17 @@ export function TransactionView({ transaction, onDelete, onRetry, onBack }: Wall Amounts.parseOrThrow(transaction.amountRaw), Amounts.parseOrThrow(transaction.amountEffective), ).amount - return From {transaction.info.merchant.name}}> -

Refund

-

{transaction.amountEffective}

+ return +

Refund

+
{transaction.timestamp.t_ms === 'never' ? 'never': format(transaction.timestamp.t_ms, 'dd MMMM yyyy, HH:mm')}
+
+ + + + + + - #{transaction.info.orderId}

{transaction.info.summary}

-- cgit v1.2.3