[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 01/05: default threshold
From: |
gnunet |
Subject: |
[taler-wallet-core] 01/05: default threshold |
Date: |
Wed, 06 Dec 2023 18:10:51 +0100 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository wallet-core.
commit cb9c115becb7fafb89f64d02f3555efddaeba03e
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Wed Dec 6 07:55:52 2023 -0300
default threshold
---
.../src/pages/account/ShowAccountDetails.tsx | 1 +
.../demobank-ui/src/pages/admin/AccountForm.tsx | 38 ++++++++++------------
2 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/packages/demobank-ui/src/pages/account/ShowAccountDetails.tsx
b/packages/demobank-ui/src/pages/account/ShowAccountDetails.tsx
index d435673a2..92419b7ed 100644
--- a/packages/demobank-ui/src/pages/account/ShowAccountDetails.tsx
+++ b/packages/demobank-ui/src/pages/account/ShowAccountDetails.tsx
@@ -135,6 +135,7 @@ export function ShowAccountDetails({
focus={update}
noCashout={credentials.status === "loggedIn" ?
credentials.isUserAdministrator : undefined}
username={account}
+ admin={credentials.status === "loggedIn" ?
credentials.isUserAdministrator : undefined}
template={result.body}
purpose={update ? "update" : "show"}
onChange={(a) => setSubmitAccount(a)}
diff --git a/packages/demobank-ui/src/pages/admin/AccountForm.tsx
b/packages/demobank-ui/src/pages/admin/AccountForm.tsx
index e76204a81..61702f7d4 100644
--- a/packages/demobank-ui/src/pages/admin/AccountForm.tsx
+++ b/packages/demobank-ui/src/pages/admin/AccountForm.tsx
@@ -1,12 +1,11 @@
-import { AmountString, Amounts, ChallengeContactData, PaytoString,
TalerCorebankApi, TranslatedString, buildPayto, parsePaytoUri,
stringifyPaytoUri } from "@gnu-taler/taler-util";
+import { AmountString, Amounts, PaytoString, TalerCorebankApi, buildPayto,
parsePaytoUri, stringifyPaytoUri } from "@gnu-taler/taler-util";
import { CopyButton, ShowInputErrorLabel, useTranslationContext } from
"@gnu-taler/web-util/browser";
import { ComponentChildren, Fragment, VNode, h } from "preact";
import { useState } from "preact/hooks";
-import { ErrorMessageMappingFor, PartialButDefined, RecursivePartial,
WithIntermediate, undefinedIfEmpty, validateIBAN } from "../../utils.js";
+import { useBankCoreApiContext } from "../../context/config.js";
+import { ErrorMessageMappingFor, PartialButDefined, WithIntermediate,
undefinedIfEmpty, validateIBAN } from "../../utils.js";
import { InputAmount, doAutoFocus } from "../PaytoWireTransferForm.js";
import { assertUnreachable } from "../WithdrawalOperationPage.js";
-import { useBackendContext } from "../../context/backend.js";
-import { useBankCoreApiContext } from "../../context/config.js";
import { getRandomPassword } from "../rnd.js";
const IBAN_REGEX = /^[A-Z][A-Z0-9]*$/;
@@ -16,7 +15,6 @@ const REGEX_JUST_NUMBERS_REGEX = /^\+[0-9 ]*$/;
export type AccountFormData = TalerCorebankApi.AccountData & {
username: string,
- debitAmount: string,
isExchange: boolean,
isPublic: boolean,
}
@@ -27,10 +25,11 @@ type ChangeByPurposeType = {
"show": undefined
}
/**
- * Create valid account object to update or create
- * Take template as initial values for the form
- * Purpose indicate if all field al read only (show), part of them (update)
- * or none (create)
+ * FIXME:
+ * is_public is missing on PATCH
+ * account email/password should require 2FA
+ *
+ *
* @param param0
* @returns
*/
@@ -53,21 +52,21 @@ export function AccountForm<PurposeType extends keyof
ChangeByPurposeType>({
onChange: ChangeByPurposeType[PurposeType];
purpose: PurposeType;
}): VNode {
- const initial = initializeFromTemplate(username, template);
+ const { config } = useBankCoreApiContext()
+
+ const initial = initializeFromTemplate(username, template,
config.default_debit_threshold);
const [form, setForm] = useState(initial);
const [errors, setErrors] = useState<
ErrorMessageMappingFor<typeof initial> | undefined
>(undefined);
const { i18n } = useTranslationContext();
- const { config } = useBankCoreApiContext()
-
function updateForm(newForm: typeof initial): void {
const parsed = !newForm.cashout_payto_uri
? undefined
: buildPayto("iban", newForm.cashout_payto_uri, undefined);;
- const trimmedAmountStr = newForm.debitAmount?.trim();
+ const trimmedAmountStr = newForm.debit_threshold?.trim();
const parsedAmount =
Amounts.parse(`${config.currency}:${trimmedAmountStr}`);
const errors = undefinedIfEmpty<ErrorMessageMappingFor<typeof initial>>({
@@ -98,8 +97,6 @@ export function AccountForm<PurposeType extends keyof
ChangeByPurposeType>({
? (purpose === "create" ? i18n.str`required` : undefined)
: !parsedAmount
? i18n.str`not valid`
- : Amounts.isZero(parsedAmount)
- ? i18n.str`should be greater than 0`
: undefined,
name: !newForm.name ? i18n.str`required` : undefined,
username: !newForm.username ? i18n.str`required` : undefined,
@@ -130,7 +127,7 @@ export function AccountForm<PurposeType extends keyof
ChangeByPurposeType>({
email: newForm.contact_data?.email,
phone: newForm.contact_data?.phone,
}),
- debit_threshold: newForm.debit_threshold as AmountString,
+ debit_threshold: `${config.currency}:${newForm.debit_threshold}`
as AmountString,
internal_payto_uri: internalURI,
is_public: newForm.isPublic,
is_taler_exchange: newForm.isExchange,
@@ -141,6 +138,7 @@ export function AccountForm<PurposeType extends keyof
ChangeByPurposeType>({
case "update": {
//typescript doesn't correctly narrow a generic type
const callback = onChange as ChangeByPurposeType["update"]
+
const result: TalerCorebankApi.AccountReconfiguration = {
cashout_payto_uri: cashoutURI,
challenge_contact_data: undefinedIfEmpty({
@@ -363,9 +361,9 @@ export function AccountForm<PurposeType extends keyof
ChangeByPurposeType>({
name="debit"
left
currency={config.currency}
- value={form.debitAmount ?? ""}
+ value={form.debit_threshold ?? ""}
onChange={(e) => {
- form.debitAmount = e
+ form.debit_threshold = e as AmountString
updateForm(structuredClone(form))
}}
/>
@@ -427,17 +425,17 @@ export function AccountForm<PurposeType extends keyof
ChangeByPurposeType>({
</form>
);
}
-// JNTMECG7RM3AAQB6SRAZNWDSM8
function initializeFromTemplate(
username: string | undefined,
account: TalerCorebankApi.AccountData | undefined,
+ default_debit_threshold: AmountString,
): WithIntermediate<AccountFormData> {
const emptyAccount = {
cashout_payto_uri: undefined,
contact_data: undefined,
payto_uri: undefined,
balance: undefined,
- debit_threshold: undefined,
+ debit_threshold: Amounts.stringifyValue(default_debit_threshold) as
AmountString,
name: undefined,
};
const emptyContact = {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.