better wording to the tx details
This commit is contained in:
parent
7010e707ba
commit
9dbf0bd7d2
@ -65,6 +65,8 @@ export function BankDetailsByPaytoType({
|
|||||||
const payto = parsePaytoUri(firstPayto);
|
const payto = parsePaytoUri(firstPayto);
|
||||||
|
|
||||||
if (!payto) return <Fragment />;
|
if (!payto) return <Fragment />;
|
||||||
|
payto.params["amount"] = Amounts.stringify(amount);
|
||||||
|
payto.params["message"] = subject;
|
||||||
|
|
||||||
if (payto.isKnown && payto.targetType === "bitcoin") {
|
if (payto.isKnown && payto.targetType === "bitcoin") {
|
||||||
const min = segwitMinAmount(amount.currency);
|
const min = segwitMinAmount(amount.currency);
|
||||||
|
@ -31,7 +31,7 @@ import editIcon from "../../svg/edit_24px.inline.svg";
|
|||||||
import {
|
import {
|
||||||
ExchangeDetails,
|
ExchangeDetails,
|
||||||
getAmountWithFee,
|
getAmountWithFee,
|
||||||
InvoiceDetails,
|
InvoiceCreationDetails,
|
||||||
} from "../../wallet/Transaction.js";
|
} from "../../wallet/Transaction.js";
|
||||||
import { State } from "./index.js";
|
import { State } from "./index.js";
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ export function ReadyView({
|
|||||||
<Part
|
<Part
|
||||||
title={i18n.str`Details`}
|
title={i18n.str`Details`}
|
||||||
text={
|
text={
|
||||||
<InvoiceDetails
|
<InvoiceCreationDetails
|
||||||
amount={getAmountWithFee(toBeReceived, requestAmount, "credit")}
|
amount={getAmountWithFee(toBeReceived, requestAmount, "credit")}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,10 @@ import { PaymentButtons } from "../../components/PaymentButtons.js";
|
|||||||
import { SubTitle, WalletAction } from "../../components/styled/index.js";
|
import { SubTitle, WalletAction } from "../../components/styled/index.js";
|
||||||
import { Time } from "../../components/Time.js";
|
import { Time } from "../../components/Time.js";
|
||||||
import { useTranslationContext } from "@gnu-taler/web-util/browser";
|
import { useTranslationContext } from "@gnu-taler/web-util/browser";
|
||||||
import { getAmountWithFee, InvoiceDetails } from "../../wallet/Transaction.js";
|
import {
|
||||||
|
getAmountWithFee,
|
||||||
|
InvoicePaymentDetails,
|
||||||
|
} from "../../wallet/Transaction.js";
|
||||||
import { State } from "./index.js";
|
import { State } from "./index.js";
|
||||||
|
|
||||||
export function ReadyView(
|
export function ReadyView(
|
||||||
@ -38,7 +41,7 @@ export function ReadyView(
|
|||||||
<Part
|
<Part
|
||||||
title={i18n.str`Details`}
|
title={i18n.str`Details`}
|
||||||
text={
|
text={
|
||||||
<InvoiceDetails
|
<InvoicePaymentDetails
|
||||||
amount={getAmountWithFee(effective, raw, "debit")}
|
amount={getAmountWithFee(effective, raw, "debit")}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ export function BaseView(state: SupportedStates): VNode {
|
|||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
<PaymentButtons
|
<PaymentButtons
|
||||||
amount={state.amount}
|
amount={effective}
|
||||||
payStatus={state.payStatus}
|
payStatus={state.payStatus}
|
||||||
uri={state.uri}
|
uri={state.uri}
|
||||||
payHandler={state.status === "ready" ? state.payHandler : undefined}
|
payHandler={state.status === "ready" ? state.payHandler : undefined}
|
||||||
|
@ -67,8 +67,8 @@ export function useComponentState({
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
const { amountEffective, amountRaw } = hook.response;
|
const { amountEffective, amountRaw } = hook.response;
|
||||||
const debitAmount = Amounts.parseOrThrow(amountRaw);
|
const debitAmount = Amounts.parseOrThrow(amountEffective);
|
||||||
const toBeReceived = Amounts.parseOrThrow(amountEffective);
|
const toBeReceived = Amounts.parseOrThrow(amountRaw);
|
||||||
|
|
||||||
let purse_expiration: TalerProtocolTimestamp | undefined = undefined;
|
let purse_expiration: TalerProtocolTimestamp | undefined = undefined;
|
||||||
let timestampError: string | undefined = undefined;
|
let timestampError: string | undefined = undefined;
|
||||||
|
@ -14,17 +14,16 @@
|
|||||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Amounts } from "@gnu-taler/taler-util";
|
import { useTranslationContext } from "@gnu-taler/web-util/browser";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { Fragment, h, VNode } from "preact";
|
import { Fragment, h, VNode } from "preact";
|
||||||
import { ErrorTalerOperation } from "../../components/ErrorTalerOperation.js";
|
|
||||||
import { LogoHeader } from "../../components/LogoHeader.js";
|
|
||||||
import { Part } from "../../components/Part.js";
|
import { Part } from "../../components/Part.js";
|
||||||
import { Link, SubTitle, WalletAction } from "../../components/styled/index.js";
|
|
||||||
import { useTranslationContext } from "@gnu-taler/web-util/browser";
|
|
||||||
import { Button } from "../../mui/Button.js";
|
import { Button } from "../../mui/Button.js";
|
||||||
import { TextField } from "../../mui/TextField.js";
|
import { TextField } from "../../mui/TextField.js";
|
||||||
import { getAmountWithFee, TransferDetails } from "../../wallet/Transaction.js";
|
import {
|
||||||
|
getAmountWithFee,
|
||||||
|
TransferCreationDetails,
|
||||||
|
} from "../../wallet/Transaction.js";
|
||||||
import { State } from "./index.js";
|
import { State } from "./index.js";
|
||||||
|
|
||||||
export function ReadyView({
|
export function ReadyView({
|
||||||
@ -110,7 +109,7 @@ export function ReadyView({
|
|||||||
<Part
|
<Part
|
||||||
title={i18n.str`Details`}
|
title={i18n.str`Details`}
|
||||||
text={
|
text={
|
||||||
<TransferDetails
|
<TransferCreationDetails
|
||||||
amount={getAmountWithFee(debitAmount, toBeReceived, "debit")}
|
amount={getAmountWithFee(debitAmount, toBeReceived, "debit")}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,16 @@
|
|||||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { useTranslationContext } from "@gnu-taler/web-util/browser";
|
||||||
import { Fragment, h, VNode } from "preact";
|
import { Fragment, h, VNode } from "preact";
|
||||||
import { Amount } from "../../components/Amount.js";
|
import { Amount } from "../../components/Amount.js";
|
||||||
import { ErrorTalerOperation } from "../../components/ErrorTalerOperation.js";
|
|
||||||
import { LogoHeader } from "../../components/LogoHeader.js";
|
|
||||||
import { Part } from "../../components/Part.js";
|
import { Part } from "../../components/Part.js";
|
||||||
import { Link, SubTitle, WalletAction } from "../../components/styled/index.js";
|
|
||||||
import { Time } from "../../components/Time.js";
|
import { Time } from "../../components/Time.js";
|
||||||
import { useTranslationContext } from "@gnu-taler/web-util/browser";
|
|
||||||
import { Button } from "../../mui/Button.js";
|
import { Button } from "../../mui/Button.js";
|
||||||
import { getAmountWithFee, TransferDetails } from "../../wallet/Transaction.js";
|
import {
|
||||||
|
getAmountWithFee,
|
||||||
|
TransferPickupDetails,
|
||||||
|
} from "../../wallet/Transaction.js";
|
||||||
import { State } from "./index.js";
|
import { State } from "./index.js";
|
||||||
|
|
||||||
export function ReadyView({
|
export function ReadyView({
|
||||||
@ -42,7 +42,7 @@ export function ReadyView({
|
|||||||
<Part
|
<Part
|
||||||
title={i18n.str`Details`}
|
title={i18n.str`Details`}
|
||||||
text={
|
text={
|
||||||
<TransferDetails
|
<TransferPickupDetails
|
||||||
amount={getAmountWithFee(effective, raw, "credit")}
|
amount={getAmountWithFee(effective, raw, "credit")}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
@ -152,16 +152,20 @@ export function HistoryView({
|
|||||||
? []
|
? []
|
||||||
: transactionByCurrency[selectedCurrency] ?? [];
|
: transactionByCurrency[selectedCurrency] ?? [];
|
||||||
|
|
||||||
|
const datesWithTransaction: string[] = [];
|
||||||
const byDate = ts.reduce((rv, x) => {
|
const byDate = ts.reduce((rv, x) => {
|
||||||
const theDate =
|
const theDate =
|
||||||
x.timestamp.t_s === "never" ? 0 : normalizeToDay(x.timestamp.t_s * 1000);
|
x.timestamp.t_s === "never" ? 0 : normalizeToDay(x.timestamp.t_s * 1000);
|
||||||
if (theDate) {
|
if (theDate) {
|
||||||
(rv[theDate] = rv[theDate] || []).push(x);
|
if (!rv[theDate]) {
|
||||||
|
rv[theDate] = [];
|
||||||
|
datesWithTransaction.push(String(theDate));
|
||||||
|
}
|
||||||
|
rv[theDate].push(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}, {} as { [x: string]: Transaction[] });
|
}, {} as { [x: string]: Transaction[] });
|
||||||
const datesWithTransaction = Object.keys(byDate);
|
|
||||||
|
|
||||||
if (balances.length === 0 || !selectedCurrency) {
|
if (balances.length === 0 || !selectedCurrency) {
|
||||||
return (
|
return (
|
||||||
|
@ -876,7 +876,7 @@ export function TransactionView({
|
|||||||
<Part
|
<Part
|
||||||
title={i18n.str`Details`}
|
title={i18n.str`Details`}
|
||||||
text={
|
text={
|
||||||
<InvoiceDetails
|
<InvoiceCreationDetails
|
||||||
amount={getAmountWithFee(effective, raw, "credit")}
|
amount={getAmountWithFee(effective, raw, "credit")}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@ -920,7 +920,7 @@ export function TransactionView({
|
|||||||
<Part
|
<Part
|
||||||
title={i18n.str`Details`}
|
title={i18n.str`Details`}
|
||||||
text={
|
text={
|
||||||
<InvoiceDetails
|
<InvoicePaymentDetails
|
||||||
amount={getAmountWithFee(effective, raw, "debit")}
|
amount={getAmountWithFee(effective, raw, "debit")}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@ -972,7 +972,7 @@ export function TransactionView({
|
|||||||
<Part
|
<Part
|
||||||
title={i18n.str`Details`}
|
title={i18n.str`Details`}
|
||||||
text={
|
text={
|
||||||
<TransferDetails
|
<TransferCreationDetails
|
||||||
amount={getAmountWithFee(effective, raw, "debit")}
|
amount={getAmountWithFee(effective, raw, "debit")}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@ -1016,7 +1016,7 @@ export function TransactionView({
|
|||||||
<Part
|
<Part
|
||||||
title={i18n.str`Details`}
|
title={i18n.str`Details`}
|
||||||
text={
|
text={
|
||||||
<TransferDetails
|
<TransferPickupDetails
|
||||||
amount={getAmountWithFee(effective, raw, "credit")}
|
amount={getAmountWithFee(effective, raw, "credit")}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@ -1212,24 +1212,27 @@ export function getAmountWithFee(
|
|||||||
raw: AmountJson,
|
raw: AmountJson,
|
||||||
direction: "credit" | "debit",
|
direction: "credit" | "debit",
|
||||||
): AmountWithFee {
|
): AmountWithFee {
|
||||||
const fee =
|
const total = direction === "credit" ? effective : raw;
|
||||||
direction === "credit"
|
const value = direction === "debit" ? effective : raw;
|
||||||
? Amounts.sub(raw, effective).amount
|
const fee = Amounts.sub(value, total).amount;
|
||||||
: Amounts.sub(effective, raw).amount;
|
|
||||||
|
|
||||||
const maxFrac = [effective, raw, fee]
|
const maxFrac = [effective, raw, fee]
|
||||||
.map((a) => Amounts.maxFractionalDigits(a))
|
.map((a) => Amounts.maxFractionalDigits(a))
|
||||||
.reduce((c, p) => Math.max(c, p), 0);
|
.reduce((c, p) => Math.max(c, p), 0);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
total: effective,
|
total,
|
||||||
value: raw,
|
value,
|
||||||
fee,
|
fee,
|
||||||
maxFrac,
|
maxFrac,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function InvoiceDetails({ amount }: { amount: AmountWithFee }): VNode {
|
export function InvoiceCreationDetails({
|
||||||
|
amount,
|
||||||
|
}: {
|
||||||
|
amount: AmountWithFee;
|
||||||
|
}): VNode {
|
||||||
const { i18n } = useTranslationContext();
|
const { i18n } = useTranslationContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -1270,7 +1273,101 @@ export function InvoiceDetails({ amount }: { amount: AmountWithFee }): VNode {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TransferDetails({ amount }: { amount: AmountWithFee }): VNode {
|
export function InvoicePaymentDetails({
|
||||||
|
amount,
|
||||||
|
}: {
|
||||||
|
amount: AmountWithFee;
|
||||||
|
}): VNode {
|
||||||
|
const { i18n } = useTranslationContext();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PurchaseDetailsTable>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<i18n.Translate>Invoice</i18n.Translate>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Amount value={amount.total} maxFracSize={amount.maxFrac} />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{Amounts.isNonZero(amount.fee) && (
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<i18n.Translate>Fees</i18n.Translate>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Amount value={amount.fee} maxFracSize={amount.maxFrac} />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
<tr>
|
||||||
|
<td colSpan={2}>
|
||||||
|
<hr />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<i18n.Translate>Total</i18n.Translate>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Amount value={amount.value} maxFracSize={amount.maxFrac} />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</PurchaseDetailsTable>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TransferCreationDetails({
|
||||||
|
amount,
|
||||||
|
}: {
|
||||||
|
amount: AmountWithFee;
|
||||||
|
}): VNode {
|
||||||
|
const { i18n } = useTranslationContext();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PurchaseDetailsTable>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<i18n.Translate>Sent</i18n.Translate>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Amount value={amount.value} maxFracSize={amount.maxFrac} />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{Amounts.isNonZero(amount.fee) && (
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<i18n.Translate>Fees</i18n.Translate>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Amount value={amount.fee} maxFracSize={amount.maxFrac} />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
<tr>
|
||||||
|
<td colSpan={2}>
|
||||||
|
<hr />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<i18n.Translate>Transfer</i18n.Translate>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Amount value={amount.total} maxFracSize={amount.maxFrac} />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</PurchaseDetailsTable>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TransferPickupDetails({
|
||||||
|
amount,
|
||||||
|
}: {
|
||||||
|
amount: AmountWithFee;
|
||||||
|
}): VNode {
|
||||||
const { i18n } = useTranslationContext();
|
const { i18n } = useTranslationContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -1310,7 +1407,6 @@ export function TransferDetails({ amount }: { amount: AmountWithFee }): VNode {
|
|||||||
</PurchaseDetailsTable>
|
</PurchaseDetailsTable>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function WithdrawDetails({ amount }: { amount: AmountWithFee }): VNode {
|
export function WithdrawDetails({ amount }: { amount: AmountWithFee }): VNode {
|
||||||
const { i18n } = useTranslationContext();
|
const { i18n } = useTranslationContext();
|
||||||
|
|
||||||
@ -1324,7 +1420,7 @@ export function WithdrawDetails({ amount }: { amount: AmountWithFee }): VNode {
|
|||||||
<PurchaseDetailsTable>
|
<PurchaseDetailsTable>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<i18n.Translate>Wire transfer</i18n.Translate>
|
<i18n.Translate>Transfer</i18n.Translate>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<Amount value={amount.value} maxFracSize={amount.maxFrac} />
|
<Amount value={amount.value} maxFracSize={amount.maxFrac} />
|
||||||
@ -1389,7 +1485,7 @@ export function PurchaseDetails({
|
|||||||
<i18n.Translate>Price</i18n.Translate>
|
<i18n.Translate>Price</i18n.Translate>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<Amount value={price.value} />
|
<Amount value={price.total} />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{Amounts.isNonZero(price.fee) && (
|
{Amounts.isNonZero(price.fee) && (
|
||||||
@ -1451,7 +1547,7 @@ export function PurchaseDetails({
|
|||||||
<i18n.Translate>Total</i18n.Translate>
|
<i18n.Translate>Total</i18n.Translate>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<Amount value={price.total} />
|
<Amount value={price.value} />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
@ -1621,7 +1717,7 @@ function DepositDetails({ amount }: { amount: AmountWithFee }): VNode {
|
|||||||
<PurchaseDetailsTable>
|
<PurchaseDetailsTable>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<i18n.Translate>Deposit</i18n.Translate>
|
<i18n.Translate>Sent</i18n.Translate>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<Amount value={amount.value} maxFracSize={amount.maxFrac} />
|
<Amount value={amount.value} maxFracSize={amount.maxFrac} />
|
||||||
|
Loading…
Reference in New Issue
Block a user