From 43c7cff75055f72c7d59a7180ae8da2554456d8d Mon Sep 17 00:00:00 2001
From: Sebastian
Date: Mon, 7 Nov 2022 19:29:47 -0300
Subject: un-uglyfy, fix: 7442
---
.../src/wallet/ManageAccount/stories.tsx | 3 +-
.../src/wallet/ManageAccount/views.tsx | 147 +++++++++++++--------
.../src/wallet/Transaction.tsx | 4 +-
3 files changed, 94 insertions(+), 60 deletions(-)
(limited to 'packages/taler-wallet-webextension/src/wallet')
diff --git a/packages/taler-wallet-webextension/src/wallet/ManageAccount/stories.tsx b/packages/taler-wallet-webextension/src/wallet/ManageAccount/stories.tsx
index c0d3a38b0..875dec227 100644
--- a/packages/taler-wallet-webextension/src/wallet/ManageAccount/stories.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ManageAccount/stories.tsx
@@ -194,8 +194,9 @@ export const AddingIbanAccount = createExample(ReadyView, {
uri: {
targetType: "iban",
iban: "ASDQWEQWE",
+ bic: "SANDBOX",
isKnown: true,
- targetPath: "/ASDQWEQWE",
+ targetPath: "SANDBOX/ASDQWEQWE",
params: {},
},
},
diff --git a/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx b/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx
index 326e078f4..3af0d5505 100644
--- a/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx
@@ -23,7 +23,6 @@ import {
import { styled } from "@linaria/react";
import { Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks";
-import { ErrorMessage } from "../../components/ErrorMessage.js";
import { LoadingError } from "../../components/LoadingError.js";
import { SelectList } from "../../components/SelectList.js";
import {
@@ -41,6 +40,7 @@ import checkIcon from "../../svg/check_24px.svg";
import warningIcon from "../../svg/warning_24px.svg";
import deleteIcon from "../../svg/delete_24px.svg";
import { State } from "./index.js";
+import { ErrorMessage } from "../../components/ErrorMessage.js";
type AccountType = "bitcoin" | "x-taler-bank" | "iban";
type ComponentFormByAccountType = {
@@ -143,9 +143,9 @@ export function ReadyView({
Alias
+
+ Bank Id
+ |
Int. Account Number
|
@@ -219,7 +222,8 @@ function IbanTable({
return (
{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
|
-
+
|
)}
--
cgit v1.2.3