diff options
Diffstat (limited to 'packages/exchange-backoffice-ui/src/forms/simplest.ts')
-rw-r--r-- | packages/exchange-backoffice-ui/src/forms/simplest.ts | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/packages/exchange-backoffice-ui/src/forms/simplest.ts b/packages/exchange-backoffice-ui/src/forms/simplest.ts new file mode 100644 index 000000000..a395410c3 --- /dev/null +++ b/packages/exchange-backoffice-ui/src/forms/simplest.ts @@ -0,0 +1,96 @@ +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/AccountDetails.js"; +import { State } from "../pages/AntiMoneyLaunderingForm.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, + }, + }, + ], + }, + { + 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, + }, + }, + ], + }, + ], + behavior: function formBehavior( + v: Partial<Simplest.Form>, + ): FormState<Simplest.Form> { + return { + when: { + disabled: true, + }, + threshold: { + disabled: v.state === AmlState.frozen, + }, + }; + }, +}); + +namespace Simplest { + export interface Form { + when: AbsoluteTime; + threshold: AmountJson; + state: AmlState; + comment: string; + } +} |