commit 08ca91e3ad44547b6a731efb0a1642f83058fc56
parent dfcb1700f50a72a38a1164a204737b1178f5e6cd
Author: Florian Dold <florian@dold.me>
Date: Sat, 22 Mar 2025 21:31:04 +0100
forms: cleanup, put form definition next to form design
Diffstat:
12 files changed, 32 insertions(+), 199 deletions(-)
diff --git a/packages/aml-backoffice-ui/src/forms/index.ts b/packages/aml-backoffice-ui/src/forms/index.ts
@@ -14,9 +14,9 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
import {
+ form_vqf_902_1_customer,
VQF_902_11,
VQF_902_14,
- VQF_902_1_customer,
VQF_902_1_officer,
VQF_902_4,
VQF_902_5,
@@ -26,117 +26,6 @@ import {
} from "@gnu-taler/web-util/browser";
import { v1 as simplest } from "./simplest.js";
-const languages = (i18n: InternationalizationAPI) => [
- {
- label: i18n.str`Mandarin Chinese`,
- value: "cmn",
- },
- {
- label: i18n.str`Spanish`,
- value: "spa",
- },
- {
- label: i18n.str`English`,
- value: "eng",
- },
- {
- label: i18n.str`Hindi`,
- value: "hin",
- },
- {
- label: i18n.str`Portuguese`,
- value: "por",
- },
- {
- label: i18n.str`Bengali`,
- value: "ben",
- },
- {
- label: i18n.str`Russian`,
- value: "rus",
- },
- {
- label: i18n.str`Japanese`,
- value: "jpn",
- },
- {
- label: i18n.str`Yue`,
- value: "yue",
- },
- {
- label: i18n.str`Vietnamese`,
- value: "vie",
- },
- {
- label: i18n.str`Turkish`,
- value: "tur",
- },
- {
- label: i18n.str`Wu`,
- value: "wuu",
- },
- {
- label: i18n.str`Marathi`,
- value: "mar",
- },
- {
- label: i18n.str`Telugu`,
- value: "ten",
- },
- {
- label: i18n.str`Korean`,
- value: "kor",
- },
- {
- label: i18n.str`French`,
- value: "fra",
- },
- {
- label: i18n.str`Tamil`,
- value: "tam",
- },
- {
- label: i18n.str`Egyptian Arabic`,
- value: "arz",
- },
- {
- label: i18n.str`Standard German`,
- value: "deu",
- },
- {
- label: i18n.str`Urdu`,
- value: "urd",
- },
- {
- label: i18n.str`Javanese`,
- value: "jav",
- },
- {
- label: i18n.str`Punjabi`,
- value: "pan",
- },
- {
- label: i18n.str`Italian`,
- value: "ita",
- },
- {
- label: i18n.str`Gujarati`,
- value: "guj",
- },
- {
- label: i18n.str`Iranian Persian`,
- value: "pes",
- },
- {
- label: i18n.str`Bhojpuri`,
- value: "bho",
- },
- {
- label: i18n.str`Hausa`,
- value: "hau",
- },
-];
-
export const preloadedForms: (
i18n: InternationalizationAPI,
) => Array<FormMetadata> = (i18n) => [
@@ -146,13 +35,7 @@ export const preloadedForms: (
version: 1,
config: simplest(i18n),
},
- {
- label: i18n.str`Identification Form (customer)`,
- description: i18n.str`The customer has to be identified on entering into a permanent business relationship or on concluding a cash transaction, which meets the according threshold.`,
- id: "vqf_902_1_customer",
- version: 1,
- config: VQF_902_1_customer(i18n),
- },
+ form_vqf_902_1_customer(i18n),
{
label: i18n.str`Identification Form (acceptance)`,
description: i18n.str`The customer has to be identified on entering into a permanent business relationship or on concluding a cash transaction, which meets the according threshold.`,
@@ -194,30 +77,3 @@ export const preloadedForms: (
config: VQF_902_14(i18n),
},
];
-
-const currencies = (i18n: InternationalizationAPI) => [
- {
- label: i18n.str`United States dollar`,
- value: "usd",
- },
- {
- label: i18n.str`Euro`,
- value: "eur",
- },
- {
- label: i18n.str`Swiss franc`,
- value: "chf",
- },
- {
- label: i18n.str`Argentine peso`,
- value: "ars",
- },
- {
- label: i18n.str`Mexican peso`,
- value: "mxn",
- },
- {
- label: i18n.str`Brazilian real`,
- value: "brl",
- },
-];
diff --git a/packages/aml-backoffice-ui/src/pages/Cases.tsx b/packages/aml-backoffice-ui/src/pages/Cases.tsx
@@ -388,6 +388,7 @@ function JumpByIdForm({
name="inv"
label={i18n.str`Only investigated`}
handler={{
+ name: "inv",
onChange: onTog,
value: fitered,
computedProperties: {},
diff --git a/packages/aml-backoffice-ui/src/pages/decision/Information.tsx b/packages/aml-backoffice-ui/src/pages/decision/Information.tsx
@@ -73,6 +73,7 @@ function FillCustomerData({
onChange: setExpiration,
value: expiration,
computedProperties: {},
+ name: "expiration",
};
/**
diff --git a/packages/kyc-ui/src/forms/index.ts b/packages/kyc-ui/src/forms/index.ts
@@ -15,12 +15,12 @@
*/
import {
+ form_vqf_902_1_customer,
FormMetadata,
GLS_Onboarding,
InternationalizationAPI,
VQF_902_11,
VQF_902_14,
- VQF_902_1_customer,
VQF_902_4,
VQF_902_5,
VQF_902_9,
@@ -59,13 +59,7 @@ export const preloadedForms: (
version: 1,
config: GLS_Onboarding(i18n),
},
- {
- label: i18n.str`Identification Form`,
- description: i18n.str`The customer has to be identified on entering into a permanent business relationship or on concluding a cash transaction, which meets the according threshold.`,
- id: "vqf-902-1",
- version: 1,
- config: VQF_902_1_customer(i18n),
- },
+ form_vqf_902_1_customer(i18n),
{
label: i18n.str`Risk Profile AMLA`,
id: "vqf_902_4",
diff --git a/packages/web-util/src/forms/forms-types.ts b/packages/web-util/src/forms/forms-types.ts
@@ -22,16 +22,15 @@ export type FormDesign<T = unknown> =
| SingleColumnFormDesign;
/**
- * form with composed by multiple sections
+ * Form with multiple sections.
*/
export type DoubleColumnFormDesign = {
type: "double-column";
sections: DoubleColumnFormSection[];
- // behavior?: (form: Partial<T>) => FormState<T>;
};
/**
- * single section form
+ * Single section form.
*/
export type SingleColumnFormDesign = {
type: "single-column";
diff --git a/packages/web-util/src/forms/gana/VQF_902_1_customer.stories.tsx b/packages/web-util/src/forms/gana/VQF_902_1_customer.stories.tsx
@@ -21,17 +21,16 @@
import { i18n, setupI18n } from "@gnu-taler/taler-util";
import * as tests from "../../tests/hook.js";
-import { DefaultForm as TestedComponent } from "../forms-ui.js";
-import { VQF_902_1_customer } from "./VQF_902_1_customer.js";
-export default {
- title: "vqf_902_1_customer",
-};
+import { DefaultForm } from "../forms-ui.js";
+import { design_VQF_902_1_customer } from "./VQF_902_1_customer.js";
setupI18n("en", {});
type TargetObject = {};
const initial: TargetObject = {};
-export const EmptyForm = tests.createExample(TestedComponent, {
+export const EmptyForm = tests.createExample(DefaultForm, {
initial,
- design: VQF_902_1_customer(i18n),
+ design: design_VQF_902_1_customer(i18n),
});
+
+export const title = "vqf_902_1_customer";
diff --git a/packages/web-util/src/forms/gana/VQF_902_1_customer.ts b/packages/web-util/src/forms/gana/VQF_902_1_customer.ts
@@ -28,10 +28,18 @@ const Descr = {
member act as director of a domiciliary company, this domiciliary company is the customer.`,
} as const;
+export const form_vqf_902_1_customer = (i18n: InternationalizationAPI) => ({
+ label: i18n.str`Identification Form (customer)`,
+ description: i18n.str`The customer has to be identified on entering into a permanent business relationship or on concluding a cash transaction, which meets the according threshold.`,
+ id: "vqf_902_1_customer",
+ version: 1,
+ config: design_VQF_902_1_customer(i18n),
+});
+
/**
* Form vqf_902_1_customer.
*/
-export function VQF_902_1_customer(
+export function design_VQF_902_1_customer(
i18n: InternationalizationAPI,
): DoubleColumnFormDesign {
return {
@@ -42,7 +50,7 @@ export function VQF_902_1_customer(
description: Descr.CUSTOMER_INFO_TYPE(i18n),
fields: [
{
- id: TalerFormAttributes.CUSTOMER_INFO_TYPE,
+ id: TalerFormAttributes.CUSTOMER_TYPE,
label: i18n.str`Customer type`,
type: "choiceStacked",
choices: [
@@ -125,7 +133,7 @@ export function VQF_902_1_customer(
description: i18n.str`The customer is a sole proprietor`,
hide(root) {
return (
- root[TalerFormAttributes.CUSTOMER_INFO_TYPE] !== "NATURAL_PERSON" ||
+ root[TalerFormAttributes.CUSTOMER_TYPE] !== "NATURAL_PERSON" ||
!root[TalerFormAttributes.CUSTOMER_IS_SOLE_PROPRIETOR]
);
},
@@ -155,9 +163,7 @@ export function VQF_902_1_customer(
title: i18n.str`Information on customer`,
description: i18n.str`The customer is a legal entity`,
hide(root) {
- return (
- root[TalerFormAttributes.CUSTOMER_INFO_TYPE] !== "LEGAL_ENTITY"
- );
+ return root[TalerFormAttributes.CUSTOMER_TYPE] !== "LEGAL_ENTITY";
},
fields: [
{
diff --git a/packages/web-util/src/forms/gana/VQF_902_1_officer.stories.tsx b/packages/web-util/src/forms/gana/VQF_902_1_officer.stories.tsx
@@ -23,8 +23,9 @@ import { i18n, setupI18n } from "@gnu-taler/taler-util";
import * as tests from "../../tests/hook.js";
import { DefaultForm as TestedComponent } from "../forms-ui.js";
import { VQF_902_1_officer } from "./VQF_902_1_officer.js";
+
export default {
- title: "VQF_902_1e Officer fields (after customer)",
+ title: "vqf_902_1_officer",
};
setupI18n("en", {});
diff --git a/packages/web-util/src/forms/gana/taler_form_attributes.ts b/packages/web-util/src/forms/gana/taler_form_attributes.ts
@@ -62,7 +62,7 @@ export const TalerFormAttributes = {
*
* GANA Type: 'NATURAL_PERSON' | 'LEGAL_ENTITY'
*/
- CUSTOMER_INFO_TYPE: "CUSTOMER_INFO_TYPE" as UIHandlerId,
+ CUSTOMER_TYPE: "CUSTOMER_TYPE" as UIHandlerId,
/**
* Description:
*
diff --git a/packages/web-util/src/stories-utils.tsx b/packages/web-util/src/stories-utils.tsx
@@ -559,25 +559,3 @@ export function renderStories(
}
}
}
-
-function ResizeHandle({ onUpdate }: { onUpdate: (x: number) => void }): VNode {
- const [start, setStart] = useState<number | undefined>(undefined);
- return (
- <ResizeHandleDiv
- onMouseDown={(e: any) => {
- setStart(e.pageX);
- return false;
- }}
- onMouseMove={(e: any) => {
- if (start !== undefined) {
- onUpdate(e.pageX - start);
- }
- return false;
- }}
- onMouseUp={() => {
- setStart(undefined);
- return false;
- }}
- />
- );
-}
diff --git a/packages/web-util/src/stories.tsx b/packages/web-util/src/stories.tsx
@@ -18,13 +18,13 @@
*
* @author Sebastian Javier Marchano (sebasjm)
*/
-// import { strings } from "./i18n/strings.js";
+/**
+ * Imports.
+ */
import * as forms from "./forms/index.stories.js";
import { renderStories } from "./stories-utils.js";
-const TALER_SCREEN_ID = 101;
-
function main(): void {
renderStories(
{ forms },
diff --git a/packages/web-util/src/tests/hook.ts b/packages/web-util/src/tests/hook.ts
@@ -39,11 +39,9 @@ export type ExampleItemSetup<Props extends object = {}> = {
};
/**
- *
* @param Component component to be tested
* @param props allow partial props for easier example setup
* @param contextProps if the context requires params for this example
- * @returns
*/
export function createExample<T extends object, Props extends object>(
Component: FunctionalComponent<Props>,