aboutsummaryrefslogtreecommitdiff
path: root/packages/aml-backoffice-ui/src/pages/AntiMoneyLaunderingForm.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-04-23 11:31:56 -0300
committerSebastian <sebasjm@gmail.com>2024-04-23 11:31:56 -0300
commitcd590b18e856a128af3c31d9e7d4a621ea44024c (patch)
treeb20e8f4a446f4edddf364755032389d267beedb6 /packages/aml-backoffice-ui/src/pages/AntiMoneyLaunderingForm.tsx
parent2b8ae6381776b0d6fc9cc8c0b8275fbdc6d3295b (diff)
downloadwallet-core-cd590b18e856a128af3c31d9e7d4a621ea44024c.tar.xz
tidy up: some header missing
Diffstat (limited to 'packages/aml-backoffice-ui/src/pages/AntiMoneyLaunderingForm.tsx')
-rw-r--r--packages/aml-backoffice-ui/src/pages/AntiMoneyLaunderingForm.tsx47
1 files changed, 33 insertions, 14 deletions
diff --git a/packages/aml-backoffice-ui/src/pages/AntiMoneyLaunderingForm.tsx b/packages/aml-backoffice-ui/src/pages/AntiMoneyLaunderingForm.tsx
index c42b1e7af..77d4b8167 100644
--- a/packages/aml-backoffice-ui/src/pages/AntiMoneyLaunderingForm.tsx
+++ b/packages/aml-backoffice-ui/src/pages/AntiMoneyLaunderingForm.tsx
@@ -1,3 +1,18 @@
+/*
+ This file is part of GNU Taler
+ (C) 2022 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
import {
AbsoluteTime,
AmountJson,
@@ -5,11 +20,11 @@ import {
Codec,
OperationFail,
OperationOk,
- OperationResult,
+ TalerErrorDetail,
buildCodecForObject,
codecForNumber,
codecForString,
- codecOptional,
+ codecOptional
} from "@gnu-taler/taler-util";
import {
DefaultForm,
@@ -17,7 +32,7 @@ import {
} from "@gnu-taler/web-util/browser";
import { h } from "preact";
import { useExchangeApiContext } from "../context/config.js";
-import { FormMetadata, uiForms } from "../forms/declaration.js";
+import { BaseForm, FormMetadata, uiForms } from "../forms/declaration.js";
import { Pages } from "../pages.js";
import { AmlExchangeBackend } from "../utils/types.js";
@@ -51,10 +66,12 @@ export function AntiMoneyLaunderingForm({
<DefaultForm
initial={initial}
form={theForm.impl(initial)}
- onUpdate={() => { }}
+ onUpdate={() => {}}
onSubmit={(formValue) => {
- if (formValue.state === undefined || formValue.threshold === undefined)
+ if (formValue.state === undefined || formValue.threshold === undefined) {
return;
+ }
+ const validatedForm = formValue as BaseForm;
const st = formValue.state;
const amount = formValue.threshold;
@@ -62,7 +79,7 @@ export function AntiMoneyLaunderingForm({
id: theForm.id,
label: theForm.label,
version: theForm.version,
- value: formValue,
+ value: validatedForm,
};
onSubmit(justification, st, amount);
@@ -86,10 +103,10 @@ export function AntiMoneyLaunderingForm({
);
}
-export type Justification<T = any> = {
+export type Justification<T extends BaseForm = BaseForm> = {
// form values
value: T;
-} & Omit<Omit<FormMetadata<any>, "icon">, "impl">;
+} & Omit<Omit<FormMetadata<BaseForm>, "icon">, "impl">;
export function stringifyJustification(j: Justification): string {
return JSON.stringify(j);
@@ -114,8 +131,10 @@ type ParseJustificationFail =
export function parseJustification(
s: string,
- listOfAllKnownForms: FormMetadata<any>[],
-): OperationOk<{ justification: Justification; metadata: FormMetadata<any> }> | OperationFail<ParseJustificationFail> {
+ listOfAllKnownForms: FormMetadata<BaseForm>[],
+):
+ | OperationOk<{ justification: Justification; metadata: FormMetadata<BaseForm> }>
+ | OperationFail<ParseJustificationFail> {
try {
const justification = JSON.parse(s);
const info = codecForSimpleFormMetadata().decode(justification);
@@ -123,14 +142,14 @@ export function parseJustification(
return {
type: "fail",
case: "id-not-found",
- detail: {} as any,
+ detail: {} as TalerErrorDetail,
};
}
if (!info.version) {
return {
type: "fail",
case: "version-not-found",
- detail: {} as any,
+ detail: {} as TalerErrorDetail,
};
}
const found = listOfAllKnownForms.find((f) => {
@@ -140,7 +159,7 @@ export function parseJustification(
return {
type: "fail",
case: "form-not-found",
- detail: {} as any,
+ detail: {} as TalerErrorDetail,
};
}
return {
@@ -154,7 +173,7 @@ export function parseJustification(
return {
type: "fail",
case: "not-json",
- detail: {} as any,
+ detail: {} as TalerErrorDetail,
};
}
}