aboutsummaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/pages/admin/AccountForm.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/demobank-ui/src/pages/admin/AccountForm.tsx')
-rw-r--r--packages/demobank-ui/src/pages/admin/AccountForm.tsx20
1 files changed, 18 insertions, 2 deletions
diff --git a/packages/demobank-ui/src/pages/admin/AccountForm.tsx b/packages/demobank-ui/src/pages/admin/AccountForm.tsx
index 7311d826e..4fcc32484 100644
--- a/packages/demobank-ui/src/pages/admin/AccountForm.tsx
+++ b/packages/demobank-ui/src/pages/admin/AccountForm.tsx
@@ -3,7 +3,7 @@ import { ShowInputErrorLabel } from "@gnu-taler/web-util/browser";
import { PartialButDefined, RecursivePartial, WithIntermediate, undefinedIfEmpty, validateIBAN } from "../../utils.js";
import { useEffect, useRef, useState } from "preact/hooks";
import { useTranslationContext } from "@gnu-taler/web-util/browser";
-import { PaytoString, TalerCorebankApi, buildPayto, parsePaytoUri } from "@gnu-taler/taler-util";
+import { PaytoString, TalerCorebankApi, buildPayto, parsePaytoUri, stringifyPaytoUri } from "@gnu-taler/taler-util";
import { doAutoFocus } from "../PaytoWireTransferForm.js";
import { CopyButton } from "@gnu-taler/web-util/browser";
import { assertUnreachable } from "../WithdrawalOperationPage.js";
@@ -80,7 +80,16 @@ export function AccountForm({
});
setErrors(errors);
setForm(newForm);
- onChange(errors === undefined ? (newForm as any) : undefined);
+ if (errors) {
+ onChange(undefined)
+ } else {
+ const cashout = buildPayto("iban", newForm.cashout_payto_uri!, undefined)
+ const account: AccountFormData = {
+ ...newForm as any,
+ cashout_payto_uri: stringifyPaytoUri(cashout)
+ }
+ onChange(account);
+ }
}
return (
@@ -296,6 +305,13 @@ function initializeFromTemplate(
if (typeof initial.contact_data === "undefined") {
initial.contact_data = emptyContact;
}
+ if (initial.cashout_payto_uri) {
+ const ac = parsePaytoUri(initial.cashout_payto_uri)
+ if (ac?.isKnown && ac.targetType === "iban") {
+ // we are using the cashout field for the iban number
+ initial.cashout_payto_uri = ac.targetPath as any
+ }
+ }
const result: WithIntermediate<AccountFormData> = initial as any // FIXME: check types
result.username = username