aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-wallet-webextension/src/components/HistoryItem.tsx6
-rw-r--r--packages/taler-wallet-webextension/src/wallet/Transaction.tsx113
2 files changed, 74 insertions, 45 deletions
diff --git a/packages/taler-wallet-webextension/src/components/HistoryItem.tsx b/packages/taler-wallet-webextension/src/components/HistoryItem.tsx
index 72881c746..f65535a3d 100644
--- a/packages/taler-wallet-webextension/src/components/HistoryItem.tsx
+++ b/packages/taler-wallet-webextension/src/components/HistoryItem.tsx
@@ -253,6 +253,8 @@ export function HistoryItem(props: { tx: Transaction }): VNode {
}
/>
);
+ case TransactionType.Recoup:
+ throw Error("recoup transaction not implemented");
default: {
assertUnreachable(tx);
}
@@ -267,12 +269,12 @@ function Layout(props: LayoutProps): VNode {
style={{
backgroundColor:
props.currentState === TransactionMajorState.Pending ||
- props.currentState === TransactionMajorState.Dialog
+ props.currentState === TransactionMajorState.Dialog
? "lightcyan"
: props.currentState === TransactionMajorState.Failed
? "#ff000040"
: props.currentState === TransactionMajorState.Aborted ||
- props.currentState === TransactionMajorState.Aborting
+ props.currentState === TransactionMajorState.Aborting
? "#00000010"
: "inherit",
alignItems: "center",
diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
index d8ed38aa1..f6c98952e 100644
--- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
@@ -37,7 +37,7 @@ import {
TransactionType,
TransactionWithdrawal,
TranslatedString,
- WithdrawalType
+ WithdrawalType,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { useTranslationContext } from "@gnu-taler/web-util/browser";
@@ -62,7 +62,7 @@ import {
SmallLightText,
SubTitle,
SvgIcon,
- WarningBox
+ WarningBox,
} from "../components/styled/index.js";
import { Time } from "../components/Time.js";
import { alertFromError, useAlertContext } from "../context/alert.js";
@@ -229,8 +229,8 @@ function TransactionTemplate({
<Fragment>
<section style={{ padding: 8, textAlign: "center" }}>
{transaction?.error &&
- // FIXME: wallet core should stop sending this error on KYC
- transaction.error.code !==
+ // FIXME: wallet core should stop sending this error on KYC
+ transaction.error.code !==
TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED ? (
<ErrorAlertView
error={alertFromError(
@@ -249,7 +249,13 @@ function TransactionTemplate({
<div>
<i18n.Translate>
Follow this link to the{` `}
- <a rel="noreferrer" target="_bank" href={transaction.kycUrl}>KYC verifier</a>
+ <a
+ rel="noreferrer"
+ target="_bank"
+ href={transaction.kycUrl}
+ >
+ KYC verifier
+ </a>
</i18n.Translate>
</div>
) : (
@@ -435,8 +441,10 @@ export function TransactionView({
transaction.type === TransactionType.Withdrawal ||
transaction.type === TransactionType.InternalWithdrawal
) {
- const conversion = transaction.withdrawalDetails.type === WithdrawalType.ManualTransfer ?
- transaction.withdrawalDetails.exchangeCreditAccountDetails ?? [] : []
+ const conversion =
+ transaction.withdrawalDetails.type === WithdrawalType.ManualTransfer
+ ? transaction.withdrawalDetails.exchangeCreditAccountDetails ?? []
+ : [];
return (
<TransactionTemplate
transaction={transaction}
@@ -457,21 +465,23 @@ export function TransactionView({
</Header>
{transaction.txState.major !==
- TransactionMajorState.Pending ? undefined :
- transaction.txState.minor === TransactionMinorState.KycRequired ||
- transaction.txState.minor === TransactionMinorState.AmlRequired ? undefined :
- transaction
- .withdrawalDetails.type === WithdrawalType.ManualTransfer ? (
- //manual withdrawal
- <BankDetailsByPaytoType
- amount={raw}
- accounts={transaction.withdrawalDetails.exchangeCreditAccountDetails ?? []}
- subject={transaction.withdrawalDetails.reservePub}
- />
- ) : (
- //integrated bank withdrawal
- <ShowWithdrawalDetailForBankIntegrated transaction={transaction} />
- )}
+ TransactionMajorState.Pending ? undefined : transaction.txState
+ .minor === TransactionMinorState.KycRequired ||
+ transaction.txState.minor ===
+ TransactionMinorState.AmlRequired ? undefined : transaction
+ .withdrawalDetails.type === WithdrawalType.ManualTransfer ? (
+ //manual withdrawal
+ <BankDetailsByPaytoType
+ amount={raw}
+ accounts={
+ transaction.withdrawalDetails.exchangeCreditAccountDetails ?? []
+ }
+ subject={transaction.withdrawalDetails.reservePub}
+ />
+ ) : (
+ //integrated bank withdrawal
+ <ShowWithdrawalDetailForBankIntegrated transaction={transaction} />
+ )}
<Part
title={i18n.str`Details`}
text={
@@ -1028,6 +1038,10 @@ export function TransactionView({
</TransactionTemplate>
);
}
+
+ if (transaction.type === TransactionType.Recoup) {
+ throw Error("recoup transaction not implemented");
+ }
assertUnreachable(transaction);
}
@@ -1411,7 +1425,13 @@ export function TransferPickupDetails({
</PurchaseDetailsTable>
);
}
-export function WithdrawDetails({ conversion, amount }: { conversion?: AmountJson, amount: AmountWithFee }): VNode {
+export function WithdrawDetails({
+ conversion,
+ amount,
+}: {
+ conversion?: AmountJson;
+ amount: AmountWithFee;
+}): VNode {
const { i18n } = useTranslationContext();
const maxFrac = [amount.fee, amount.fee]
@@ -1422,7 +1442,7 @@ export function WithdrawDetails({ conversion, amount }: { conversion?: AmountJso
return (
<PurchaseDetailsTable>
- {conversion ?
+ {conversion ? (
<Fragment>
<tr>
<td>
@@ -1432,7 +1452,8 @@ export function WithdrawDetails({ conversion, amount }: { conversion?: AmountJso
<Amount value={conversion} maxFracSize={amount.maxFrac} />
</td>
</tr>
- {conversion.fraction === amount.value.fraction && conversion.value === amount.value.value ? undefined :
+ {conversion.fraction === amount.value.fraction &&
+ conversion.value === amount.value.value ? undefined : (
<tr>
<td>
<i18n.Translate>Converted</i18n.Translate>
@@ -1441,9 +1462,10 @@ export function WithdrawDetails({ conversion, amount }: { conversion?: AmountJso
<Amount value={amount.value} maxFracSize={amount.maxFrac} />
</td>
</tr>
- }
+ )}
</Fragment>
- : <tr>
+ ) : (
+ <tr>
<td>
<i18n.Translate>Transfer</i18n.Translate>
</td>
@@ -1451,7 +1473,7 @@ export function WithdrawDetails({ conversion, amount }: { conversion?: AmountJso
<Amount value={amount.value} maxFracSize={amount.maxFrac} />
</td>
</tr>
- }
+ )}
{Amounts.isNonZero(amount.fee) && (
<tr>
<td>
@@ -1683,19 +1705,22 @@ function calculateAmountByWireTransfer(
const allTracking = Object.values(state ?? {});
//group tracking by wtid, sum amounts
- const trackByWtid = allTracking.reduce((prev, cur) => {
- const fee = Amounts.parseOrThrow(cur.wireFee);
- const raw = Amounts.parseOrThrow(cur.amountRaw);
- const total = !prev[cur.wireTransferId]
- ? raw
- : Amounts.add(prev[cur.wireTransferId].total, raw).amount;
-
- prev[cur.wireTransferId] = {
- total,
- fee,
- };
- return prev;
- }, {} as Record<string, { total: AmountJson; fee: AmountJson }>);
+ const trackByWtid = allTracking.reduce(
+ (prev, cur) => {
+ const fee = Amounts.parseOrThrow(cur.wireFee);
+ const raw = Amounts.parseOrThrow(cur.amountRaw);
+ const total = !prev[cur.wireTransferId]
+ ? raw
+ : Amounts.add(prev[cur.wireTransferId].total, raw).amount;
+
+ prev[cur.wireTransferId] = {
+ total,
+ fee,
+ };
+ return prev;
+ },
+ {} as Record<string, { total: AmountJson; fee: AmountJson }>,
+ );
//remove wire fee from total amount
return Object.entries(trackByWtid).map(([id, info]) => ({
@@ -2022,12 +2047,14 @@ function ShowWithdrawalDetailForBankIntegrated({
{showDetails && (
<BankDetailsByPaytoType
amount={raw}
- accounts={transaction.withdrawalDetails.exchangeCreditAccountDetails ?? []}
+ accounts={
+ transaction.withdrawalDetails.exchangeCreditAccountDetails ?? []
+ }
subject={transaction.withdrawalDetails.reservePub}
/>
)}
{!transaction.withdrawalDetails.confirmed &&
- transaction.withdrawalDetails.bankConfirmationUrl ? (
+ transaction.withdrawalDetails.bankConfirmationUrl ? (
<InfoBox>
<div style={{ display: "block" }}>
<i18n.Translate>