aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-11-14 18:58:26 -0300
committerSebastian <sebasjm@gmail.com>2024-11-14 19:01:45 -0300
commit548b1d1deb54080ceba911b1b6d6b6ea12fd6276 (patch)
tree6c4be99d4f4e9b20d2ef72a38c1de63a2f2ae0b0
parent388ca54e3f72472368e41833298ac75aa948f2c7 (diff)
use the officer defined form in the kyc ui
-rw-r--r--packages/aml-backoffice-ui/src/Routing.tsx14
-rw-r--r--packages/aml-backoffice-ui/src/pages/CaseDetails.tsx57
-rw-r--r--packages/kyc-ui/src/pages/FillForm.tsx30
3 files changed, 74 insertions, 27 deletions
diff --git a/packages/aml-backoffice-ui/src/Routing.tsx b/packages/aml-backoffice-ui/src/Routing.tsx
index d69b47184..21b0c9929 100644
--- a/packages/aml-backoffice-ui/src/Routing.tsx
+++ b/packages/aml-backoffice-ui/src/Routing.tsx
@@ -23,7 +23,11 @@ import {
} from "@gnu-taler/web-util/browser";
import { Fragment, VNode, h } from "preact";
-import { assertUnreachable, parsePaytoUri, PaytoString } from "@gnu-taler/taler-util";
+import {
+ assertUnreachable,
+ parsePaytoUri,
+ PaytoString,
+} from "@gnu-taler/taler-util";
import { useEffect } from "preact/hooks";
import { ExchangeAmlFrame } from "./ExchangeAmlFrame.js";
import { useOfficer } from "./hooks/officer.js";
@@ -108,7 +112,7 @@ export const privatePages = {
/\/case\/(?<cid>[a-zA-Z0-9]+)\/new/,
({ cid }) => `#/case/${cid}/new`,
),
- caseDetailsNewAccount: urlPattern<{ cid: string, payto: string }>(
+ caseDetailsNewAccount: urlPattern<{ cid: string; payto: string }>(
/\/case\/(?<cid>[a-zA-Z0-9]+)\/(?<payto>[a-zA-Z0-9]+)/,
({ cid, payto }) => `#/case/${cid}/${payto}`,
),
@@ -143,9 +147,11 @@ function PrivateRouting(): VNode {
return <CaseDetails account={location.values.cid} />;
}
case "caseDetailsNewAccount": {
- console.log(location.values)
return (
- <CaseDetails account={location.values.cid} paytoString={decodeCrockFromURI(location.values.payto)} />
+ <CaseDetails
+ account={location.values.cid}
+ paytoString={decodeCrockFromURI(location.values.payto)}
+ />
);
}
case "caseNew": {
diff --git a/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx b/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx
index 2d433c2ba..d15b088a1 100644
--- a/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx
+++ b/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx
@@ -40,6 +40,7 @@ import {
Button,
convertUiField,
DefaultForm,
+ FormConfiguration,
FormMetadata,
getConverterById,
InternationalizationAPI,
@@ -375,18 +376,8 @@ export function CaseDetails({
// the custom meaure with context
new_measures: "askMoreInfo",
new_rules: {
- custom_measures: {
- ask_more_info: {
- context: {
- // this value is going to be overriden
- form: {},
- },
- // check of type form, it will use the officer defined form
- check_name: "askContext",
- // after that, mark as investigate to read what the user sent
- prog_name: "markInvestigate",
- },
- },
+ // this value is going to be overriden
+ custom_measures: {},
expiration_time: AbsoluteTime.toProtocolTimestamp(
AbsoluteTime.never(),
),
@@ -530,7 +521,7 @@ function SubmitNewDecision({
help: i18n.str`Type of information being asked`,
choices: [
{
- value: "number",
+ value: "integer",
label: i18n.str`Number`,
description: i18n.str`Numeric information`,
},
@@ -560,8 +551,31 @@ function SubmitNewDecision({
},
);
+ const customFields = decisionForm.status.result.fields as [
+ { name: string; type: string },
+ ];
+
+ const customForm: FormConfiguration | undefined = !decisionForm.status.result
+ .fields
+ ? undefined
+ : {
+ type: "double-column",
+ design: [
+ {
+ fields: customFields.map((f) => {
+ return {
+ id: f.name,
+ label: f.name,
+ type: f.type,
+ } as UIFormElementConfig;
+ }),
+ title: "Required information",
+ },
+ ],
+ };
+
const submitHandler =
- decisionForm === undefined || !session
+ decisionForm === undefined || !session || customForm === undefined
? undefined
: withErrorHandler(
() => {
@@ -573,6 +587,21 @@ function SubmitNewDecision({
},
justification:
decisionForm.status.result.justification ?? "empty",
+ new_rules: {
+ ...decision.request.new_rules,
+ custom_measures: {
+ ...decision.request.new_rules.custom_measures,
+ askMoreInfo: {
+ context: {
+ form: customForm,
+ },
+ // check of type form, it will use the officer defined form
+ check_name: "askContext",
+ // after that, mark as investigate to read what the user sent
+ prog_name: "markInvestigate",
+ },
+ },
+ },
};
return lib.exchange.makeAmlDesicion(session, request);
},
diff --git a/packages/kyc-ui/src/pages/FillForm.tsx b/packages/kyc-ui/src/pages/FillForm.tsx
index 157ca3406..459186240 100644
--- a/packages/kyc-ui/src/pages/FillForm.tsx
+++ b/packages/kyc-ui/src/pages/FillForm.tsx
@@ -77,7 +77,17 @@ export function FillForm({
// const { forms } = useUiFormsContext();
const [notification, withErrorHandler] = useLocalNotificationHandler();
- const theForm = searchForm(i18n, [], formId);
+ const customForm =
+ requirement.context && "form" in requirement.context
+ ? ({
+ id: "by-context",
+ config: requirement.context.form,
+ label: "Officer defined form",
+ version: 1,
+ } as FormMetadata)
+ : undefined;
+
+ const theForm = searchForm(i18n, customForm ? [customForm] : [], formId);
if (!theForm) {
return <div>form with id {formId} not found</div>;
}
@@ -135,14 +145,16 @@ export function FillForm({
// const data = new FormData()
// data.set("header", JSON.stringify(information.header))
// data.set("payload", JSON.stringify(information.payload))
- const data = new URLSearchParams()
- Object.entries(validatedForm as Record<string,string>).forEach(([key, value]) => {
- if (key === "money") {
- data.set(key,Amounts.stringify(value))
- } else {
- data.set(key,(value))
- }
- })
+ const data = new URLSearchParams();
+ Object.entries(validatedForm as Record<string, string>).forEach(
+ ([key, value]) => {
+ if (key === "money") {
+ data.set(key, Amounts.stringify(value));
+ } else {
+ data.set(key, value);
+ }
+ },
+ );
return lib.exchange.uploadKycForm(reqId, data);
},
(res) => {