From 1657e3136941f99b2b5e7d5e5cc8a2d8122628fa Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 12 Apr 2024 11:49:58 -0300 Subject: dd53: Deposits should use the receiver name of the payto-URI of the target account --- .../src/components/HistoryItem.tsx | 90 ++++++++++++---------- .../src/wallet/ManageAccount/views.tsx | 38 +++++---- 2 files changed, 72 insertions(+), 56 deletions(-) (limited to 'packages/taler-wallet-webextension/src') diff --git a/packages/taler-wallet-webextension/src/components/HistoryItem.tsx b/packages/taler-wallet-webextension/src/components/HistoryItem.tsx index 8bdd98f6a..833448e67 100644 --- a/packages/taler-wallet-webextension/src/components/HistoryItem.tsx +++ b/packages/taler-wallet-webextension/src/components/HistoryItem.tsx @@ -24,6 +24,7 @@ import { WithdrawalType, TransactionMajorState, DenomLossEventType, + parsePaytoUri, } from "@gnu-taler/taler-util"; import { h, VNode } from "preact"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; @@ -136,9 +137,7 @@ export function HistoryItem(props: { tx: Transaction }): VNode { /> ); case TransactionType.Reward: - return ( -
not supported
- ); + return
not supported
; case TransactionType.Refresh: return ( ); - case TransactionType.Deposit: + case TransactionType.Deposit:{ + const payto = parsePaytoUri(tx.targetPaytoUri); + const title = payto === undefined || !payto.isKnown ? tx.targetPaytoUri : + payto.params["receiver-name"] ; return ( ); + } case TransactionType.PeerPullCredit: return ( ); - case TransactionType.DenomLoss: + case TransactionType.DenomLoss: { switch (tx.lossEventType) { case DenomLossEventType.DenomExpired: { - return + return ( + + ); } case DenomLossEventType.DenomVanished: { - return + return ( + + ); } case DenomLossEventType.DenomUnoffered: { - - return + return ( + + ); } default: { - assertUnreachable(tx.lossEventType) + assertUnreachable(tx.lossEventType); } } + break; + } case TransactionType.Recoup: throw Error("recoup transaction not implemented"); default: { @@ -300,12 +310,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/ManageAccount/views.tsx b/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx index 4d045ee13..7b80977f3 100644 --- a/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx +++ b/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx @@ -23,13 +23,12 @@ import { stringifyPaytoUri, validateIban, } from "@gnu-taler/taler-util"; +import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { styled } from "@linaria/react"; import { Fragment, h, VNode } from "preact"; import { useState } from "preact/hooks"; import { ErrorMessage } from "../../components/ErrorMessage.js"; -import { SelectList } from "../../components/SelectList.js"; -import { Input, SubTitle, SvgIcon } from "../../components/styled/index.js"; -import { useTranslationContext } from "@gnu-taler/web-util/browser"; +import { SubTitle, SvgIcon } from "../../components/styled/index.js"; import { Button } from "../../mui/Button.js"; import { TextFieldHandler } from "../../mui/handlers.js"; import { TextField } from "../../mui/TextField.js"; @@ -110,6 +109,7 @@ export function ReadyView({
{Object.entries(accountType.list).map(([key, name], idx) => (
{ + onClick={() => { if (accountType.onChange) { accountType.onChange(key); } @@ -130,6 +130,7 @@ export function ReadyView({ ))}
+ --- {uri.value} ---

(obj: T): T | undefined { - return Object.keys(obj).some((k) => (obj as any)[k] !== undefined) + return Object.keys(obj).some((k) => (obj as Record)[k] !== undefined) ? obj : undefined; } @@ -488,20 +489,21 @@ function TalerBankAddressAccount({ } //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}$/; +// 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 [bic, setBic] = useState(undefined); + // const [bic, setBic] = useState(undefined); const [iban, setIban] = useState(undefined); const [name, setName] = useState(undefined); - const errors = undefinedIfEmpty({ - bic: !bic - ? undefined - : !bicRegex.test(bic) - ? i18n.str`Invalid bic` - : undefined, + const bic = "" + const errorsFN = (iban:string | undefined, name: string | undefined) => undefinedIfEmpty({ + // bic: !bic + // ? undefined + // : !bicRegex.test(bic) + // ? i18n.str`Invalid bic` + // : undefined, iban: !iban ? i18n.str`Can't be empty` : validateIban(iban).type === "invalid" @@ -509,16 +511,20 @@ function IbanAddressAccount({ field }: { field: TextFieldHandler }): VNode { : undefined, name: !name ? i18n.str`Can't be empty` : undefined, }); + const errors = errorsFN(iban, name) function sendUpdateIfNoErrors( bic: string | undefined, iban: string, name: string, ): void { - if (!errors && field.onInput) { + if (!field.onInput) return; + if (!errorsFN(iban, name)) { const p = buildPayto("iban", iban, bic); p.params["receiver-name"] = name; field.onInput(stringifyPaytoUri(p)); + } else { + field.onInput("") } } return ( @@ -584,7 +590,7 @@ function CustomFieldByAccountType({ type: AccountType; field: TextFieldHandler; }): VNode { - const { i18n } = useTranslationContext(); + // const { i18n } = useTranslationContext(); const AccountForm = formComponentByAccountType[type]; -- cgit v1.2.3