{account.alias} |
- {p.targetPath} |
+ {p.bic} |
+ {p.iban} |
{p.params["receiver-name"]} |
{account.kyc_completed ? (
@@ -415,7 +419,7 @@ function BitcoinAddressAccount({ field }: { field: TextFieldHandler }): VNode {
variant="standard"
fullWidth
value={value}
- error={value !== undefined && !!errors?.value}
+ error={value !== undefined ? errors?.value : undefined}
disabled={!field.onInput}
onChange={(v) => {
setValue(v);
@@ -424,9 +428,6 @@ function BitcoinAddressAccount({ field }: { field: TextFieldHandler }): VNode {
}
}}
/>
- {value !== undefined && errors?.value && (
- {errors?.value}} />
- )}
);
}
@@ -456,7 +457,7 @@ function TalerBankAddressAccount({
variant="standard"
fullWidth
value={host}
- error={host !== undefined && !!errors?.host}
+ error={host !== undefined ? errors?.host : undefined}
disabled={!field.onInput}
onChange={(v) => {
setHost(v);
@@ -464,77 +465,109 @@ function TalerBankAddressAccount({
field.onInput(`payto://x-taler-bank/${v}/${account}`);
}
}}
- />{" "}
- {host !== undefined && errors?.host && (
- {errors?.host}} />
- )}
+ />
{
setAccount(v || "");
if (!errors && field.onInput) {
field.onInput(`payto://x-taler-bank/${host}/${v}`);
}
}}
- />{" "}
- {account !== undefined && errors?.account && (
- {errors?.account}} />
- )}
+ />
);
}
+//Taken from libeufin and libeufin took it from the ISO20022 XSD schema
+const bicRegex = /^[A-Z]{6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3})?$/;
+const ibanRegex = /^[A-Z]{2}[0-9]{2}[a-zA-Z0-9]{1,30}$/;
+
function IbanAddressAccount({ field }: { field: TextFieldHandler }): VNode {
const { i18n } = useTranslationContext();
- const [number, setNumber] = useState(undefined);
+ const [bic, setBic] = useState(undefined);
+ const [iban, setIban] = useState(undefined);
const [name, setName] = useState(undefined);
const errors = undefinedIfEmpty({
- number: !number ? i18n.str`Can't be empty` : undefined,
+ bic: !bic
+ ? undefined
+ : !bicRegex.test(bic)
+ ? i18n.str`Invalid bic`
+ : undefined,
+ iban: !iban
+ ? i18n.str`Can't be empty`
+ : !ibanRegex.test(iban)
+ ? i18n.str`Invalid iban`
+ : undefined,
name: !name ? i18n.str`Can't be empty` : undefined,
});
+
+ function sendUpdateIfNoErrors(
+ bic: string | undefined,
+ iban: string,
+ name: string,
+ ): void {
+ if (!errors && field.onInput) {
+ const path = bic === undefined ? iban : `${bic}/${iban}`;
+ field.onInput(
+ `payto://iban/${path}?receiver-name=${encodeURIComponent(name)}`,
+ );
+ }
+ }
return (
- {
- setNumber(v);
- if (!errors && field.onInput) {
- field.onInput(`payto://iban/${v}?receiver-name=${name}`);
- }
- }}
- />
- {number !== undefined && errors?.number && (
- {errors?.number}} />
- )}
- {
- setName(v);
- if (!errors && field.onInput) {
- field.onInput(
- `payto://iban/${number}?receiver-name=${encodeURIComponent(v)}`,
- );
- }
- }}
- />
- {name !== undefined && errors?.name && (
- {errors?.name}} />
- )}
+
+ {
+ setBic(v);
+ sendUpdateIfNoErrors(v, iban || "", name || "");
+ }}
+ />
+
+
+ {
+ setIban(v);
+ sendUpdateIfNoErrors(bic, v, name || "");
+ }}
+ />
+
+
+ {
+ setName(v);
+ sendUpdateIfNoErrors(bic, iban || "", v);
+ }}
+ />
+
);
}
diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
index 746d127cf..76bfe014b 100644
--- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
@@ -1343,7 +1343,7 @@ function DepositDetails({
const { i18n } = useTranslationContext();
const r = Amounts.parseOrThrow(transaction.amountRaw);
const e = Amounts.parseOrThrow(transaction.amountEffective);
- const fee = Amounts.sub(r, e).amount;
+ const fee = Amounts.sub(e, r).amount;
const maxFrac = [r, e, fee]
.map((a) => Amounts.maxFractionalDigits(a))
@@ -1366,7 +1366,7 @@ function DepositDetails({
Transaction fees
|
-
+
|
)}