forked from egovernments/DIGIT-OSS
/
Sample.js
112 lines (103 loc) · 3.14 KB
/
Sample.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { Loader,FormComposer } from "@egovernments/digit-ui-react-components";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";
export const newConfig = [
{
head: "Config Header",
subHead: "Config Sub Head",
body: [
{
inline:true,
label: "Enter Sample text 1",
isMandatory: false,
key: "BrSelectFather",
type: "text",
disable: false,
populators: { name: "sampletext1", error: "Required", validation: { pattern: /^[A-Za-z]+$/i } },
}, {
inline:true,
label: "Enter Sample text 333",
isMandatory: true,
key: "BrSelectFather",
type: "text",
disable: false,
populators: { name: "sampletext333", error: "Required", validation: { pattern: /^[A-Za-z]+$/i } },
},
{ inline:true,
label: "Enter Sample text 2",
isMandatory: false,
description: "Field supporting description",
key: "BrSelectFather",
type: "text",
disable: false,
populators: { name: "sampletext2", error: "Required", validation: { pattern: /^[A-Za-z]+$/i } },
},
{
label: "Enter Sample phone number",
isMandatory: true,
key: "BrSelectFather",
type: "number",
disable: false,
populators: { name: "samplenum1", error: "sample error message", validation: { min: 5999999999, max: 9999999999 } },
},
{
label: "Enter Sample phone number 2",
isMandatory: true,
key: "BrSelectFather",
type: "mobileNumber",
disable: false,
populators: { name: "samplenum2", error: "sample error message", validation: { min: 5999999999, max: 9999999999 } },
},
],
},
{
head: "Config Header 2",
body: [
{
label: "Enter text 2",
isMandatory: true,
description: "Field supporting description",
key: "BrSelectFather",
type: "text",
disable: false,
populators: { name: "sampletext3", error: "sample error message", validation: { pattern: /^[A-Za-z]+$/i } },
},
{
component: "BRSelectGender",
withoutLabel: true,
key: "BRSelectGender",
type: "component",
populators: { name: "genders",}
},
],
},
];
const Create = () => {
const tenantId = Digit.ULBService.getCurrentTenantId();
const { t } = useTranslation();
const history = useHistory();
const onSubmit = (data) => {
console.log(data, "data");
};
/* use newConfig instead of commonFields for local development in case needed */
const configs = newConfig ? newConfig : newConfig;
return (
<FormComposer
heading={t("Config Application Heading")}
label={t("Submit Bar")}
description={"Sample Description"}
text={"Sample Text"}
config={configs.map((config) => {
return {
...config,
body: config.body.filter((a) => !a.hideInEmployee),
};
})}
defaultValues={{}}
onSubmit={onSubmit}
fieldStyle={{ marginRight: 0 }}
/>
);
};
export default Create;