aboutsummaryrefslogtreecommitdiff
path: root/packages/exchange-backoffice-ui/src/handlers/forms.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-05-25 18:08:20 -0300
committerSebastian <sebasjm@gmail.com>2023-05-26 09:26:09 -0300
commit64e3705669e7c12b8013704654f17cf8eaf659d4 (patch)
treeb0572d228b34740f307da4c59e6e5fa0e3e1f808 /packages/exchange-backoffice-ui/src/handlers/forms.ts
parentdad7d48ed2d7cd6f17466889395b49023e4b5097 (diff)
downloadwallet-core-64e3705669e7c12b8013704654f17cf8eaf659d4.tar.xz
cases, account details and new-form screen
Diffstat (limited to 'packages/exchange-backoffice-ui/src/handlers/forms.ts')
-rw-r--r--packages/exchange-backoffice-ui/src/handlers/forms.ts32
1 files changed, 26 insertions, 6 deletions
diff --git a/packages/exchange-backoffice-ui/src/handlers/forms.ts b/packages/exchange-backoffice-ui/src/handlers/forms.ts
index 115127cc3..4eb188a09 100644
--- a/packages/exchange-backoffice-ui/src/handlers/forms.ts
+++ b/packages/exchange-backoffice-ui/src/handlers/forms.ts
@@ -13,8 +13,10 @@ import { Group } from "./Group.js";
import { InputSelectOne } from "./InputSelectOne.js";
import { FormProvider } from "./FormProvider.js";
import { InputLine } from "./InputLine.js";
+import { InputAmount } from "./InputAmount.js";
+import { InputChoiceHorizontal } from "./InputChoiceHorizontal.js";
-export type DoubleColumnForm = DoubleColumnFormSection[];
+export type DoubleColumnForm = Array<DoubleColumnFormSection | undefined>;
type DoubleColumnFormSection = {
title: TranslatedString;
@@ -35,8 +37,10 @@ type FieldType<T extends object = any, K extends keyof T = any> = {
text: Parameters<typeof InputText<T, K>>[0];
textArea: Parameters<typeof InputTextArea<T, K>>[0];
choiceStacked: Parameters<typeof InputChoiceStacked<T, K>>[0];
+ choiceHorizontal: Parameters<typeof InputChoiceHorizontal<T, K>>[0];
date: Parameters<typeof InputDate<T, K>>[0];
integer: Parameters<typeof InputInteger<T, K>>[0];
+ amount: Parameters<typeof InputAmount<T, K>>[0];
};
/**
@@ -47,11 +51,13 @@ export type UIFormField =
| { type: "caption"; props: FieldType["caption"] }
| { type: "array"; props: FieldType["array"] }
| { type: "file"; props: FieldType["file"] }
+ | { type: "amount"; props: FieldType["amount"] }
| { type: "selectOne"; props: FieldType["selectOne"] }
| { type: "selectMultiple"; props: FieldType["selectMultiple"] }
| { type: "text"; props: FieldType["text"] }
| { type: "textArea"; props: FieldType["textArea"] }
| { type: "choiceStacked"; props: FieldType["choiceStacked"] }
+ | { type: "choiceHorizontal"; props: FieldType["choiceHorizontal"] }
| { type: "integer"; props: FieldType["integer"] }
| { type: "date"; props: FieldType["date"] };
@@ -79,11 +85,15 @@ const UIFormConfiguration: UIFormFieldMap = {
date: InputDate,
//@ts-ignore
choiceStacked: InputChoiceStacked,
+ //@ts-ignore
+ choiceHorizontal: InputChoiceHorizontal,
integer: InputInteger,
//@ts-ignore
selectOne: InputSelectOne,
//@ts-ignore
selectMultiple: InputSelectMultiple,
+ //@ts-ignore
+ amount: InputAmount,
};
export function RenderAllFieldsByUiConfig({
@@ -103,13 +113,23 @@ export function RenderAllFieldsByUiConfig({
);
}
-type FormSet<T extends object, K extends keyof T = any> = {
+type FormSet<T extends object> = {
Provider: typeof FormProvider<T>;
- InputLine: typeof InputLine<T, K>;
+ InputLine: <K extends keyof T>() => typeof InputLine<T, K>;
+ InputChoiceHorizontal: <K extends keyof T>() => typeof InputChoiceHorizontal<
+ T,
+ K
+ >;
};
-export function createNewForm<T extends object>(): FormSet<T> {
- return {
+export function createNewForm<T extends object>() {
+ const res: FormSet<T> = {
Provider: FormProvider,
- InputLine: InputLine,
+ InputLine: () => InputLine,
+ InputChoiceHorizontal: () => InputChoiceHorizontal,
+ };
+ return {
+ Provider: res.Provider,
+ InputLine: res.InputLine(),
+ InputChoiceHorizontal: res.InputChoiceHorizontal(),
};
}