2021-06-16 23:21:03 +02:00
|
|
|
/*
|
2022-06-06 17:05:26 +02:00
|
|
|
This file is part of GNU Taler
|
|
|
|
(C) 2022 Taler Systems S.A.
|
2021-06-16 23:21:03 +02:00
|
|
|
|
2022-06-06 17:05:26 +02:00
|
|
|
GNU Taler is free software; you can redistribute it and/or modify it under the
|
2021-06-16 23:21:03 +02:00
|
|
|
terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 3, or (at your option) any later version.
|
|
|
|
|
2022-06-06 17:05:26 +02:00
|
|
|
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
2021-06-16 23:21:03 +02:00
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
2022-06-06 17:05:26 +02:00
|
|
|
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
2021-06-16 23:21:03 +02:00
|
|
|
*/
|
|
|
|
|
2021-11-15 15:18:58 +01:00
|
|
|
import {
|
2022-03-18 15:32:41 +01:00
|
|
|
AbsoluteTime,
|
2022-05-26 20:55:14 +02:00
|
|
|
AmountJson,
|
2021-11-15 15:18:58 +01:00
|
|
|
Amounts,
|
2022-05-26 20:55:14 +02:00
|
|
|
Location,
|
2022-08-08 19:09:28 +02:00
|
|
|
MerchantInfo,
|
2021-11-19 18:51:27 +01:00
|
|
|
NotificationType,
|
2022-08-08 19:09:28 +02:00
|
|
|
OrderShortInfo,
|
2021-11-19 18:51:27 +01:00
|
|
|
parsePaytoUri,
|
2022-05-29 06:23:15 +02:00
|
|
|
PaytoUri,
|
|
|
|
stringifyPaytoUri,
|
2022-05-26 20:55:14 +02:00
|
|
|
TalerProtocolTimestamp,
|
2021-11-15 15:18:58 +01:00
|
|
|
Transaction,
|
2022-05-26 20:55:14 +02:00
|
|
|
TransactionDeposit,
|
|
|
|
TransactionRefresh,
|
|
|
|
TransactionRefund,
|
|
|
|
TransactionTip,
|
2021-11-15 15:18:58 +01:00
|
|
|
TransactionType,
|
2021-11-19 18:51:27 +01:00
|
|
|
WithdrawalType,
|
2021-11-15 15:18:58 +01:00
|
|
|
} from "@gnu-taler/taler-util";
|
2022-05-26 20:55:14 +02:00
|
|
|
import { styled } from "@linaria/react";
|
2021-12-06 14:31:19 +01:00
|
|
|
import { differenceInSeconds } from "date-fns";
|
2021-11-19 18:51:27 +01:00
|
|
|
import { ComponentChildren, Fragment, h, VNode } from "preact";
|
2022-04-26 03:37:41 +02:00
|
|
|
import { useEffect, useState } from "preact/hooks";
|
2021-10-27 20:13:35 +02:00
|
|
|
import emptyImg from "../../static/img/empty.png";
|
2022-04-11 16:33:55 +02:00
|
|
|
import { Amount } from "../components/Amount.js";
|
2022-03-29 04:41:07 +02:00
|
|
|
import { BankDetailsByPaytoType } from "../components/BankDetailsByPaytoType.js";
|
|
|
|
import { ErrorTalerOperation } from "../components/ErrorTalerOperation.js";
|
|
|
|
import { Loading } from "../components/Loading.js";
|
|
|
|
import { LoadingError } from "../components/LoadingError.js";
|
2022-05-26 20:55:14 +02:00
|
|
|
import { Kind, Part, PartCollapsible, PartPayto } from "../components/Part.js";
|
2022-08-31 05:20:35 +02:00
|
|
|
import { QR } from "../components/QR.js";
|
2022-08-08 19:09:28 +02:00
|
|
|
import { ShowFullContractTermPopup } from "../components/ShowFullContractTermPopup.js";
|
2021-11-15 15:18:58 +01:00
|
|
|
import {
|
2021-11-19 18:51:27 +01:00
|
|
|
CenteredDialog,
|
|
|
|
InfoBox,
|
2021-11-15 15:18:58 +01:00
|
|
|
ListOfProducts,
|
2021-11-19 18:51:27 +01:00
|
|
|
Overlay,
|
2022-05-26 20:55:14 +02:00
|
|
|
Row,
|
2021-11-15 15:18:58 +01:00
|
|
|
SmallLightText,
|
2022-03-28 19:03:59 +02:00
|
|
|
SubTitle,
|
2021-11-15 15:18:58 +01:00
|
|
|
WarningBox,
|
2022-03-29 04:41:07 +02:00
|
|
|
} from "../components/styled/index.js";
|
|
|
|
import { Time } from "../components/Time.js";
|
|
|
|
import { useTranslationContext } from "../context/translation.js";
|
2022-04-26 04:07:31 +02:00
|
|
|
import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
|
2022-06-01 20:47:47 +02:00
|
|
|
import { Button } from "../mui/Button.js";
|
2022-05-14 23:09:33 +02:00
|
|
|
import { Pages } from "../NavigationBar.js";
|
2022-03-29 04:41:07 +02:00
|
|
|
import * as wxApi from "../wxApi.js";
|
2021-06-16 23:21:03 +02:00
|
|
|
|
2022-01-25 14:29:29 +01:00
|
|
|
interface Props {
|
|
|
|
tid: string;
|
2022-06-01 20:47:47 +02:00
|
|
|
goToWalletHistory: (currency?: string) => Promise<void>;
|
2022-01-25 14:29:29 +01:00
|
|
|
}
|
2022-04-26 03:37:41 +02:00
|
|
|
|
|
|
|
async function getTransaction(tid: string): Promise<Transaction> {
|
|
|
|
const res = await wxApi.getTransactions();
|
|
|
|
const ts = res.transactions.filter((t) => t.transactionId === tid);
|
|
|
|
if (ts.length > 1) throw Error("more than one transaction with this id");
|
|
|
|
if (ts.length === 1) {
|
|
|
|
return ts[0];
|
|
|
|
}
|
|
|
|
throw Error("no transaction found");
|
|
|
|
}
|
|
|
|
|
2022-01-25 14:29:29 +01:00
|
|
|
export function TransactionPage({ tid, goToWalletHistory }: Props): VNode {
|
2022-03-14 19:20:32 +01:00
|
|
|
const { i18n } = useTranslationContext();
|
2021-11-19 18:51:27 +01:00
|
|
|
|
2022-05-29 06:23:15 +02:00
|
|
|
const state = useAsyncAsHook(() => getTransaction(tid), [tid]);
|
2022-04-26 03:37:41 +02:00
|
|
|
|
|
|
|
useEffect(() => {
|
2022-06-09 19:16:28 +02:00
|
|
|
return wxApi.onUpdateNotification(
|
|
|
|
[NotificationType.WithdrawGroupFinished],
|
|
|
|
() => {
|
|
|
|
state?.retry();
|
|
|
|
},
|
|
|
|
);
|
2022-04-26 03:37:41 +02:00
|
|
|
});
|
2021-06-16 23:21:03 +02:00
|
|
|
|
2021-11-19 18:51:27 +01:00
|
|
|
if (!state) {
|
2022-01-25 14:29:29 +01:00
|
|
|
return <Loading />;
|
2021-07-13 20:33:28 +02:00
|
|
|
}
|
2021-11-19 18:51:27 +01:00
|
|
|
|
|
|
|
if (state.hasError) {
|
|
|
|
return (
|
2022-01-25 14:29:29 +01:00
|
|
|
<LoadingError
|
2022-02-23 19:18:37 +01:00
|
|
|
title={
|
2022-02-23 19:44:14 +01:00
|
|
|
<i18n.Translate>
|
|
|
|
Could not load the transaction information
|
|
|
|
</i18n.Translate>
|
2022-02-23 19:18:37 +01:00
|
|
|
}
|
2022-01-25 14:29:29 +01:00
|
|
|
error={state}
|
|
|
|
/>
|
2021-11-19 18:51:27 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-01-25 14:29:29 +01:00
|
|
|
const currency = Amounts.parse(state.response.amountRaw)?.currency;
|
2021-11-19 18:51:27 +01:00
|
|
|
|
2021-11-15 15:18:58 +01:00
|
|
|
return (
|
|
|
|
<TransactionView
|
2021-11-19 18:51:27 +01:00
|
|
|
transaction={state.response}
|
2022-01-25 14:29:29 +01:00
|
|
|
onDelete={() =>
|
|
|
|
wxApi.deleteTransaction(tid).then(() => goToWalletHistory(currency))
|
|
|
|
}
|
|
|
|
onRetry={() =>
|
|
|
|
wxApi.retryTransaction(tid).then(() => goToWalletHistory(currency))
|
|
|
|
}
|
2022-06-01 20:47:47 +02:00
|
|
|
onRefund={(id) => wxApi.applyRefundFromPurchaseId(id).then()}
|
2022-01-25 14:29:29 +01:00
|
|
|
onBack={() => goToWalletHistory(currency)}
|
2021-11-15 15:18:58 +01:00
|
|
|
/>
|
|
|
|
);
|
2021-06-16 23:21:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface WalletTransactionProps {
|
2021-10-15 00:37:18 +02:00
|
|
|
transaction: Transaction;
|
2022-06-01 20:47:47 +02:00
|
|
|
onDelete: () => Promise<void>;
|
|
|
|
onRetry: () => Promise<void>;
|
|
|
|
onRefund: (id: string) => Promise<void>;
|
|
|
|
onBack: () => Promise<void>;
|
2021-06-16 23:21:03 +02:00
|
|
|
}
|
|
|
|
|
2022-05-26 20:55:14 +02:00
|
|
|
const PurchaseDetailsTable = styled.table`
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
& > tr > td:nth-child(2n) {
|
|
|
|
text-align: right;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2021-11-15 15:18:58 +01:00
|
|
|
export function TransactionView({
|
|
|
|
transaction,
|
|
|
|
onDelete,
|
|
|
|
onRetry,
|
2022-05-29 06:23:15 +02:00
|
|
|
onRefund,
|
2021-11-16 17:59:53 +01:00
|
|
|
}: WalletTransactionProps): VNode {
|
2021-11-19 18:51:27 +01:00
|
|
|
const [confirmBeforeForget, setConfirmBeforeForget] = useState(false);
|
2021-12-06 14:31:19 +01:00
|
|
|
|
2022-06-01 20:47:47 +02:00
|
|
|
async function doCheckBeforeForget(): Promise<void> {
|
2021-11-19 18:51:27 +01:00
|
|
|
if (
|
|
|
|
transaction.pending &&
|
|
|
|
transaction.type === TransactionType.Withdrawal
|
|
|
|
) {
|
|
|
|
setConfirmBeforeForget(true);
|
|
|
|
} else {
|
|
|
|
onDelete();
|
|
|
|
}
|
|
|
|
}
|
2021-12-06 14:31:19 +01:00
|
|
|
|
2022-03-14 19:20:32 +01:00
|
|
|
const { i18n } = useTranslationContext();
|
|
|
|
|
2021-11-19 18:51:27 +01:00
|
|
|
function TransactionTemplate({
|
|
|
|
children,
|
|
|
|
}: {
|
|
|
|
children: ComponentChildren;
|
|
|
|
}): VNode {
|
2021-12-06 14:31:19 +01:00
|
|
|
const showRetry =
|
|
|
|
transaction.error !== undefined ||
|
2022-03-18 15:32:41 +01:00
|
|
|
transaction.timestamp.t_s === "never" ||
|
2021-12-06 14:31:19 +01:00
|
|
|
(transaction.pending &&
|
2022-03-18 15:32:41 +01:00
|
|
|
differenceInSeconds(new Date(), transaction.timestamp.t_s * 1000) > 10);
|
2021-12-06 14:31:19 +01:00
|
|
|
|
2021-11-15 15:18:58 +01:00
|
|
|
return (
|
2021-11-19 18:51:27 +01:00
|
|
|
<Fragment>
|
2021-11-15 15:18:58 +01:00
|
|
|
<section style={{ padding: 8, textAlign: "center" }}>
|
2021-11-29 18:11:32 +01:00
|
|
|
<ErrorTalerOperation
|
2022-02-23 19:18:37 +01:00
|
|
|
title={
|
2022-02-23 19:44:14 +01:00
|
|
|
<i18n.Translate>
|
2022-02-23 19:18:37 +01:00
|
|
|
There was an error trying to complete the transaction
|
2022-02-23 19:44:14 +01:00
|
|
|
</i18n.Translate>
|
2022-02-23 19:18:37 +01:00
|
|
|
}
|
2021-11-29 18:11:32 +01:00
|
|
|
error={transaction?.error}
|
|
|
|
/>
|
2021-11-15 15:18:58 +01:00
|
|
|
{transaction.pending && (
|
2022-02-23 19:18:37 +01:00
|
|
|
<WarningBox>
|
2022-02-23 19:44:14 +01:00
|
|
|
<i18n.Translate>This transaction is not completed</i18n.Translate>
|
2022-02-23 19:18:37 +01:00
|
|
|
</WarningBox>
|
2021-11-15 15:18:58 +01:00
|
|
|
)}
|
|
|
|
</section>
|
2022-05-26 20:55:14 +02:00
|
|
|
<section>{children}</section>
|
2021-11-15 15:18:58 +01:00
|
|
|
<footer>
|
2022-03-17 16:39:16 +01:00
|
|
|
<div />
|
2021-11-15 15:18:58 +01:00
|
|
|
<div>
|
2021-12-06 14:31:19 +01:00
|
|
|
{showRetry ? (
|
2022-06-01 20:47:47 +02:00
|
|
|
<Button variant="contained" onClick={onRetry}>
|
2022-02-23 19:44:14 +01:00
|
|
|
<i18n.Translate>Retry</i18n.Translate>
|
2022-06-01 20:47:47 +02:00
|
|
|
</Button>
|
2021-11-15 15:18:58 +01:00
|
|
|
) : null}
|
2022-06-01 20:47:47 +02:00
|
|
|
<Button
|
|
|
|
variant="contained"
|
|
|
|
color="error"
|
|
|
|
onClick={doCheckBeforeForget}
|
|
|
|
>
|
2022-02-23 19:44:14 +01:00
|
|
|
<i18n.Translate>Forget</i18n.Translate>
|
2022-06-01 20:47:47 +02:00
|
|
|
</Button>
|
2021-11-15 15:18:58 +01:00
|
|
|
</div>
|
|
|
|
</footer>
|
2021-11-19 18:51:27 +01:00
|
|
|
</Fragment>
|
2021-11-15 15:18:58 +01:00
|
|
|
);
|
2021-07-13 20:33:28 +02:00
|
|
|
}
|
2021-08-24 20:16:11 +02:00
|
|
|
|
2021-06-16 23:21:03 +02:00
|
|
|
if (transaction.type === TransactionType.Withdrawal) {
|
2022-05-26 20:55:14 +02:00
|
|
|
const total = Amounts.parseOrThrow(transaction.amountEffective);
|
|
|
|
const chosen = Amounts.parseOrThrow(transaction.amountRaw);
|
2021-11-15 15:18:58 +01:00
|
|
|
return (
|
|
|
|
<TransactionTemplate>
|
2021-11-19 18:51:27 +01:00
|
|
|
{confirmBeforeForget ? (
|
|
|
|
<Overlay>
|
|
|
|
<CenteredDialog>
|
2022-02-23 19:18:37 +01:00
|
|
|
<header>
|
2022-02-23 19:44:14 +01:00
|
|
|
<i18n.Translate>Caution!</i18n.Translate>
|
2022-02-23 19:18:37 +01:00
|
|
|
</header>
|
2021-11-19 18:51:27 +01:00
|
|
|
<section>
|
2022-02-23 19:44:14 +01:00
|
|
|
<i18n.Translate>
|
2022-02-23 19:18:37 +01:00
|
|
|
If you have already wired money to the exchange you will loose
|
|
|
|
the chance to get the coins form it.
|
2022-02-23 19:44:14 +01:00
|
|
|
</i18n.Translate>
|
2021-11-19 18:51:27 +01:00
|
|
|
</section>
|
|
|
|
<footer>
|
2022-06-01 20:47:47 +02:00
|
|
|
<Button
|
|
|
|
variant="contained"
|
|
|
|
color="secondary"
|
|
|
|
onClick={async () => setConfirmBeforeForget(false)}
|
|
|
|
>
|
2022-02-23 19:44:14 +01:00
|
|
|
<i18n.Translate>Cancel</i18n.Translate>
|
2021-11-19 18:51:27 +01:00
|
|
|
</Button>
|
|
|
|
|
2022-06-01 20:47:47 +02:00
|
|
|
<Button variant="contained" color="error" onClick={onDelete}>
|
2022-02-23 19:44:14 +01:00
|
|
|
<i18n.Translate>Confirm</i18n.Translate>
|
2022-06-01 20:47:47 +02:00
|
|
|
</Button>
|
2021-11-19 18:51:27 +01:00
|
|
|
</footer>
|
|
|
|
</CenteredDialog>
|
|
|
|
</Overlay>
|
|
|
|
) : undefined}
|
2022-05-26 20:55:14 +02:00
|
|
|
<Header
|
|
|
|
timestamp={transaction.timestamp}
|
|
|
|
type={i18n.str`Withdrawal`}
|
|
|
|
total={total}
|
|
|
|
kind="positive"
|
|
|
|
>
|
|
|
|
{transaction.exchangeBaseUrl}
|
|
|
|
</Header>
|
|
|
|
|
|
|
|
{!transaction.pending ? undefined : transaction.withdrawalDetails
|
|
|
|
.type === WithdrawalType.ManualTransfer ? (
|
|
|
|
<Fragment>
|
|
|
|
<BankDetailsByPaytoType
|
|
|
|
amount={chosen}
|
|
|
|
exchangeBaseUrl={transaction.exchangeBaseUrl}
|
|
|
|
payto={parsePaytoUri(
|
|
|
|
transaction.withdrawalDetails.exchangePaytoUris[0],
|
|
|
|
)}
|
|
|
|
subject={transaction.withdrawalDetails.reservePub}
|
|
|
|
/>
|
|
|
|
<WarningBox>
|
|
|
|
<i18n.Translate>
|
|
|
|
Make sure to use the correct subject, otherwise the money will
|
|
|
|
not arrive in this wallet.
|
|
|
|
</i18n.Translate>
|
|
|
|
</WarningBox>
|
|
|
|
</Fragment>
|
|
|
|
) : (
|
|
|
|
<Fragment>
|
|
|
|
{!transaction.withdrawalDetails.confirmed &&
|
|
|
|
transaction.withdrawalDetails.bankConfirmationUrl ? (
|
|
|
|
<InfoBox>
|
|
|
|
<div style={{ display: "block" }}>
|
2022-02-23 19:44:14 +01:00
|
|
|
<i18n.Translate>
|
2022-05-26 20:55:14 +02:00
|
|
|
The bank did not yet confirmed the wire transfer. Go to the
|
|
|
|
{` `}
|
2022-02-23 19:18:37 +01:00
|
|
|
<a
|
|
|
|
href={transaction.withdrawalDetails.bankConfirmationUrl}
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer"
|
2022-05-26 20:55:14 +02:00
|
|
|
style={{ display: "inline" }}
|
2022-02-23 19:18:37 +01:00
|
|
|
>
|
2022-02-23 19:44:14 +01:00
|
|
|
<i18n.Translate>bank site</i18n.Translate>
|
2022-05-26 20:55:14 +02:00
|
|
|
</a>{" "}
|
|
|
|
and check there is no pending step.
|
2022-02-23 19:44:14 +01:00
|
|
|
</i18n.Translate>
|
2022-05-26 20:55:14 +02:00
|
|
|
</div>
|
|
|
|
</InfoBox>
|
|
|
|
) : undefined}
|
|
|
|
{transaction.withdrawalDetails.confirmed && (
|
|
|
|
<InfoBox>
|
|
|
|
<i18n.Translate>
|
|
|
|
Bank has confirmed the wire transfer. Waiting for the exchange
|
|
|
|
to send the coins
|
|
|
|
</i18n.Translate>
|
|
|
|
</InfoBox>
|
|
|
|
)}
|
2021-11-19 18:51:27 +01:00
|
|
|
</Fragment>
|
|
|
|
)}
|
2021-11-15 15:18:58 +01:00
|
|
|
<Part
|
2022-05-26 20:55:14 +02:00
|
|
|
title={<i18n.Translate>Details</i18n.Translate>}
|
2022-08-10 16:50:46 +02:00
|
|
|
text={
|
|
|
|
<WithdrawDetails
|
|
|
|
amount={{
|
|
|
|
effective: Amounts.parseOrThrow(transaction.amountEffective),
|
|
|
|
raw: Amounts.parseOrThrow(transaction.amountRaw),
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
}
|
2021-11-15 15:18:58 +01:00
|
|
|
/>
|
|
|
|
</TransactionTemplate>
|
|
|
|
);
|
2021-06-16 23:21:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (transaction.type === TransactionType.Payment) {
|
2022-05-14 23:09:33 +02:00
|
|
|
const pendingRefund =
|
|
|
|
transaction.refundPending === undefined
|
|
|
|
? undefined
|
|
|
|
: Amounts.parseOrThrow(transaction.refundPending);
|
2022-05-26 20:55:14 +02:00
|
|
|
|
2022-08-08 19:09:28 +02:00
|
|
|
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;
|
2022-05-26 20:55:14 +02:00
|
|
|
|
2021-11-15 15:18:58 +01:00
|
|
|
return (
|
|
|
|
<TransactionTemplate>
|
2022-05-26 20:55:14 +02:00
|
|
|
<Header
|
|
|
|
timestamp={transaction.timestamp}
|
|
|
|
total={total}
|
|
|
|
type={i18n.str`Payment`}
|
2021-11-15 15:18:58 +01:00
|
|
|
kind="negative"
|
2022-05-26 20:55:14 +02:00
|
|
|
>
|
|
|
|
{transaction.info.fulfillmentUrl ? (
|
|
|
|
<a
|
|
|
|
href={transaction.info.fulfillmentUrl}
|
|
|
|
target="_bank"
|
|
|
|
rel="noreferrer"
|
|
|
|
>
|
|
|
|
{transaction.info.summary}
|
|
|
|
</a>
|
|
|
|
) : (
|
|
|
|
transaction.info.summary
|
|
|
|
)}
|
|
|
|
</Header>
|
|
|
|
<br />
|
2022-05-29 06:23:15 +02:00
|
|
|
{transaction.refunds.length > 0 ? (
|
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>Refunds</i18n.Translate>}
|
|
|
|
text={
|
|
|
|
<table>
|
|
|
|
{transaction.refunds.map((r, i) => {
|
|
|
|
return (
|
|
|
|
<tr key={i}>
|
|
|
|
<td>
|
|
|
|
{<Amount value={r.amountEffective} />}{" "}
|
|
|
|
<a
|
2022-06-02 17:20:36 +02:00
|
|
|
href={Pages.balanceTransaction({
|
|
|
|
tid: r.transactionId,
|
|
|
|
})}
|
2022-05-29 06:23:15 +02:00
|
|
|
>
|
|
|
|
was refunded
|
|
|
|
</a>{" "}
|
|
|
|
on{" "}
|
|
|
|
{
|
|
|
|
<Time
|
|
|
|
timestamp={AbsoluteTime.fromTimestamp(r.timestamp)}
|
|
|
|
format="dd MMMM yyyy"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</table>
|
|
|
|
}
|
|
|
|
kind="neutral"
|
|
|
|
/>
|
|
|
|
) : undefined}
|
2022-05-26 20:55:14 +02:00
|
|
|
{pendingRefund !== undefined && Amounts.isNonZero(pendingRefund) && (
|
|
|
|
<InfoBox>
|
|
|
|
<i18n.Translate>
|
|
|
|
Merchant created a refund for this order but was not automatically
|
|
|
|
picked up.
|
|
|
|
</i18n.Translate>
|
2022-05-14 23:09:33 +02:00
|
|
|
<Part
|
2022-05-26 20:55:14 +02:00
|
|
|
title={<i18n.Translate>Offer</i18n.Translate>}
|
|
|
|
text={<Amount value={pendingRefund} />}
|
2022-05-14 23:09:33 +02:00
|
|
|
kind="positive"
|
|
|
|
/>
|
2022-05-26 20:55:14 +02:00
|
|
|
<div>
|
|
|
|
<div />
|
|
|
|
<div>
|
2022-06-01 20:47:47 +02:00
|
|
|
<Button
|
|
|
|
variant="contained"
|
|
|
|
onClick={() => onRefund(transaction.proposalId)}
|
|
|
|
>
|
2022-05-26 20:55:14 +02:00
|
|
|
<i18n.Translate>Accept</i18n.Translate>
|
2022-06-01 20:47:47 +02:00
|
|
|
</Button>
|
2022-05-26 20:55:14 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</InfoBox>
|
2022-05-14 23:09:33 +02:00
|
|
|
)}
|
2022-02-23 19:18:37 +01:00
|
|
|
<Part
|
2022-02-23 19:44:14 +01:00
|
|
|
title={<i18n.Translate>Merchant</i18n.Translate>}
|
2022-08-08 19:09:28 +02:00
|
|
|
text={<MerchantDetails merchant={transaction.info.merchant} />}
|
2021-11-15 15:18:58 +01:00
|
|
|
kind="neutral"
|
|
|
|
/>
|
|
|
|
<Part
|
2022-05-26 20:55:14 +02:00
|
|
|
title={<i18n.Translate>Invoice ID</i18n.Translate>}
|
|
|
|
text={transaction.info.orderId}
|
2022-02-23 19:18:37 +01:00
|
|
|
kind="neutral"
|
|
|
|
/>
|
|
|
|
<Part
|
2022-05-26 20:55:14 +02:00
|
|
|
title={<i18n.Translate>Details</i18n.Translate>}
|
2022-08-08 19:09:28 +02:00
|
|
|
text={
|
|
|
|
<PurchaseDetails
|
|
|
|
price={price}
|
|
|
|
refund={refund}
|
|
|
|
info={transaction.info}
|
|
|
|
proposalId={transaction.proposalId}
|
|
|
|
/>
|
|
|
|
}
|
2021-11-15 15:18:58 +01:00
|
|
|
kind="neutral"
|
|
|
|
/>
|
|
|
|
</TransactionTemplate>
|
|
|
|
);
|
2021-06-16 23:21:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (transaction.type === TransactionType.Deposit) {
|
2022-05-26 20:55:14 +02:00
|
|
|
const total = Amounts.parseOrThrow(transaction.amountRaw);
|
2022-05-03 05:16:03 +02:00
|
|
|
const payto = parsePaytoUri(transaction.targetPaytoUri);
|
2021-11-15 15:18:58 +01:00
|
|
|
return (
|
|
|
|
<TransactionTemplate>
|
2022-05-26 20:55:14 +02:00
|
|
|
<Header
|
|
|
|
timestamp={transaction.timestamp}
|
|
|
|
type={i18n.str`Deposit`}
|
|
|
|
total={total}
|
|
|
|
kind="negative"
|
|
|
|
>
|
2022-05-29 06:23:15 +02:00
|
|
|
{!payto ? transaction.targetPaytoUri : <NicePayto payto={payto} />}
|
2022-05-26 20:55:14 +02:00
|
|
|
</Header>
|
2022-05-29 06:23:15 +02:00
|
|
|
{payto && <PartPayto payto={payto} kind="neutral" />}
|
2021-11-15 15:18:58 +01:00
|
|
|
<Part
|
2022-05-26 20:55:14 +02:00
|
|
|
title={<i18n.Translate>Details</i18n.Translate>}
|
|
|
|
text={<DepositDetails transaction={transaction} />}
|
2021-12-23 19:17:36 +01:00
|
|
|
kind="neutral"
|
2021-11-15 15:18:58 +01:00
|
|
|
/>
|
|
|
|
</TransactionTemplate>
|
|
|
|
);
|
2021-06-16 23:21:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (transaction.type === TransactionType.Refresh) {
|
2022-05-26 20:55:14 +02:00
|
|
|
const total = Amounts.sub(
|
2021-06-21 01:37:35 +02:00
|
|
|
Amounts.parseOrThrow(transaction.amountRaw),
|
|
|
|
Amounts.parseOrThrow(transaction.amountEffective),
|
2021-11-15 15:18:58 +01:00
|
|
|
).amount;
|
2022-05-26 20:55:14 +02:00
|
|
|
|
2021-11-15 15:18:58 +01:00
|
|
|
return (
|
|
|
|
<TransactionTemplate>
|
2022-05-26 20:55:14 +02:00
|
|
|
<Header
|
|
|
|
timestamp={transaction.timestamp}
|
|
|
|
type={i18n.str`Refresh`}
|
|
|
|
total={total}
|
2021-11-15 15:18:58 +01:00
|
|
|
kind="negative"
|
2022-05-26 20:55:14 +02:00
|
|
|
>
|
|
|
|
{transaction.exchangeBaseUrl}
|
|
|
|
</Header>
|
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>Details</i18n.Translate>}
|
|
|
|
text={<RefreshDetails transaction={transaction} />}
|
2021-11-15 15:18:58 +01:00
|
|
|
/>
|
|
|
|
</TransactionTemplate>
|
|
|
|
);
|
2021-06-16 23:21:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (transaction.type === TransactionType.Tip) {
|
2022-05-26 20:55:14 +02:00
|
|
|
const total = Amounts.parseOrThrow(transaction.amountEffective);
|
|
|
|
|
2021-11-15 15:18:58 +01:00
|
|
|
return (
|
|
|
|
<TransactionTemplate>
|
2022-05-26 20:55:14 +02:00
|
|
|
<Header
|
|
|
|
timestamp={transaction.timestamp}
|
|
|
|
type={i18n.str`Tip`}
|
|
|
|
total={total}
|
|
|
|
kind="positive"
|
|
|
|
>
|
|
|
|
{transaction.merchantBaseUrl}
|
|
|
|
</Header>
|
|
|
|
{/* <Part
|
|
|
|
title={<i18n.Translate>Merchant</i18n.Translate>}
|
2022-08-08 19:09:28 +02:00
|
|
|
text={<MerchantDetails merchant={transaction.merchant} />}
|
2022-05-26 20:55:14 +02:00
|
|
|
kind="neutral"
|
|
|
|
/> */}
|
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>Details</i18n.Translate>}
|
|
|
|
text={<TipDetails transaction={transaction} />}
|
2021-11-15 15:18:58 +01:00
|
|
|
/>
|
|
|
|
</TransactionTemplate>
|
|
|
|
);
|
2021-06-16 23:21:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (transaction.type === TransactionType.Refund) {
|
2022-05-26 20:55:14 +02:00
|
|
|
const total = Amounts.parseOrThrow(transaction.amountEffective);
|
2021-11-15 15:18:58 +01:00
|
|
|
return (
|
|
|
|
<TransactionTemplate>
|
2022-05-26 20:55:14 +02:00
|
|
|
<Header
|
|
|
|
timestamp={transaction.timestamp}
|
|
|
|
type={i18n.str`Refund`}
|
|
|
|
total={total}
|
2021-11-15 15:18:58 +01:00
|
|
|
kind="positive"
|
2022-05-26 20:55:14 +02:00
|
|
|
>
|
|
|
|
{transaction.info.summary}
|
|
|
|
</Header>
|
|
|
|
|
2022-02-23 19:18:37 +01:00
|
|
|
<Part
|
2022-02-23 19:44:14 +01:00
|
|
|
title={<i18n.Translate>Merchant</i18n.Translate>}
|
2021-11-15 15:18:58 +01:00
|
|
|
text={transaction.info.merchant.name}
|
|
|
|
kind="neutral"
|
|
|
|
/>
|
|
|
|
<Part
|
2022-05-26 20:55:14 +02:00
|
|
|
title={<i18n.Translate>Original order ID</i18n.Translate>}
|
2022-03-17 19:00:34 +01:00
|
|
|
text={
|
2022-05-14 23:09:33 +02:00
|
|
|
<a
|
2022-06-02 17:20:36 +02:00
|
|
|
href={Pages.balanceTransaction({
|
|
|
|
tid: transaction.refundedTransactionId,
|
|
|
|
})}
|
2022-05-14 23:09:33 +02:00
|
|
|
>
|
2022-05-26 20:55:14 +02:00
|
|
|
{transaction.info.orderId}
|
2022-05-14 23:09:33 +02:00
|
|
|
</a>
|
2022-03-17 19:00:34 +01:00
|
|
|
}
|
2022-02-23 19:18:37 +01:00
|
|
|
kind="neutral"
|
|
|
|
/>
|
|
|
|
<Part
|
2022-05-26 20:55:14 +02:00
|
|
|
title={<i18n.Translate>Purchase summary</i18n.Translate>}
|
|
|
|
text={transaction.info.summary}
|
2021-11-15 15:18:58 +01:00
|
|
|
kind="neutral"
|
|
|
|
/>
|
2022-05-26 20:55:14 +02:00
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>Details</i18n.Translate>}
|
|
|
|
text={<RefundDetails transaction={transaction} />}
|
|
|
|
/>
|
2021-11-15 15:18:58 +01:00
|
|
|
</TransactionTemplate>
|
|
|
|
);
|
|
|
|
}
|
2021-06-16 23:21:03 +02:00
|
|
|
|
2022-08-31 05:20:35 +02:00
|
|
|
function ShowQrWithCopy({ text }: { text: string }): VNode {
|
|
|
|
const [showing, setShowing] = useState(false);
|
|
|
|
async function copy(): Promise<void> {
|
|
|
|
navigator.clipboard.writeText(text);
|
|
|
|
}
|
|
|
|
async function toggle(): Promise<void> {
|
|
|
|
setShowing((s) => !s);
|
|
|
|
}
|
|
|
|
if (showing) {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<QR text={text} />
|
|
|
|
<Button onClick={copy}>copy</Button>
|
|
|
|
<Button onClick={toggle}>hide qr</Button>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div>{text.substring(0, 64)}...</div>
|
|
|
|
<Button onClick={copy}>copy</Button>
|
|
|
|
<Button onClick={toggle}>show qr</Button>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transaction.type === TransactionType.PeerPullCredit) {
|
|
|
|
const total = Amounts.parseOrThrow(transaction.amountEffective);
|
|
|
|
return (
|
|
|
|
<TransactionTemplate>
|
|
|
|
<Header
|
|
|
|
timestamp={transaction.timestamp}
|
|
|
|
type={i18n.str`Credit`}
|
|
|
|
total={total}
|
|
|
|
kind="positive"
|
|
|
|
>
|
|
|
|
Invoice
|
|
|
|
</Header>
|
|
|
|
|
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>Exchange</i18n.Translate>}
|
|
|
|
text={transaction.exchangeBaseUrl}
|
|
|
|
kind="neutral"
|
|
|
|
/>
|
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>URI</i18n.Translate>}
|
|
|
|
text={<ShowQrWithCopy text={transaction.talerUri} />}
|
|
|
|
kind="neutral"
|
|
|
|
/>
|
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>Details</i18n.Translate>}
|
|
|
|
text={
|
|
|
|
<InvoiceDetails
|
|
|
|
amount={{
|
|
|
|
effective: Amounts.parseOrThrow(transaction.amountEffective),
|
|
|
|
raw: Amounts.parseOrThrow(transaction.amountRaw),
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</TransactionTemplate>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transaction.type === TransactionType.PeerPullDebit) {
|
|
|
|
const total = Amounts.parseOrThrow(transaction.amountEffective);
|
|
|
|
return (
|
|
|
|
<TransactionTemplate>
|
|
|
|
<Header
|
|
|
|
timestamp={transaction.timestamp}
|
|
|
|
type={i18n.str`Debit`}
|
|
|
|
total={total}
|
|
|
|
kind="negative"
|
|
|
|
>
|
|
|
|
Invoice
|
|
|
|
</Header>
|
|
|
|
|
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>Exchange</i18n.Translate>}
|
|
|
|
text={transaction.exchangeBaseUrl}
|
|
|
|
kind="neutral"
|
|
|
|
/>
|
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>Details</i18n.Translate>}
|
|
|
|
text={
|
|
|
|
<InvoiceDetails
|
|
|
|
amount={{
|
|
|
|
effective: Amounts.parseOrThrow(transaction.amountEffective),
|
|
|
|
raw: Amounts.parseOrThrow(transaction.amountRaw),
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</TransactionTemplate>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (transaction.type === TransactionType.PeerPushDebit) {
|
|
|
|
const total = Amounts.parseOrThrow(transaction.amountEffective);
|
|
|
|
return (
|
|
|
|
<TransactionTemplate>
|
|
|
|
<Header
|
|
|
|
timestamp={transaction.timestamp}
|
|
|
|
type={i18n.str`Debit`}
|
|
|
|
total={total}
|
|
|
|
kind="negative"
|
|
|
|
>
|
|
|
|
Transfer
|
|
|
|
</Header>
|
|
|
|
|
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>Exchange</i18n.Translate>}
|
|
|
|
text={transaction.exchangeBaseUrl}
|
|
|
|
kind="neutral"
|
|
|
|
/>
|
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>URI</i18n.Translate>}
|
|
|
|
text={<QR text={transaction.talerUri} />}
|
|
|
|
kind="neutral"
|
|
|
|
/>
|
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>Details</i18n.Translate>}
|
|
|
|
text={
|
|
|
|
<TransferDetails
|
|
|
|
amount={{
|
|
|
|
effective: Amounts.parseOrThrow(transaction.amountEffective),
|
|
|
|
raw: Amounts.parseOrThrow(transaction.amountRaw),
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</TransactionTemplate>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transaction.type === TransactionType.PeerPushCredit) {
|
|
|
|
const total = Amounts.parseOrThrow(transaction.amountEffective);
|
|
|
|
return (
|
|
|
|
<TransactionTemplate>
|
|
|
|
<Header
|
|
|
|
timestamp={transaction.timestamp}
|
|
|
|
type={i18n.str`Credit`}
|
|
|
|
total={total}
|
|
|
|
kind="positive"
|
|
|
|
>
|
|
|
|
Transfer
|
|
|
|
</Header>
|
|
|
|
|
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>Exchange</i18n.Translate>}
|
|
|
|
text={transaction.exchangeBaseUrl}
|
|
|
|
kind="neutral"
|
|
|
|
/>
|
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>Details</i18n.Translate>}
|
|
|
|
text={
|
|
|
|
<TransferDetails
|
|
|
|
amount={{
|
|
|
|
effective: Amounts.parseOrThrow(transaction.amountEffective),
|
|
|
|
raw: Amounts.parseOrThrow(transaction.amountRaw),
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</TransactionTemplate>
|
|
|
|
);
|
|
|
|
}
|
2021-11-16 17:59:53 +01:00
|
|
|
return <div />;
|
2021-06-16 23:21:03 +02:00
|
|
|
}
|
2022-05-26 20:55:14 +02:00
|
|
|
|
2022-08-08 19:09:28 +02:00
|
|
|
export function MerchantDetails({
|
|
|
|
merchant,
|
|
|
|
}: {
|
|
|
|
merchant: MerchantInfo;
|
|
|
|
}): VNode {
|
|
|
|
return (
|
|
|
|
<div style={{ display: "flex", flexDirection: "row" }}>
|
|
|
|
{merchant.logo && (
|
|
|
|
<div>
|
|
|
|
<img
|
|
|
|
src={merchant.logo}
|
|
|
|
style={{ width: 64, height: 64, margin: 4 }}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<div>
|
|
|
|
<p style={{ marginTop: 0 }}>{merchant.name}</p>
|
|
|
|
{merchant.website && (
|
|
|
|
<a
|
|
|
|
href={merchant.website}
|
|
|
|
target="_blank"
|
|
|
|
style={{ textDecorationColor: "gray" }}
|
|
|
|
rel="noreferrer"
|
|
|
|
>
|
|
|
|
<SmallLightText>{merchant.website}</SmallLightText>
|
|
|
|
</a>
|
|
|
|
)}
|
|
|
|
{merchant.email && (
|
|
|
|
<a
|
|
|
|
href={`mailto:${merchant.email}`}
|
|
|
|
style={{ textDecorationColor: "gray" }}
|
|
|
|
>
|
|
|
|
<SmallLightText>{merchant.email}</SmallLightText>
|
|
|
|
</a>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-05-26 20:55:14 +02:00
|
|
|
function DeliveryDetails({
|
|
|
|
date,
|
|
|
|
location,
|
|
|
|
}: {
|
|
|
|
date: TalerProtocolTimestamp | undefined;
|
|
|
|
location: Location | undefined;
|
|
|
|
}): VNode {
|
|
|
|
const { i18n } = useTranslationContext();
|
|
|
|
return (
|
|
|
|
<PurchaseDetailsTable>
|
|
|
|
{location && (
|
|
|
|
<Fragment>
|
|
|
|
{location.country && (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<i18n.Translate>Country</i18n.Translate>
|
|
|
|
</td>
|
|
|
|
<td>{location.country}</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
{location.address_lines && (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<i18n.Translate>Address lines</i18n.Translate>
|
|
|
|
</td>
|
|
|
|
<td>{location.address_lines}</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
{location.building_number && (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<i18n.Translate>Building number</i18n.Translate>
|
|
|
|
</td>
|
|
|
|
<td>{location.building_number}</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
{location.building_name && (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<i18n.Translate>Building name</i18n.Translate>
|
|
|
|
</td>
|
|
|
|
<td>{location.building_name}</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
{location.street && (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<i18n.Translate>Street</i18n.Translate>
|
|
|
|
</td>
|
|
|
|
<td>{location.street}</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
{location.post_code && (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<i18n.Translate>Post code</i18n.Translate>
|
|
|
|
</td>
|
|
|
|
<td>{location.post_code}</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
{location.town_location && (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<i18n.Translate>Town location</i18n.Translate>
|
|
|
|
</td>
|
|
|
|
<td>{location.town_location}</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
{location.town && (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<i18n.Translate>Town</i18n.Translate>
|
|
|
|
</td>
|
|
|
|
<td>{location.town}</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
{location.district && (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<i18n.Translate>District</i18n.Translate>
|
|
|
|
</td>
|
|
|
|
<td>{location.district}</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
{location.country_subdivision && (
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<i18n.Translate>Country subdivision</i18n.Translate>
|
|
|
|
</td>
|
|
|
|
<td>{location.country_subdivision}</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
</Fragment>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{!location || !date ? undefined : (
|
|
|
|
<tr>
|
|
|
|
<td colSpan={2}>
|
|
|
|
<hr />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
{date && (
|
|
|
|
<Fragment>
|
|
|
|
<tr>
|
|
|
|
<td>Date</td>
|
|
|
|
<td>
|
|
|
|
<Time
|
|
|
|
timestamp={AbsoluteTime.fromTimestamp(date)}
|
|
|
|
format="dd MMMM yyyy, HH:mm"
|
|
|
|
/>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</Fragment>
|
|
|
|
)}
|
|
|
|
</PurchaseDetailsTable>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-08-10 16:50:46 +02:00
|
|
|
export function ExchangeDetails({ exchange }: { exchange: string }): VNode {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<p style={{ marginTop: 0 }}>
|
|
|
|
<a rel="noreferrer" target="_blank" href={exchange}>
|
|
|
|
{exchange}
|
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-08-08 19:09:28 +02:00
|
|
|
export interface AmountWithFee {
|
|
|
|
effective: AmountJson;
|
|
|
|
raw: AmountJson;
|
|
|
|
}
|
2022-08-10 16:50:46 +02:00
|
|
|
|
2022-08-31 05:20:35 +02:00
|
|
|
export function InvoiceDetails({ amount }: { amount: AmountWithFee }): VNode {
|
|
|
|
const { i18n } = useTranslationContext();
|
|
|
|
|
|
|
|
const fee = Amounts.sub(amount.raw, amount.effective).amount;
|
|
|
|
|
|
|
|
const maxFrac = [amount.raw, amount.effective, fee]
|
|
|
|
.map((a) => Amounts.maxFractionalDigits(a))
|
|
|
|
.reduce((c, p) => Math.max(c, p), 0);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<PurchaseDetailsTable>
|
|
|
|
<tr>
|
|
|
|
<td>Invoice</td>
|
|
|
|
<td>
|
|
|
|
<Amount value={amount.raw} maxFracSize={maxFrac} />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
{Amounts.isNonZero(fee) && (
|
|
|
|
<tr>
|
|
|
|
<td>Transaction fees</td>
|
|
|
|
<td>
|
|
|
|
<Amount value={fee} negative maxFracSize={maxFrac} />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
<tr>
|
|
|
|
<td colSpan={2}>
|
|
|
|
<hr />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Total</td>
|
|
|
|
<td>
|
|
|
|
<Amount value={amount.effective} maxFracSize={maxFrac} />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</PurchaseDetailsTable>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function TransferDetails({ amount }: { amount: AmountWithFee }): VNode {
|
|
|
|
const { i18n } = useTranslationContext();
|
|
|
|
|
|
|
|
const fee = Amounts.sub(amount.raw, amount.effective).amount;
|
|
|
|
|
|
|
|
const maxFrac = [amount.raw, amount.effective, fee]
|
|
|
|
.map((a) => Amounts.maxFractionalDigits(a))
|
|
|
|
.reduce((c, p) => Math.max(c, p), 0);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<PurchaseDetailsTable>
|
|
|
|
<tr>
|
|
|
|
<td>Transfer</td>
|
|
|
|
<td>
|
|
|
|
<Amount value={amount.raw} maxFracSize={maxFrac} />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
{Amounts.isNonZero(fee) && (
|
|
|
|
<tr>
|
|
|
|
<td>Transaction fees</td>
|
|
|
|
<td>
|
|
|
|
<Amount value={fee} negative maxFracSize={maxFrac} />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
<tr>
|
|
|
|
<td colSpan={2}>
|
|
|
|
<hr />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Total</td>
|
|
|
|
<td>
|
|
|
|
<Amount value={amount.effective} maxFracSize={maxFrac} />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</PurchaseDetailsTable>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-08-10 16:50:46 +02:00
|
|
|
export function WithdrawDetails({ amount }: { amount: AmountWithFee }): VNode {
|
|
|
|
const { i18n } = useTranslationContext();
|
|
|
|
|
|
|
|
const fee = Amounts.sub(amount.raw, amount.effective).amount;
|
|
|
|
|
|
|
|
const maxFrac = [amount.raw, amount.effective, fee]
|
|
|
|
.map((a) => Amounts.maxFractionalDigits(a))
|
|
|
|
.reduce((c, p) => Math.max(c, p), 0);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<PurchaseDetailsTable>
|
|
|
|
<tr>
|
|
|
|
<td>Withdraw</td>
|
|
|
|
<td>
|
|
|
|
<Amount value={amount.raw} maxFracSize={maxFrac} />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
{Amounts.isNonZero(fee) && (
|
|
|
|
<tr>
|
|
|
|
<td>Transaction fees</td>
|
|
|
|
<td>
|
|
|
|
<Amount value={fee} negative maxFracSize={maxFrac} />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
<tr>
|
|
|
|
<td colSpan={2}>
|
|
|
|
<hr />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Total</td>
|
|
|
|
<td>
|
|
|
|
<Amount value={amount.effective} maxFracSize={maxFrac} />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</PurchaseDetailsTable>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-08-08 19:09:28 +02:00
|
|
|
export function PurchaseDetails({
|
|
|
|
price,
|
|
|
|
refund,
|
|
|
|
info,
|
|
|
|
proposalId,
|
2022-05-26 20:55:14 +02:00
|
|
|
}: {
|
2022-08-08 19:09:28 +02:00
|
|
|
price: AmountWithFee;
|
|
|
|
refund?: AmountWithFee;
|
|
|
|
info: OrderShortInfo;
|
|
|
|
proposalId: string;
|
2022-05-26 20:55:14 +02:00
|
|
|
}): VNode {
|
|
|
|
const { i18n } = useTranslationContext();
|
|
|
|
|
2022-08-08 19:09:28 +02:00
|
|
|
const partialFee = Amounts.sub(price.effective, price.raw).amount;
|
2022-05-26 20:55:14 +02:00
|
|
|
|
2022-08-08 19:09:28 +02:00
|
|
|
const refundFee = !refund
|
|
|
|
? Amounts.getZero(price.effective.currency)
|
|
|
|
: Amounts.sub(refund.raw, refund.effective).amount;
|
2022-05-26 20:55:14 +02:00
|
|
|
|
|
|
|
const fee = Amounts.sum([partialFee, refundFee]).amount;
|
|
|
|
|
2022-08-08 19:09:28 +02:00
|
|
|
const hasProducts = info.products && info.products.length > 0;
|
2022-05-26 20:55:14 +02:00
|
|
|
|
|
|
|
const hasShipping =
|
2022-08-08 19:09:28 +02:00
|
|
|
info.delivery_date !== undefined || info.delivery_location !== undefined;
|
2022-05-26 20:55:14 +02:00
|
|
|
|
|
|
|
const showLargePic = (): void => {
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
|
2022-08-08 19:09:28 +02:00
|
|
|
const total = !refund
|
|
|
|
? price.effective
|
|
|
|
: Amounts.sub(price.effective, refund.effective).amount;
|
2022-05-26 20:55:14 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<PurchaseDetailsTable>
|
|
|
|
<tr>
|
|
|
|
<td>Price</td>
|
|
|
|
<td>
|
2022-08-08 19:09:28 +02:00
|
|
|
<Amount value={price.raw} />
|
2022-05-26 20:55:14 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
2022-08-08 19:09:28 +02:00
|
|
|
{refund && Amounts.isNonZero(refund.raw) && (
|
2022-05-26 20:55:14 +02:00
|
|
|
<tr>
|
|
|
|
<td>Refunded</td>
|
|
|
|
<td>
|
2022-08-08 19:09:28 +02:00
|
|
|
<Amount value={refund.raw} negative />
|
2022-05-26 20:55:14 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
{Amounts.isNonZero(fee) && (
|
|
|
|
<tr>
|
|
|
|
<td>Transaction fees</td>
|
|
|
|
<td>
|
|
|
|
<Amount value={fee} />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
<tr>
|
|
|
|
<td colSpan={2}>
|
|
|
|
<hr />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Total</td>
|
|
|
|
<td>
|
|
|
|
<Amount value={total} />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{hasProducts && (
|
|
|
|
<tr>
|
|
|
|
<td colSpan={2}>
|
|
|
|
<PartCollapsible
|
|
|
|
big
|
|
|
|
title={<i18n.Translate>Products</i18n.Translate>}
|
|
|
|
text={
|
|
|
|
<ListOfProducts>
|
2022-08-08 19:09:28 +02:00
|
|
|
{info.products?.map((p, k) => (
|
2022-05-26 20:55:14 +02:00
|
|
|
<Row key={k}>
|
|
|
|
<a href="#" onClick={showLargePic}>
|
|
|
|
<img src={p.image ? p.image : emptyImg} />
|
|
|
|
</a>
|
|
|
|
<div>
|
|
|
|
{p.quantity && p.quantity > 0 && (
|
|
|
|
<SmallLightText>
|
|
|
|
x {p.quantity} {p.unit}
|
|
|
|
</SmallLightText>
|
|
|
|
)}
|
|
|
|
<div>{p.description}</div>
|
|
|
|
</div>
|
|
|
|
</Row>
|
|
|
|
))}
|
|
|
|
</ListOfProducts>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
{hasShipping && (
|
|
|
|
<tr>
|
|
|
|
<td colSpan={2}>
|
|
|
|
<PartCollapsible
|
|
|
|
big
|
|
|
|
title={<i18n.Translate>Delivery</i18n.Translate>}
|
|
|
|
text={
|
|
|
|
<DeliveryDetails
|
2022-08-08 19:09:28 +02:00
|
|
|
date={info.delivery_date}
|
|
|
|
location={info.delivery_location}
|
2022-05-26 20:55:14 +02:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
2022-08-08 19:09:28 +02:00
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<ShowFullContractTermPopup proposalId={proposalId} />
|
|
|
|
</td>
|
|
|
|
</tr>
|
2022-05-26 20:55:14 +02:00
|
|
|
</PurchaseDetailsTable>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function RefundDetails({
|
|
|
|
transaction,
|
|
|
|
}: {
|
|
|
|
transaction: TransactionRefund;
|
|
|
|
}): VNode {
|
|
|
|
const { i18n } = useTranslationContext();
|
|
|
|
|
2022-06-09 18:37:33 +02:00
|
|
|
const r = Amounts.parseOrThrow(transaction.amountRaw);
|
|
|
|
const e = Amounts.parseOrThrow(transaction.amountEffective);
|
|
|
|
const fee = Amounts.sub(r, e).amount;
|
|
|
|
|
|
|
|
const maxFrac = [r, e, fee]
|
|
|
|
.map((a) => Amounts.maxFractionalDigits(a))
|
|
|
|
.reduce((c, p) => Math.max(c, p), 0);
|
2022-05-26 20:55:14 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<PurchaseDetailsTable>
|
|
|
|
<tr>
|
|
|
|
<td>Amount</td>
|
|
|
|
<td>
|
2022-06-09 18:37:33 +02:00
|
|
|
<Amount value={transaction.amountRaw} maxFracSize={maxFrac} />
|
2022-05-26 20:55:14 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
{Amounts.isNonZero(fee) && (
|
|
|
|
<tr>
|
|
|
|
<td>Transaction fees</td>
|
|
|
|
<td>
|
2022-06-09 18:37:33 +02:00
|
|
|
<Amount value={fee} negative maxFracSize={maxFrac} />
|
2022-05-26 20:55:14 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
<tr>
|
|
|
|
<td colSpan={2}>
|
|
|
|
<hr />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Total</td>
|
|
|
|
<td>
|
2022-06-09 18:37:33 +02:00
|
|
|
<Amount value={transaction.amountEffective} maxFracSize={maxFrac} />
|
2022-05-26 20:55:14 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</PurchaseDetailsTable>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function DepositDetails({
|
|
|
|
transaction,
|
|
|
|
}: {
|
|
|
|
transaction: TransactionDeposit;
|
|
|
|
}): VNode {
|
|
|
|
const { i18n } = useTranslationContext();
|
2022-06-09 18:37:33 +02:00
|
|
|
const r = Amounts.parseOrThrow(transaction.amountRaw);
|
|
|
|
const e = Amounts.parseOrThrow(transaction.amountEffective);
|
|
|
|
const fee = Amounts.sub(r, e).amount;
|
2022-05-26 20:55:14 +02:00
|
|
|
|
2022-06-09 18:37:33 +02:00
|
|
|
const maxFrac = [r, e, fee]
|
|
|
|
.map((a) => Amounts.maxFractionalDigits(a))
|
|
|
|
.reduce((c, p) => Math.max(c, p), 0);
|
2022-05-26 20:55:14 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<PurchaseDetailsTable>
|
|
|
|
<tr>
|
|
|
|
<td>Amount</td>
|
|
|
|
<td>
|
2022-06-09 18:37:33 +02:00
|
|
|
<Amount value={transaction.amountRaw} maxFracSize={maxFrac} />
|
2022-05-26 20:55:14 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
{Amounts.isNonZero(fee) && (
|
|
|
|
<tr>
|
|
|
|
<td>Transaction fees</td>
|
|
|
|
<td>
|
2022-06-09 18:37:33 +02:00
|
|
|
<Amount value={fee} negative maxFracSize={maxFrac} />
|
2022-05-26 20:55:14 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
<tr>
|
|
|
|
<td colSpan={2}>
|
|
|
|
<hr />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Total transfer</td>
|
|
|
|
<td>
|
2022-06-09 18:37:33 +02:00
|
|
|
<Amount value={transaction.amountEffective} maxFracSize={maxFrac} />
|
2022-05-26 20:55:14 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</PurchaseDetailsTable>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
function RefreshDetails({
|
|
|
|
transaction,
|
|
|
|
}: {
|
|
|
|
transaction: TransactionRefresh;
|
|
|
|
}): VNode {
|
|
|
|
const { i18n } = useTranslationContext();
|
|
|
|
|
2022-06-09 18:37:33 +02:00
|
|
|
const r = Amounts.parseOrThrow(transaction.amountRaw);
|
|
|
|
const e = Amounts.parseOrThrow(transaction.amountEffective);
|
|
|
|
const fee = Amounts.sub(r, e).amount;
|
|
|
|
|
|
|
|
const maxFrac = [r, e, fee]
|
|
|
|
.map((a) => Amounts.maxFractionalDigits(a))
|
|
|
|
.reduce((c, p) => Math.max(c, p), 0);
|
2022-05-26 20:55:14 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<PurchaseDetailsTable>
|
|
|
|
<tr>
|
|
|
|
<td>Amount</td>
|
|
|
|
<td>
|
2022-06-09 18:37:33 +02:00
|
|
|
<Amount value={transaction.amountRaw} maxFracSize={maxFrac} />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Transaction fees</td>
|
|
|
|
<td>
|
|
|
|
<Amount value={fee} negative maxFracSize={maxFrac} />
|
2022-05-26 20:55:14 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td colSpan={2}>
|
|
|
|
<hr />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2022-06-09 18:37:33 +02:00
|
|
|
<td>Total</td>
|
2022-05-26 20:55:14 +02:00
|
|
|
<td>
|
2022-06-09 18:37:33 +02:00
|
|
|
<Amount value={transaction.amountEffective} maxFracSize={maxFrac} />
|
2022-05-26 20:55:14 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</PurchaseDetailsTable>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function TipDetails({ transaction }: { transaction: TransactionTip }): VNode {
|
|
|
|
const { i18n } = useTranslationContext();
|
|
|
|
|
2022-06-09 18:37:33 +02:00
|
|
|
const r = Amounts.parseOrThrow(transaction.amountRaw);
|
|
|
|
const e = Amounts.parseOrThrow(transaction.amountEffective);
|
|
|
|
const fee = Amounts.sub(r, e).amount;
|
|
|
|
|
|
|
|
const maxFrac = [r, e, fee]
|
|
|
|
.map((a) => Amounts.maxFractionalDigits(a))
|
|
|
|
.reduce((c, p) => Math.max(c, p), 0);
|
2022-05-26 20:55:14 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<PurchaseDetailsTable>
|
|
|
|
<tr>
|
|
|
|
<td>Amount</td>
|
|
|
|
<td>
|
2022-06-09 18:37:33 +02:00
|
|
|
<Amount value={transaction.amountRaw} maxFracSize={maxFrac} />
|
2022-05-26 20:55:14 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
{Amounts.isNonZero(fee) && (
|
|
|
|
<tr>
|
|
|
|
<td>Transaction fees</td>
|
|
|
|
<td>
|
2022-06-09 18:37:33 +02:00
|
|
|
<Amount value={fee} negative maxFracSize={maxFrac} />
|
2022-05-26 20:55:14 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)}
|
|
|
|
<tr>
|
|
|
|
<td colSpan={2}>
|
|
|
|
<hr />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Total</td>
|
|
|
|
<td>
|
2022-06-09 18:37:33 +02:00
|
|
|
<Amount value={transaction.amountEffective} maxFracSize={maxFrac} />
|
2022-05-26 20:55:14 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</PurchaseDetailsTable>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function Header({
|
|
|
|
timestamp,
|
|
|
|
total,
|
|
|
|
children,
|
|
|
|
kind,
|
|
|
|
type,
|
|
|
|
}: {
|
|
|
|
timestamp: TalerProtocolTimestamp;
|
|
|
|
total: AmountJson;
|
|
|
|
children: ComponentChildren;
|
|
|
|
kind: Kind;
|
|
|
|
type: string;
|
|
|
|
}): VNode {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
display: "flex",
|
|
|
|
justifyContent: "space-between",
|
|
|
|
flexDirection: "row",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<SubTitle>{children}</SubTitle>
|
|
|
|
<Time
|
|
|
|
timestamp={AbsoluteTime.fromTimestamp(timestamp)}
|
|
|
|
format="dd MMMM yyyy, HH:mm"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<SubTitle>
|
|
|
|
<Part
|
|
|
|
title={type}
|
2022-06-09 18:37:33 +02:00
|
|
|
text={<Amount value={total} negative={kind === "negative"} />}
|
2022-05-26 20:55:14 +02:00
|
|
|
kind={kind}
|
|
|
|
/>
|
|
|
|
</SubTitle>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2022-05-29 06:23:15 +02:00
|
|
|
|
|
|
|
function NicePayto({ payto }: { payto: PaytoUri }): VNode {
|
|
|
|
if (payto.isKnown) {
|
|
|
|
switch (payto.targetType) {
|
|
|
|
case "bitcoin": {
|
|
|
|
return <div>{payto.targetPath.substring(0, 20)}...</div>;
|
|
|
|
}
|
|
|
|
case "x-taler-bank": {
|
|
|
|
const url = new URL("/", `https://${payto.host}`);
|
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<div>{payto.account}</div>
|
|
|
|
<SmallLightText>
|
|
|
|
<a href={url.href} target="_bank" rel="noreferrer">
|
|
|
|
{url.toString()}
|
|
|
|
</a>
|
|
|
|
</SmallLightText>
|
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
case "iban": {
|
|
|
|
return <div>{payto.targetPath.substring(0, 20)}</div>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return <Fragment>{stringifyPaytoUri(payto)}</Fragment>;
|
|
|
|
}
|