2023-05-25 23:08:20 +02:00
|
|
|
import {
|
|
|
|
AbsoluteTime,
|
|
|
|
AmountJson,
|
|
|
|
Amounts,
|
|
|
|
TranslatedString,
|
|
|
|
} from "@gnu-taler/taler-util";
|
|
|
|
import { FormState } from "../handlers/FormProvider.js";
|
|
|
|
import { FlexibleForm } from "./index.js";
|
|
|
|
import { AmlState } from "../types.js";
|
2023-05-26 21:52:30 +02:00
|
|
|
import { amlStateConverter } from "../pages/CaseDetails.js";
|
2023-05-25 23:08:20 +02:00
|
|
|
import { State } from "../pages/AntiMoneyLaunderingForm.js";
|
2023-05-25 23:23:38 +02:00
|
|
|
import { DoubleColumnFormSection, UIFormField } from "../handlers/forms.js";
|
2023-05-25 23:08:20 +02:00
|
|
|
|
|
|
|
export const v1 = (current: State): FlexibleForm<Simplest.Form> => ({
|
|
|
|
versionId: "2023-05-25",
|
|
|
|
design: [
|
|
|
|
{
|
|
|
|
title: "Simple form" as TranslatedString,
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
type: "textArea",
|
|
|
|
props: {
|
|
|
|
name: "comment",
|
|
|
|
label: "Comments" as TranslatedString,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-05-25 23:23:38 +02:00
|
|
|
resolutionSection(current),
|
2023-05-25 23:08:20 +02:00
|
|
|
],
|
|
|
|
behavior: function formBehavior(
|
|
|
|
v: Partial<Simplest.Form>,
|
|
|
|
): FormState<Simplest.Form> {
|
|
|
|
return {
|
|
|
|
when: {
|
|
|
|
disabled: true,
|
|
|
|
},
|
|
|
|
threshold: {
|
|
|
|
disabled: v.state === AmlState.frozen,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-05-25 23:23:38 +02:00
|
|
|
export namespace Simplest {
|
|
|
|
export interface WithResolution {
|
2023-05-25 23:08:20 +02:00
|
|
|
when: AbsoluteTime;
|
|
|
|
threshold: AmountJson;
|
|
|
|
state: AmlState;
|
2023-05-25 23:23:38 +02:00
|
|
|
}
|
|
|
|
export interface Form extends WithResolution {
|
2023-05-25 23:08:20 +02:00
|
|
|
comment: string;
|
|
|
|
}
|
|
|
|
}
|
2023-05-25 23:23:38 +02:00
|
|
|
|
|
|
|
export function resolutionSection(current: State): DoubleColumnFormSection {
|
|
|
|
return {
|
|
|
|
title: "Resolution" as TranslatedString,
|
|
|
|
description: `Current state is ${amlStateConverter.toStringUI(
|
|
|
|
current.state,
|
|
|
|
)} and threshold at ${Amounts.stringifyValue(
|
|
|
|
current.threshold,
|
|
|
|
)}` as TranslatedString,
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
type: "date",
|
|
|
|
props: {
|
|
|
|
name: "when",
|
|
|
|
label: "Decision Time" as TranslatedString,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "choiceHorizontal",
|
|
|
|
props: {
|
|
|
|
name: "state",
|
|
|
|
label: "New state" as TranslatedString,
|
|
|
|
converter: amlStateConverter,
|
|
|
|
choices: [
|
|
|
|
{
|
|
|
|
value: AmlState.frozen,
|
|
|
|
label: "Frozen" as TranslatedString,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: AmlState.pending,
|
|
|
|
label: "Pending" as TranslatedString,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: AmlState.normal,
|
|
|
|
label: "Normal" as TranslatedString,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "amount",
|
|
|
|
props: {
|
|
|
|
name: "threshold",
|
|
|
|
label: "New threshold" as TranslatedString,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|