add receiver name to iban form and fix some bugs

This commit is contained in:
Sebastian 2022-10-29 20:10:46 -03:00
parent 5ed4d5d54d
commit 7d69aca76f
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
3 changed files with 32 additions and 10 deletions

View File

@ -182,7 +182,7 @@ export function useComponentState(
async function doSend(): Promise<void> { async function doSend(): Promise<void> {
if (!parsedAmount || !currency) return; if (!parsedAmount || !currency) return;
const depositPaytoUri = `payto://${currentAccount.targetType}/${currentAccount.targetPath}`; const depositPaytoUri = stringifyPaytoUri(currentAccount);
const amount = Amounts.stringify(parsedAmount); const amount = Amounts.stringify(parsedAmount);
await api.wallet.call(WalletApiOperation.CreateDepositGroup, { await api.wallet.call(WalletApiOperation.CreateDepositGroup, {
amount, depositPaytoUri amount, depositPaytoUri

View File

@ -71,7 +71,7 @@ export function useComponentState(
? "that account is already present" ? "that account is already present"
: undefined; : undefined;
const unableToAdd = !type || !alias || paytoUriError !== undefined || uri !== undefined; const unableToAdd = !type || !alias || paytoUriError !== undefined || uri === undefined;
const accountByType: AccountByType = { const accountByType: AccountByType = {
iban: [], iban: [],

View File

@ -204,6 +204,9 @@ function IbanTable({
<th> <th>
<i18n.Translate>Int. Account Number</i18n.Translate> <i18n.Translate>Int. Account Number</i18n.Translate>
</th> </th>
<th>
<i18n.Translate>Account name</i18n.Translate>
</th>
<th class="kyc"> <th class="kyc">
<i18n.Translate>KYC</i18n.Translate> <i18n.Translate>KYC</i18n.Translate>
</th> </th>
@ -217,6 +220,7 @@ function IbanTable({
<tr key={account.alias}> <tr key={account.alias}>
<td>{account.alias}</td> <td>{account.alias}</td>
<td>{p.targetPath}</td> <td>{p.targetPath}</td>
<td>{p.params["receiver-name"]}</td>
<td class="kyc"> <td class="kyc">
{account.kyc_completed ? ( {account.kyc_completed ? (
<SvgIcon <SvgIcon
@ -484,9 +488,11 @@ function TalerBankAddressAccount({
function IbanAddressAccount({ field }: { field: TextFieldHandler }): VNode { function IbanAddressAccount({ field }: { field: TextFieldHandler }): VNode {
const { i18n } = useTranslationContext(); const { i18n } = useTranslationContext();
const [value, setValue] = useState<string | undefined>(undefined); const [number, setNumber] = useState<string | undefined>(undefined);
const [name, setName] = useState<string | undefined>(undefined);
const errors = undefinedIfEmpty({ const errors = undefinedIfEmpty({
value: !value ? i18n.str`Can't be empty` : undefined, number: !number ? i18n.str`Can't be empty` : undefined,
name: !name ? i18n.str`Can't be empty` : undefined,
}); });
return ( return (
<Fragment> <Fragment>
@ -494,17 +500,33 @@ function IbanAddressAccount({ field }: { field: TextFieldHandler }): VNode {
label="IBAN number" label="IBAN number"
variant="standard" variant="standard"
fullWidth fullWidth
value={value} value={number}
error={value !== undefined && !!errors?.value} error={number !== undefined && !!errors?.number}
onChange={(v) => { onChange={(v) => {
setValue(v); setNumber(v);
if (!errors) { if (!errors) {
field.onInput(`payto://iban/${v}`); field.onInput(`payto://iban/${v}?receiver-name=${name}`);
} }
}} }}
/> />
{value !== undefined && errors?.value && ( {number !== undefined && errors?.number && (
<ErrorMessage title={<span>{errors?.value}</span>} /> <ErrorMessage title={<span>{errors?.number}</span>} />
)}
<TextField
label="Account name"
variant="standard"
fullWidth
value={name}
error={name !== undefined && !!errors?.name}
onChange={(v) => {
setName(v);
if (!errors) {
field.onInput(`payto://iban/${number}?receiver-name=${v}`);
}
}}
/>
{name !== undefined && errors?.name && (
<ErrorMessage title={<span>{errors?.name}</span>} />
)} )}
</Fragment> </Fragment>
); );