diff options
author | Sebastian <sebasjm@gmail.com> | 2023-06-05 10:04:09 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-06-05 10:04:09 -0300 |
commit | c680f5aa71b08e978444df07f93c381f9d47ab82 (patch) | |
tree | 81903fac003bb1e202cf69551e06ba41a6e960a5 /packages/aml-backoffice-ui/src/forms/simplest.ts | |
parent | df53866e6b148ea5fd2ab57e906a4aa36b535ed3 (diff) |
rename aml
Diffstat (limited to 'packages/aml-backoffice-ui/src/forms/simplest.ts')
-rw-r--r-- | packages/aml-backoffice-ui/src/forms/simplest.ts | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/packages/aml-backoffice-ui/src/forms/simplest.ts b/packages/aml-backoffice-ui/src/forms/simplest.ts new file mode 100644 index 000000000..7eda03fef --- /dev/null +++ b/packages/aml-backoffice-ui/src/forms/simplest.ts @@ -0,0 +1,103 @@ +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"; +import { amlStateConverter } from "../pages/CaseDetails.js"; +import { State } from "../pages/AntiMoneyLaunderingForm.js"; +import { DoubleColumnFormSection, UIFormField } from "../handlers/forms.js"; + +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, + }, + }, + ], + }, + resolutionSection(current), + ], + behavior: function formBehavior( + v: Partial<Simplest.Form>, + ): FormState<Simplest.Form> { + return { + when: { + disabled: true, + }, + threshold: { + disabled: v.state === AmlState.frozen, + }, + }; + }, +}); + +export namespace Simplest { + export interface WithResolution { + when: AbsoluteTime; + threshold: AmountJson; + state: AmlState; + } + export interface Form extends WithResolution { + comment: string; + } +} + +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, + }, + }, + ], + }; +} |