@djb25/digit-ui-module-ekyc 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -0
- package/dist/index.modern.js +2965 -0
- package/dist/index.modern.js.map +1 -0
- package/package.json +1 -1
- package/src/Module.js +7 -23
- package/src/components/ConnectionDetailsView.js +130 -0
- package/src/components/DesktopInbox.js +84 -84
- package/src/components/Filter.js +59 -0
- package/src/components/MobileInbox.js +73 -0
- package/src/components/SearchConsumer.js +122 -0
- package/src/components/StatusCards.js +13 -22
- package/src/pages/employee/AadhaarVerification.js +356 -0
- package/src/pages/employee/AddressDetails.js +451 -0
- package/src/pages/employee/Create.js +94 -0
- package/src/pages/employee/Inbox.js +37 -20
- package/src/pages/employee/PropertyInfo.js +353 -0
- package/src/pages/employee/index.js +97 -0
- package/src/components/Search.js +0 -77
|
@@ -0,0 +1,2965 @@
|
|
|
1
|
+
import React, { createContext, useCallback, useRef, useState, useEffect, useMemo, isValidElement, cloneElement, createElement, useContext } from 'react';
|
|
2
|
+
import { Link, useHistory, useRouteMatch, useLocation, Switch } from 'react-router-dom';
|
|
3
|
+
import { PersonIcon, EmployeeModuleCard, Label, Dropdown, TextInput, SubmitBar, LinkLabel, Card, Header, Table, Loader, DetailsCard, CardHeader, LabelFieldPair, CardLabel, ActionBar, StatusTable, Row, Modal, RadioButtons, TickMark, PropertyHouse, LocationIcon, InfoBannerIcon, HomeIcon, AppContainer, ModuleHeader, ArrowLeft, PrivateRoute } from '@djb25/digit-ui-react-components';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
|
|
6
|
+
const EKYCCard = () => {
|
|
7
|
+
const {
|
|
8
|
+
t
|
|
9
|
+
} = useTranslation();
|
|
10
|
+
const propsForModuleCard = {
|
|
11
|
+
Icon: /*#__PURE__*/React.createElement(PersonIcon, null),
|
|
12
|
+
moduleName: t("ACTION_TEST_EKYC"),
|
|
13
|
+
kpis: [{
|
|
14
|
+
count: "-",
|
|
15
|
+
label: t("TOTAL_EKYC"),
|
|
16
|
+
link: `/digit-ui/employee/ekyc/dashboard`
|
|
17
|
+
}],
|
|
18
|
+
links: [{
|
|
19
|
+
label: t("EKYC_DASHBOARD"),
|
|
20
|
+
link: `/digit-ui/employee/ekyc/dashboard`
|
|
21
|
+
}, {
|
|
22
|
+
label: t("EKYC_CREATE_KYC"),
|
|
23
|
+
link: `/digit-ui/employee/ekyc/create-kyc`
|
|
24
|
+
}]
|
|
25
|
+
};
|
|
26
|
+
return /*#__PURE__*/React.createElement(EmployeeModuleCard, propsForModuleCard);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var isHTMLElement = value => value instanceof HTMLElement;
|
|
30
|
+
const EVENTS = {
|
|
31
|
+
BLUR: 'blur',
|
|
32
|
+
CHANGE: 'change',
|
|
33
|
+
INPUT: 'input'
|
|
34
|
+
};
|
|
35
|
+
const VALIDATION_MODE = {
|
|
36
|
+
onBlur: 'onBlur',
|
|
37
|
+
onChange: 'onChange',
|
|
38
|
+
onSubmit: 'onSubmit',
|
|
39
|
+
onTouched: 'onTouched',
|
|
40
|
+
all: 'all'
|
|
41
|
+
};
|
|
42
|
+
const SELECT = 'select';
|
|
43
|
+
const UNDEFINED = 'undefined';
|
|
44
|
+
const INPUT_VALIDATION_RULES = {
|
|
45
|
+
max: 'max',
|
|
46
|
+
min: 'min',
|
|
47
|
+
maxLength: 'maxLength',
|
|
48
|
+
minLength: 'minLength',
|
|
49
|
+
pattern: 'pattern',
|
|
50
|
+
required: 'required',
|
|
51
|
+
validate: 'validate'
|
|
52
|
+
};
|
|
53
|
+
function attachEventListeners({
|
|
54
|
+
ref
|
|
55
|
+
}, shouldAttachChangeEvent, handleChange) {
|
|
56
|
+
if (isHTMLElement(ref) && handleChange) {
|
|
57
|
+
ref.addEventListener(shouldAttachChangeEvent ? EVENTS.CHANGE : EVENTS.INPUT, handleChange);
|
|
58
|
+
ref.addEventListener(EVENTS.BLUR, handleChange);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
var isNullOrUndefined = value => value == null;
|
|
62
|
+
const isObjectType = value => typeof value === 'object';
|
|
63
|
+
var isObject = value => !isNullOrUndefined(value) && !Array.isArray(value) && isObjectType(value) && !(value instanceof Date);
|
|
64
|
+
var isKey = value => /^\w*$/.test(value);
|
|
65
|
+
var compact = value => value.filter(Boolean);
|
|
66
|
+
var stringToPath = input => compact(input.replace(/["|']/g, '').replace(/\[/g, '.').replace(/\]/g, '').split('.'));
|
|
67
|
+
function set(object, path, value) {
|
|
68
|
+
let index = -1;
|
|
69
|
+
const tempPath = isKey(path) ? [path] : stringToPath(path);
|
|
70
|
+
const length = tempPath.length;
|
|
71
|
+
const lastIndex = length - 1;
|
|
72
|
+
while (++index < length) {
|
|
73
|
+
const key = tempPath[index];
|
|
74
|
+
let newValue = value;
|
|
75
|
+
if (index !== lastIndex) {
|
|
76
|
+
const objValue = object[key];
|
|
77
|
+
newValue = isObject(objValue) || Array.isArray(objValue) ? objValue : !isNaN(+tempPath[index + 1]) ? [] : {};
|
|
78
|
+
}
|
|
79
|
+
object[key] = newValue;
|
|
80
|
+
object = object[key];
|
|
81
|
+
}
|
|
82
|
+
return object;
|
|
83
|
+
}
|
|
84
|
+
var transformToNestObject = (data, value = {}) => {
|
|
85
|
+
for (const key in data) {
|
|
86
|
+
!isKey(key) ? set(value, key, data[key]) : value[key] = data[key];
|
|
87
|
+
}
|
|
88
|
+
return value;
|
|
89
|
+
};
|
|
90
|
+
var isUndefined = val => val === undefined;
|
|
91
|
+
var get = (obj = {}, path, defaultValue) => {
|
|
92
|
+
const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], obj);
|
|
93
|
+
return isUndefined(result) || result === obj ? isUndefined(obj[path]) ? defaultValue : obj[path] : result;
|
|
94
|
+
};
|
|
95
|
+
var focusOnErrorField = (fields, fieldErrors) => {
|
|
96
|
+
for (const key in fields) {
|
|
97
|
+
if (get(fieldErrors, key)) {
|
|
98
|
+
const field = fields[key];
|
|
99
|
+
if (field) {
|
|
100
|
+
if (field.ref.focus && isUndefined(field.ref.focus())) {
|
|
101
|
+
break;
|
|
102
|
+
} else if (field.options) {
|
|
103
|
+
field.options[0].ref.focus();
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var removeAllEventListeners = (ref, validateWithStateUpdate) => {
|
|
111
|
+
if (isHTMLElement(ref) && ref.removeEventListener) {
|
|
112
|
+
ref.removeEventListener(EVENTS.INPUT, validateWithStateUpdate);
|
|
113
|
+
ref.removeEventListener(EVENTS.CHANGE, validateWithStateUpdate);
|
|
114
|
+
ref.removeEventListener(EVENTS.BLUR, validateWithStateUpdate);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const defaultReturn = {
|
|
118
|
+
isValid: false,
|
|
119
|
+
value: null
|
|
120
|
+
};
|
|
121
|
+
var getRadioValue = options => Array.isArray(options) ? options.reduce((previous, option) => option && option.ref.checked ? {
|
|
122
|
+
isValid: true,
|
|
123
|
+
value: option.ref.value
|
|
124
|
+
} : previous, defaultReturn) : defaultReturn;
|
|
125
|
+
var getMultipleSelectValue = options => [...options].filter(({
|
|
126
|
+
selected
|
|
127
|
+
}) => selected).map(({
|
|
128
|
+
value
|
|
129
|
+
}) => value);
|
|
130
|
+
var isRadioInput = element => element.type === 'radio';
|
|
131
|
+
var isFileInput = element => element.type === 'file';
|
|
132
|
+
var isCheckBoxInput = element => element.type === 'checkbox';
|
|
133
|
+
var isMultipleSelect = element => element.type === `${SELECT}-multiple`;
|
|
134
|
+
const defaultResult = {
|
|
135
|
+
value: false,
|
|
136
|
+
isValid: false
|
|
137
|
+
};
|
|
138
|
+
const validResult = {
|
|
139
|
+
value: true,
|
|
140
|
+
isValid: true
|
|
141
|
+
};
|
|
142
|
+
var getCheckboxValue = options => {
|
|
143
|
+
if (Array.isArray(options)) {
|
|
144
|
+
if (options.length > 1) {
|
|
145
|
+
const values = options.filter(option => option && option.ref.checked).map(({
|
|
146
|
+
ref: {
|
|
147
|
+
value
|
|
148
|
+
}
|
|
149
|
+
}) => value);
|
|
150
|
+
return {
|
|
151
|
+
value: values,
|
|
152
|
+
isValid: !!values.length
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const {
|
|
156
|
+
checked,
|
|
157
|
+
value,
|
|
158
|
+
attributes
|
|
159
|
+
} = options[0].ref;
|
|
160
|
+
return checked ? attributes && !isUndefined(attributes.value) ? isUndefined(value) || value === '' ? validResult : {
|
|
161
|
+
value: value,
|
|
162
|
+
isValid: true
|
|
163
|
+
} : validResult : defaultResult;
|
|
164
|
+
}
|
|
165
|
+
return defaultResult;
|
|
166
|
+
};
|
|
167
|
+
function getFieldValue(fieldsRef, name, shallowFieldsStateRef, excludeDisabled, shouldKeepRawValue) {
|
|
168
|
+
const field = fieldsRef.current[name];
|
|
169
|
+
if (field) {
|
|
170
|
+
const {
|
|
171
|
+
ref: {
|
|
172
|
+
value,
|
|
173
|
+
disabled
|
|
174
|
+
},
|
|
175
|
+
ref,
|
|
176
|
+
valueAsNumber,
|
|
177
|
+
valueAsDate,
|
|
178
|
+
setValueAs
|
|
179
|
+
} = field;
|
|
180
|
+
if (disabled && excludeDisabled) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (isFileInput(ref)) {
|
|
184
|
+
return ref.files;
|
|
185
|
+
}
|
|
186
|
+
if (isRadioInput(ref)) {
|
|
187
|
+
return getRadioValue(field.options).value;
|
|
188
|
+
}
|
|
189
|
+
if (isMultipleSelect(ref)) {
|
|
190
|
+
return getMultipleSelectValue(ref.options);
|
|
191
|
+
}
|
|
192
|
+
if (isCheckBoxInput(ref)) {
|
|
193
|
+
return getCheckboxValue(field.options).value;
|
|
194
|
+
}
|
|
195
|
+
return shouldKeepRawValue ? value : valueAsNumber ? value === '' ? NaN : +value : valueAsDate ? ref.valueAsDate : setValueAs ? setValueAs(value) : value;
|
|
196
|
+
}
|
|
197
|
+
if (shallowFieldsStateRef) {
|
|
198
|
+
return get(shallowFieldsStateRef.current, name);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function isDetached(element) {
|
|
202
|
+
if (!element) {
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
if (!(element instanceof HTMLElement) || element.nodeType === Node.DOCUMENT_NODE) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
return isDetached(element.parentNode);
|
|
209
|
+
}
|
|
210
|
+
var isEmptyObject = value => isObject(value) && !Object.keys(value).length;
|
|
211
|
+
var isBoolean = value => typeof value === 'boolean';
|
|
212
|
+
function baseGet(object, updatePath) {
|
|
213
|
+
const length = updatePath.slice(0, -1).length;
|
|
214
|
+
let index = 0;
|
|
215
|
+
while (index < length) {
|
|
216
|
+
object = isUndefined(object) ? index++ : object[updatePath[index++]];
|
|
217
|
+
}
|
|
218
|
+
return object;
|
|
219
|
+
}
|
|
220
|
+
function unset(object, path) {
|
|
221
|
+
const updatePath = isKey(path) ? [path] : stringToPath(path);
|
|
222
|
+
const childObject = updatePath.length == 1 ? object : baseGet(object, updatePath);
|
|
223
|
+
const key = updatePath[updatePath.length - 1];
|
|
224
|
+
let previousObjRef;
|
|
225
|
+
if (childObject) {
|
|
226
|
+
delete childObject[key];
|
|
227
|
+
}
|
|
228
|
+
for (let k = 0; k < updatePath.slice(0, -1).length; k++) {
|
|
229
|
+
let index = -1;
|
|
230
|
+
let objectRef;
|
|
231
|
+
const currentPaths = updatePath.slice(0, -(k + 1));
|
|
232
|
+
const currentPathsLength = currentPaths.length - 1;
|
|
233
|
+
if (k > 0) {
|
|
234
|
+
previousObjRef = object;
|
|
235
|
+
}
|
|
236
|
+
while (++index < currentPaths.length) {
|
|
237
|
+
const item = currentPaths[index];
|
|
238
|
+
objectRef = objectRef ? objectRef[item] : object[item];
|
|
239
|
+
if (currentPathsLength === index && (isObject(objectRef) && isEmptyObject(objectRef) || Array.isArray(objectRef) && !objectRef.filter(data => isObject(data) && !isEmptyObject(data) || isBoolean(data)).length)) {
|
|
240
|
+
previousObjRef ? delete previousObjRef[item] : delete object[item];
|
|
241
|
+
}
|
|
242
|
+
previousObjRef = objectRef;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return object;
|
|
246
|
+
}
|
|
247
|
+
const isSameRef = (fieldValue, ref) => fieldValue && fieldValue.ref === ref;
|
|
248
|
+
function findRemovedFieldAndRemoveListener(fieldsRef, handleChange, field, shallowFieldsStateRef, shouldUnregister, forceDelete) {
|
|
249
|
+
const {
|
|
250
|
+
ref,
|
|
251
|
+
ref: {
|
|
252
|
+
name
|
|
253
|
+
}
|
|
254
|
+
} = field;
|
|
255
|
+
const fieldRef = fieldsRef.current[name];
|
|
256
|
+
if (!shouldUnregister) {
|
|
257
|
+
const value = getFieldValue(fieldsRef, name, shallowFieldsStateRef);
|
|
258
|
+
!isUndefined(value) && set(shallowFieldsStateRef.current, name, value);
|
|
259
|
+
}
|
|
260
|
+
if (!ref.type || !fieldRef) {
|
|
261
|
+
delete fieldsRef.current[name];
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (isRadioInput(ref) || isCheckBoxInput(ref)) {
|
|
265
|
+
if (Array.isArray(fieldRef.options) && fieldRef.options.length) {
|
|
266
|
+
compact(fieldRef.options).forEach((option = {}, index) => {
|
|
267
|
+
if (isDetached(option.ref) && isSameRef(option, option.ref) || forceDelete) {
|
|
268
|
+
removeAllEventListeners(option.ref, handleChange);
|
|
269
|
+
unset(fieldRef.options, `[${index}]`);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
if (fieldRef.options && !compact(fieldRef.options).length) {
|
|
273
|
+
delete fieldsRef.current[name];
|
|
274
|
+
}
|
|
275
|
+
} else {
|
|
276
|
+
delete fieldsRef.current[name];
|
|
277
|
+
}
|
|
278
|
+
} else if (isDetached(ref) && isSameRef(fieldRef, ref) || forceDelete) {
|
|
279
|
+
removeAllEventListeners(ref, handleChange);
|
|
280
|
+
delete fieldsRef.current[name];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
var isPrimitive = value => isNullOrUndefined(value) || !isObjectType(value);
|
|
284
|
+
function deepMerge(target, source) {
|
|
285
|
+
if (isPrimitive(target) || isPrimitive(source)) {
|
|
286
|
+
return source;
|
|
287
|
+
}
|
|
288
|
+
for (const key in source) {
|
|
289
|
+
const targetValue = target[key];
|
|
290
|
+
const sourceValue = source[key];
|
|
291
|
+
try {
|
|
292
|
+
target[key] = isObject(targetValue) && isObject(sourceValue) || Array.isArray(targetValue) && Array.isArray(sourceValue) ? deepMerge(targetValue, sourceValue) : sourceValue;
|
|
293
|
+
} catch (_a) {}
|
|
294
|
+
}
|
|
295
|
+
return target;
|
|
296
|
+
}
|
|
297
|
+
function deepEqual(object1, object2, isErrorObject) {
|
|
298
|
+
if (isPrimitive(object1) || isPrimitive(object2) || object1 instanceof Date || object2 instanceof Date) {
|
|
299
|
+
return object1 === object2;
|
|
300
|
+
}
|
|
301
|
+
if (!isValidElement(object1)) {
|
|
302
|
+
const keys1 = Object.keys(object1);
|
|
303
|
+
const keys2 = Object.keys(object2);
|
|
304
|
+
if (keys1.length !== keys2.length) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
for (const key of keys1) {
|
|
308
|
+
const val1 = object1[key];
|
|
309
|
+
if (!(isErrorObject && key === 'ref')) {
|
|
310
|
+
const val2 = object2[key];
|
|
311
|
+
if ((isObject(val1) || Array.isArray(val1)) && (isObject(val2) || Array.isArray(val2)) ? !deepEqual(val1, val2, isErrorObject) : val1 !== val2) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
function setDirtyFields(values, defaultValues, dirtyFields, parentNode, parentName) {
|
|
320
|
+
let index = -1;
|
|
321
|
+
while (++index < values.length) {
|
|
322
|
+
for (const key in values[index]) {
|
|
323
|
+
if (Array.isArray(values[index][key])) {
|
|
324
|
+
!dirtyFields[index] && (dirtyFields[index] = {});
|
|
325
|
+
dirtyFields[index][key] = [];
|
|
326
|
+
setDirtyFields(values[index][key], get(defaultValues[index] || {}, key, []), dirtyFields[index][key], dirtyFields[index], key);
|
|
327
|
+
} else {
|
|
328
|
+
deepEqual(get(defaultValues[index] || {}, key), values[index][key]) ? set(dirtyFields[index] || {}, key) : dirtyFields[index] = Object.assign(Object.assign({}, dirtyFields[index]), {
|
|
329
|
+
[key]: true
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
parentNode && !dirtyFields.length && delete parentNode[parentName];
|
|
334
|
+
}
|
|
335
|
+
return dirtyFields;
|
|
336
|
+
}
|
|
337
|
+
var setFieldArrayDirtyFields = (values, defaultValues, dirtyFields) => deepMerge(setDirtyFields(values, defaultValues, dirtyFields.slice(0, values.length)), setDirtyFields(defaultValues, values, dirtyFields.slice(0, values.length)));
|
|
338
|
+
var isString = value => typeof value === 'string';
|
|
339
|
+
var getFieldsValues = (fieldsRef, shallowFieldsState, shouldUnregister, excludeDisabled, search) => {
|
|
340
|
+
const output = {};
|
|
341
|
+
for (const name in fieldsRef.current) {
|
|
342
|
+
if (isUndefined(search) || (isString(search) ? name.startsWith(search) : Array.isArray(search) && search.find(data => name.startsWith(data)))) {
|
|
343
|
+
output[name] = getFieldValue(fieldsRef, name, undefined, excludeDisabled);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return shouldUnregister ? transformToNestObject(output) : deepMerge(shallowFieldsState, transformToNestObject(output));
|
|
347
|
+
};
|
|
348
|
+
var isErrorStateChanged = ({
|
|
349
|
+
errors,
|
|
350
|
+
name,
|
|
351
|
+
error,
|
|
352
|
+
validFields,
|
|
353
|
+
fieldsWithValidation
|
|
354
|
+
}) => {
|
|
355
|
+
const isValid = isUndefined(error);
|
|
356
|
+
const previousError = get(errors, name);
|
|
357
|
+
return isValid && !!previousError || !isValid && !deepEqual(previousError, error, true) || isValid && get(fieldsWithValidation, name) && !get(validFields, name);
|
|
358
|
+
};
|
|
359
|
+
var isRegex = value => value instanceof RegExp;
|
|
360
|
+
var getValueAndMessage = validationData => isObject(validationData) && !isRegex(validationData) ? validationData : {
|
|
361
|
+
value: validationData,
|
|
362
|
+
message: ''
|
|
363
|
+
};
|
|
364
|
+
var isFunction = value => typeof value === 'function';
|
|
365
|
+
var isMessage = value => isString(value) || isValidElement(value);
|
|
366
|
+
function getValidateError(result, ref, type = 'validate') {
|
|
367
|
+
if (isMessage(result) || isBoolean(result) && !result) {
|
|
368
|
+
return {
|
|
369
|
+
type,
|
|
370
|
+
message: isMessage(result) ? result : '',
|
|
371
|
+
ref
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria ? Object.assign(Object.assign({}, errors[name]), {
|
|
376
|
+
types: Object.assign(Object.assign({}, errors[name] && errors[name].types ? errors[name].types : {}), {
|
|
377
|
+
[type]: message || true
|
|
378
|
+
})
|
|
379
|
+
}) : {};
|
|
380
|
+
var validateField = async (fieldsRef, validateAllFieldCriteria, {
|
|
381
|
+
ref,
|
|
382
|
+
ref: {
|
|
383
|
+
value
|
|
384
|
+
},
|
|
385
|
+
options,
|
|
386
|
+
required,
|
|
387
|
+
maxLength,
|
|
388
|
+
minLength,
|
|
389
|
+
min,
|
|
390
|
+
max,
|
|
391
|
+
pattern,
|
|
392
|
+
validate
|
|
393
|
+
}, shallowFieldsStateRef) => {
|
|
394
|
+
const name = ref.name;
|
|
395
|
+
const error = {};
|
|
396
|
+
const isRadio = isRadioInput(ref);
|
|
397
|
+
const isCheckBox = isCheckBoxInput(ref);
|
|
398
|
+
const isRadioOrCheckbox = isRadio || isCheckBox;
|
|
399
|
+
const isEmpty = value === '';
|
|
400
|
+
const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);
|
|
401
|
+
const getMinMaxMessage = (exceedMax, maxLengthMessage, minLengthMessage, maxType = INPUT_VALIDATION_RULES.maxLength, minType = INPUT_VALIDATION_RULES.minLength) => {
|
|
402
|
+
const message = exceedMax ? maxLengthMessage : minLengthMessage;
|
|
403
|
+
error[name] = Object.assign({
|
|
404
|
+
type: exceedMax ? maxType : minType,
|
|
405
|
+
message,
|
|
406
|
+
ref
|
|
407
|
+
}, exceedMax ? appendErrorsCurry(maxType, message) : appendErrorsCurry(minType, message));
|
|
408
|
+
};
|
|
409
|
+
if (required && (!isRadio && !isCheckBox && (isEmpty || isNullOrUndefined(value)) || isBoolean(value) && !value || isCheckBox && !getCheckboxValue(options).isValid || isRadio && !getRadioValue(options).isValid)) {
|
|
410
|
+
const {
|
|
411
|
+
value: _value,
|
|
412
|
+
message
|
|
413
|
+
} = isMessage(required) ? {
|
|
414
|
+
value: !!required,
|
|
415
|
+
message: required
|
|
416
|
+
} : getValueAndMessage(required);
|
|
417
|
+
if (_value) {
|
|
418
|
+
error[name] = Object.assign({
|
|
419
|
+
type: INPUT_VALIDATION_RULES.required,
|
|
420
|
+
message,
|
|
421
|
+
ref: isRadioOrCheckbox ? ((fieldsRef.current[name].options || [])[0] || {}).ref : ref
|
|
422
|
+
}, appendErrorsCurry(INPUT_VALIDATION_RULES.required, message));
|
|
423
|
+
if (!validateAllFieldCriteria) {
|
|
424
|
+
return error;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if ((!isNullOrUndefined(min) || !isNullOrUndefined(max)) && value !== '') {
|
|
429
|
+
let exceedMax;
|
|
430
|
+
let exceedMin;
|
|
431
|
+
const maxOutput = getValueAndMessage(max);
|
|
432
|
+
const minOutput = getValueAndMessage(min);
|
|
433
|
+
if (!isNaN(value)) {
|
|
434
|
+
const valueNumber = ref.valueAsNumber || parseFloat(value);
|
|
435
|
+
if (!isNullOrUndefined(maxOutput.value)) {
|
|
436
|
+
exceedMax = valueNumber > maxOutput.value;
|
|
437
|
+
}
|
|
438
|
+
if (!isNullOrUndefined(minOutput.value)) {
|
|
439
|
+
exceedMin = valueNumber < minOutput.value;
|
|
440
|
+
}
|
|
441
|
+
} else {
|
|
442
|
+
const valueDate = ref.valueAsDate || new Date(value);
|
|
443
|
+
if (isString(maxOutput.value)) {
|
|
444
|
+
exceedMax = valueDate > new Date(maxOutput.value);
|
|
445
|
+
}
|
|
446
|
+
if (isString(minOutput.value)) {
|
|
447
|
+
exceedMin = valueDate < new Date(minOutput.value);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (exceedMax || exceedMin) {
|
|
451
|
+
getMinMaxMessage(!!exceedMax, maxOutput.message, minOutput.message, INPUT_VALIDATION_RULES.max, INPUT_VALIDATION_RULES.min);
|
|
452
|
+
if (!validateAllFieldCriteria) {
|
|
453
|
+
return error;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
if (isString(value) && !isEmpty && (maxLength || minLength)) {
|
|
458
|
+
const maxLengthOutput = getValueAndMessage(maxLength);
|
|
459
|
+
const minLengthOutput = getValueAndMessage(minLength);
|
|
460
|
+
const exceedMax = !isNullOrUndefined(maxLengthOutput.value) && value.length > maxLengthOutput.value;
|
|
461
|
+
const exceedMin = !isNullOrUndefined(minLengthOutput.value) && value.length < minLengthOutput.value;
|
|
462
|
+
if (exceedMax || exceedMin) {
|
|
463
|
+
getMinMaxMessage(exceedMax, maxLengthOutput.message, minLengthOutput.message);
|
|
464
|
+
if (!validateAllFieldCriteria) {
|
|
465
|
+
return error;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
if (isString(value) && pattern && !isEmpty) {
|
|
470
|
+
const {
|
|
471
|
+
value: patternValue,
|
|
472
|
+
message
|
|
473
|
+
} = getValueAndMessage(pattern);
|
|
474
|
+
if (isRegex(patternValue) && !patternValue.test(value)) {
|
|
475
|
+
error[name] = Object.assign({
|
|
476
|
+
type: INPUT_VALIDATION_RULES.pattern,
|
|
477
|
+
message,
|
|
478
|
+
ref
|
|
479
|
+
}, appendErrorsCurry(INPUT_VALIDATION_RULES.pattern, message));
|
|
480
|
+
if (!validateAllFieldCriteria) {
|
|
481
|
+
return error;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
if (validate) {
|
|
486
|
+
const fieldValue = getFieldValue(fieldsRef, name, shallowFieldsStateRef, false, true);
|
|
487
|
+
const validateRef = isRadioOrCheckbox && options ? options[0].ref : ref;
|
|
488
|
+
if (isFunction(validate)) {
|
|
489
|
+
const result = await validate(fieldValue);
|
|
490
|
+
const validateError = getValidateError(result, validateRef);
|
|
491
|
+
if (validateError) {
|
|
492
|
+
error[name] = Object.assign(Object.assign({}, validateError), appendErrorsCurry(INPUT_VALIDATION_RULES.validate, validateError.message));
|
|
493
|
+
if (!validateAllFieldCriteria) {
|
|
494
|
+
return error;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
} else if (isObject(validate)) {
|
|
498
|
+
let validationResult = {};
|
|
499
|
+
for (const [key, validateFunction] of Object.entries(validate)) {
|
|
500
|
+
if (!isEmptyObject(validationResult) && !validateAllFieldCriteria) {
|
|
501
|
+
break;
|
|
502
|
+
}
|
|
503
|
+
const validateResult = await validateFunction(fieldValue);
|
|
504
|
+
const validateError = getValidateError(validateResult, validateRef, key);
|
|
505
|
+
if (validateError) {
|
|
506
|
+
validationResult = Object.assign(Object.assign({}, validateError), appendErrorsCurry(key, validateError.message));
|
|
507
|
+
if (validateAllFieldCriteria) {
|
|
508
|
+
error[name] = validationResult;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (!isEmptyObject(validationResult)) {
|
|
513
|
+
error[name] = Object.assign({
|
|
514
|
+
ref: validateRef
|
|
515
|
+
}, validationResult);
|
|
516
|
+
if (!validateAllFieldCriteria) {
|
|
517
|
+
return error;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return error;
|
|
523
|
+
};
|
|
524
|
+
const getPath = (rootPath, values, paths = []) => {
|
|
525
|
+
for (const property in values) {
|
|
526
|
+
const rootName = rootPath + (isObject(values) ? `.${property}` : `[${property}]`);
|
|
527
|
+
isPrimitive(values[property]) ? paths.push(rootName) : getPath(rootName, values[property], paths);
|
|
528
|
+
}
|
|
529
|
+
return paths;
|
|
530
|
+
};
|
|
531
|
+
var assignWatchFields = (fieldValues, fieldName, watchFields, inputValue, isSingleField) => {
|
|
532
|
+
let value = undefined;
|
|
533
|
+
watchFields.add(fieldName);
|
|
534
|
+
if (!isEmptyObject(fieldValues)) {
|
|
535
|
+
value = get(fieldValues, fieldName);
|
|
536
|
+
if (isObject(value) || Array.isArray(value)) {
|
|
537
|
+
getPath(fieldName, value).forEach(name => watchFields.add(name));
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return isUndefined(value) ? isSingleField ? inputValue : get(inputValue, fieldName) : value;
|
|
541
|
+
};
|
|
542
|
+
var skipValidation = ({
|
|
543
|
+
isOnBlur,
|
|
544
|
+
isOnChange,
|
|
545
|
+
isOnTouch,
|
|
546
|
+
isTouched,
|
|
547
|
+
isReValidateOnBlur,
|
|
548
|
+
isReValidateOnChange,
|
|
549
|
+
isBlurEvent,
|
|
550
|
+
isSubmitted,
|
|
551
|
+
isOnAll
|
|
552
|
+
}) => {
|
|
553
|
+
if (isOnAll) {
|
|
554
|
+
return false;
|
|
555
|
+
} else if (!isSubmitted && isOnTouch) {
|
|
556
|
+
return !(isTouched || isBlurEvent);
|
|
557
|
+
} else if (isSubmitted ? isReValidateOnBlur : isOnBlur) {
|
|
558
|
+
return !isBlurEvent;
|
|
559
|
+
} else if (isSubmitted ? isReValidateOnChange : isOnChange) {
|
|
560
|
+
return isBlurEvent;
|
|
561
|
+
}
|
|
562
|
+
return true;
|
|
563
|
+
};
|
|
564
|
+
var getFieldArrayParentName = name => name.substring(0, name.indexOf('['));
|
|
565
|
+
const isMatchFieldArrayName = (name, searchName) => RegExp(`^${searchName}([|.)\\d+`.replace(/\[/g, '\\[').replace(/\]/g, '\\]')).test(name);
|
|
566
|
+
var isNameInFieldArray = (names, name) => [...names].some(current => isMatchFieldArrayName(name, current));
|
|
567
|
+
var isSelectInput = element => element.type === `${SELECT}-one`;
|
|
568
|
+
function onDomRemove(fieldsRef, removeFieldEventListenerAndRef) {
|
|
569
|
+
const observer = new MutationObserver(() => {
|
|
570
|
+
for (const field of Object.values(fieldsRef.current)) {
|
|
571
|
+
if (field && field.options) {
|
|
572
|
+
for (const option of field.options) {
|
|
573
|
+
if (option && option.ref && isDetached(option.ref)) {
|
|
574
|
+
removeFieldEventListenerAndRef(field);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
} else if (field && isDetached(field.ref)) {
|
|
578
|
+
removeFieldEventListenerAndRef(field);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
observer.observe(window.document, {
|
|
583
|
+
childList: true,
|
|
584
|
+
subtree: true
|
|
585
|
+
});
|
|
586
|
+
return observer;
|
|
587
|
+
}
|
|
588
|
+
var isWeb = typeof window !== UNDEFINED && typeof document !== UNDEFINED;
|
|
589
|
+
function cloneObject(data) {
|
|
590
|
+
var _a;
|
|
591
|
+
let copy;
|
|
592
|
+
if (isPrimitive(data) || isWeb && (data instanceof File || isHTMLElement(data))) {
|
|
593
|
+
return data;
|
|
594
|
+
}
|
|
595
|
+
if (!['Set', 'Map', 'Object', 'Date', 'Array'].includes((_a = data.constructor) === null || _a === void 0 ? void 0 : _a.name)) {
|
|
596
|
+
return data;
|
|
597
|
+
}
|
|
598
|
+
if (data instanceof Date) {
|
|
599
|
+
copy = new Date(data.getTime());
|
|
600
|
+
return copy;
|
|
601
|
+
}
|
|
602
|
+
if (data instanceof Set) {
|
|
603
|
+
copy = new Set();
|
|
604
|
+
for (const item of data) {
|
|
605
|
+
copy.add(item);
|
|
606
|
+
}
|
|
607
|
+
return copy;
|
|
608
|
+
}
|
|
609
|
+
if (data instanceof Map) {
|
|
610
|
+
copy = new Map();
|
|
611
|
+
for (const key of data.keys()) {
|
|
612
|
+
copy.set(key, cloneObject(data.get(key)));
|
|
613
|
+
}
|
|
614
|
+
return copy;
|
|
615
|
+
}
|
|
616
|
+
copy = Array.isArray(data) ? [] : {};
|
|
617
|
+
for (const key in data) {
|
|
618
|
+
copy[key] = cloneObject(data[key]);
|
|
619
|
+
}
|
|
620
|
+
return copy;
|
|
621
|
+
}
|
|
622
|
+
var modeChecker = mode => ({
|
|
623
|
+
isOnSubmit: !mode || mode === VALIDATION_MODE.onSubmit,
|
|
624
|
+
isOnBlur: mode === VALIDATION_MODE.onBlur,
|
|
625
|
+
isOnChange: mode === VALIDATION_MODE.onChange,
|
|
626
|
+
isOnAll: mode === VALIDATION_MODE.all,
|
|
627
|
+
isOnTouch: mode === VALIDATION_MODE.onTouched
|
|
628
|
+
});
|
|
629
|
+
var isRadioOrCheckboxFunction = ref => isRadioInput(ref) || isCheckBoxInput(ref);
|
|
630
|
+
const isWindowUndefined = typeof window === UNDEFINED;
|
|
631
|
+
const isProxyEnabled = isWeb ? 'Proxy' in window : typeof Proxy !== UNDEFINED;
|
|
632
|
+
function useForm({
|
|
633
|
+
mode = VALIDATION_MODE.onSubmit,
|
|
634
|
+
reValidateMode = VALIDATION_MODE.onChange,
|
|
635
|
+
resolver,
|
|
636
|
+
context,
|
|
637
|
+
defaultValues = {},
|
|
638
|
+
shouldFocusError = true,
|
|
639
|
+
shouldUnregister = true,
|
|
640
|
+
criteriaMode
|
|
641
|
+
} = {}) {
|
|
642
|
+
const fieldsRef = useRef({});
|
|
643
|
+
const fieldArrayDefaultValuesRef = useRef({});
|
|
644
|
+
const fieldArrayValuesRef = useRef({});
|
|
645
|
+
const watchFieldsRef = useRef(new Set());
|
|
646
|
+
const useWatchFieldsRef = useRef({});
|
|
647
|
+
const useWatchRenderFunctionsRef = useRef({});
|
|
648
|
+
const fieldsWithValidationRef = useRef({});
|
|
649
|
+
const validFieldsRef = useRef({});
|
|
650
|
+
const defaultValuesRef = useRef(defaultValues);
|
|
651
|
+
const isUnMount = useRef(false);
|
|
652
|
+
const isWatchAllRef = useRef(false);
|
|
653
|
+
const handleChangeRef = useRef();
|
|
654
|
+
const shallowFieldsStateRef = useRef({});
|
|
655
|
+
const resetFieldArrayFunctionRef = useRef({});
|
|
656
|
+
const contextRef = useRef(context);
|
|
657
|
+
const resolverRef = useRef(resolver);
|
|
658
|
+
const fieldArrayNamesRef = useRef(new Set());
|
|
659
|
+
const modeRef = useRef(modeChecker(mode));
|
|
660
|
+
const {
|
|
661
|
+
isOnSubmit,
|
|
662
|
+
isOnTouch
|
|
663
|
+
} = modeRef.current;
|
|
664
|
+
const isValidateAllFieldCriteria = criteriaMode === VALIDATION_MODE.all;
|
|
665
|
+
const [formState, setFormState] = useState({
|
|
666
|
+
isDirty: false,
|
|
667
|
+
isValidating: false,
|
|
668
|
+
dirtyFields: {},
|
|
669
|
+
isSubmitted: false,
|
|
670
|
+
submitCount: 0,
|
|
671
|
+
touched: {},
|
|
672
|
+
isSubmitting: false,
|
|
673
|
+
isSubmitSuccessful: false,
|
|
674
|
+
isValid: !isOnSubmit,
|
|
675
|
+
errors: {}
|
|
676
|
+
});
|
|
677
|
+
const readFormStateRef = useRef({
|
|
678
|
+
isDirty: !isProxyEnabled,
|
|
679
|
+
dirtyFields: !isProxyEnabled,
|
|
680
|
+
touched: !isProxyEnabled || isOnTouch,
|
|
681
|
+
isValidating: !isProxyEnabled,
|
|
682
|
+
isSubmitting: !isProxyEnabled,
|
|
683
|
+
isValid: !isProxyEnabled
|
|
684
|
+
});
|
|
685
|
+
const formStateRef = useRef(formState);
|
|
686
|
+
const observerRef = useRef();
|
|
687
|
+
const {
|
|
688
|
+
isOnBlur: isReValidateOnBlur,
|
|
689
|
+
isOnChange: isReValidateOnChange
|
|
690
|
+
} = useRef(modeChecker(reValidateMode)).current;
|
|
691
|
+
contextRef.current = context;
|
|
692
|
+
resolverRef.current = resolver;
|
|
693
|
+
formStateRef.current = formState;
|
|
694
|
+
shallowFieldsStateRef.current = shouldUnregister ? {} : isEmptyObject(shallowFieldsStateRef.current) ? cloneObject(defaultValues) : shallowFieldsStateRef.current;
|
|
695
|
+
const updateFormState = useCallback((state = {}) => {
|
|
696
|
+
if (!isUnMount.current) {
|
|
697
|
+
formStateRef.current = Object.assign(Object.assign({}, formStateRef.current), state);
|
|
698
|
+
setFormState(formStateRef.current);
|
|
699
|
+
}
|
|
700
|
+
}, []);
|
|
701
|
+
const updateIsValidating = () => readFormStateRef.current.isValidating && updateFormState({
|
|
702
|
+
isValidating: true
|
|
703
|
+
});
|
|
704
|
+
const shouldRenderBaseOnError = useCallback((name, error, shouldRender = false, state = {}, isValid) => {
|
|
705
|
+
let shouldReRender = shouldRender || isErrorStateChanged({
|
|
706
|
+
errors: formStateRef.current.errors,
|
|
707
|
+
error,
|
|
708
|
+
name,
|
|
709
|
+
validFields: validFieldsRef.current,
|
|
710
|
+
fieldsWithValidation: fieldsWithValidationRef.current
|
|
711
|
+
});
|
|
712
|
+
const previousError = get(formStateRef.current.errors, name);
|
|
713
|
+
if (error) {
|
|
714
|
+
unset(validFieldsRef.current, name);
|
|
715
|
+
shouldReRender = shouldReRender || !previousError || !deepEqual(previousError, error, true);
|
|
716
|
+
set(formStateRef.current.errors, name, error);
|
|
717
|
+
} else {
|
|
718
|
+
if (get(fieldsWithValidationRef.current, name) || resolverRef.current) {
|
|
719
|
+
set(validFieldsRef.current, name, true);
|
|
720
|
+
shouldReRender = shouldReRender || previousError;
|
|
721
|
+
}
|
|
722
|
+
unset(formStateRef.current.errors, name);
|
|
723
|
+
}
|
|
724
|
+
if (shouldReRender && !isNullOrUndefined(shouldRender) || !isEmptyObject(state) || readFormStateRef.current.isValidating) {
|
|
725
|
+
updateFormState(Object.assign(Object.assign(Object.assign({}, state), resolverRef.current ? {
|
|
726
|
+
isValid: !!isValid
|
|
727
|
+
} : {}), {
|
|
728
|
+
isValidating: false
|
|
729
|
+
}));
|
|
730
|
+
}
|
|
731
|
+
}, []);
|
|
732
|
+
const setFieldValue = useCallback((name, rawValue) => {
|
|
733
|
+
const {
|
|
734
|
+
ref,
|
|
735
|
+
options
|
|
736
|
+
} = fieldsRef.current[name];
|
|
737
|
+
const value = isWeb && isHTMLElement(ref) && isNullOrUndefined(rawValue) ? '' : rawValue;
|
|
738
|
+
if (isRadioInput(ref)) {
|
|
739
|
+
(options || []).forEach(({
|
|
740
|
+
ref: radioRef
|
|
741
|
+
}) => radioRef.checked = radioRef.value === value);
|
|
742
|
+
} else if (isFileInput(ref) && !isString(value)) {
|
|
743
|
+
ref.files = value;
|
|
744
|
+
} else if (isMultipleSelect(ref)) {
|
|
745
|
+
[...ref.options].forEach(selectRef => selectRef.selected = value.includes(selectRef.value));
|
|
746
|
+
} else if (isCheckBoxInput(ref) && options) {
|
|
747
|
+
options.length > 1 ? options.forEach(({
|
|
748
|
+
ref: checkboxRef
|
|
749
|
+
}) => checkboxRef.checked = Array.isArray(value) ? !!value.find(data => data === checkboxRef.value) : value === checkboxRef.value) : options[0].ref.checked = !!value;
|
|
750
|
+
} else {
|
|
751
|
+
ref.value = value;
|
|
752
|
+
}
|
|
753
|
+
}, []);
|
|
754
|
+
const isFormDirty = useCallback((name, data) => {
|
|
755
|
+
if (readFormStateRef.current.isDirty) {
|
|
756
|
+
const formValues = getValues();
|
|
757
|
+
name && data && set(formValues, name, data);
|
|
758
|
+
return !deepEqual(formValues, defaultValuesRef.current);
|
|
759
|
+
}
|
|
760
|
+
return false;
|
|
761
|
+
}, []);
|
|
762
|
+
const updateAndGetDirtyState = useCallback((name, shouldRender = true) => {
|
|
763
|
+
if (readFormStateRef.current.isDirty || readFormStateRef.current.dirtyFields) {
|
|
764
|
+
const isFieldDirty = !deepEqual(get(defaultValuesRef.current, name), getFieldValue(fieldsRef, name, shallowFieldsStateRef));
|
|
765
|
+
const isDirtyFieldExist = get(formStateRef.current.dirtyFields, name);
|
|
766
|
+
const previousIsDirty = formStateRef.current.isDirty;
|
|
767
|
+
isFieldDirty ? set(formStateRef.current.dirtyFields, name, true) : unset(formStateRef.current.dirtyFields, name);
|
|
768
|
+
const state = {
|
|
769
|
+
isDirty: isFormDirty(),
|
|
770
|
+
dirtyFields: formStateRef.current.dirtyFields
|
|
771
|
+
};
|
|
772
|
+
const isChanged = readFormStateRef.current.isDirty && previousIsDirty !== state.isDirty || readFormStateRef.current.dirtyFields && isDirtyFieldExist !== get(formStateRef.current.dirtyFields, name);
|
|
773
|
+
isChanged && shouldRender && updateFormState(state);
|
|
774
|
+
return isChanged ? state : {};
|
|
775
|
+
}
|
|
776
|
+
return {};
|
|
777
|
+
}, []);
|
|
778
|
+
const executeValidation = useCallback(async (name, skipReRender) => {
|
|
779
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
780
|
+
if (!fieldsRef.current[name]) {
|
|
781
|
+
console.warn('📋 Field is missing with `name` attribute: ', name);
|
|
782
|
+
return false;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
const error = (await validateField(fieldsRef, isValidateAllFieldCriteria, fieldsRef.current[name], shallowFieldsStateRef))[name];
|
|
786
|
+
shouldRenderBaseOnError(name, error, skipReRender);
|
|
787
|
+
return isUndefined(error);
|
|
788
|
+
}, [shouldRenderBaseOnError, isValidateAllFieldCriteria]);
|
|
789
|
+
const executeSchemaOrResolverValidation = useCallback(async names => {
|
|
790
|
+
const {
|
|
791
|
+
errors
|
|
792
|
+
} = await resolverRef.current(getValues(), contextRef.current, isValidateAllFieldCriteria);
|
|
793
|
+
const previousFormIsValid = formStateRef.current.isValid;
|
|
794
|
+
if (Array.isArray(names)) {
|
|
795
|
+
const isInputsValid = names.map(name => {
|
|
796
|
+
const error = get(errors, name);
|
|
797
|
+
error ? set(formStateRef.current.errors, name, error) : unset(formStateRef.current.errors, name);
|
|
798
|
+
return !error;
|
|
799
|
+
}).every(Boolean);
|
|
800
|
+
updateFormState({
|
|
801
|
+
isValid: isEmptyObject(errors),
|
|
802
|
+
isValidating: false
|
|
803
|
+
});
|
|
804
|
+
return isInputsValid;
|
|
805
|
+
} else {
|
|
806
|
+
const error = get(errors, names);
|
|
807
|
+
shouldRenderBaseOnError(names, error, previousFormIsValid !== isEmptyObject(errors), {}, isEmptyObject(errors));
|
|
808
|
+
return !error;
|
|
809
|
+
}
|
|
810
|
+
}, [shouldRenderBaseOnError, isValidateAllFieldCriteria]);
|
|
811
|
+
const trigger = useCallback(async name => {
|
|
812
|
+
const fields = name || Object.keys(fieldsRef.current);
|
|
813
|
+
updateIsValidating();
|
|
814
|
+
if (resolverRef.current) {
|
|
815
|
+
return executeSchemaOrResolverValidation(fields);
|
|
816
|
+
}
|
|
817
|
+
if (Array.isArray(fields)) {
|
|
818
|
+
!name && (formStateRef.current.errors = {});
|
|
819
|
+
const result = await Promise.all(fields.map(async data => await executeValidation(data, null)));
|
|
820
|
+
updateFormState({
|
|
821
|
+
isValidating: false
|
|
822
|
+
});
|
|
823
|
+
return result.every(Boolean);
|
|
824
|
+
}
|
|
825
|
+
return await executeValidation(fields);
|
|
826
|
+
}, [executeSchemaOrResolverValidation, executeValidation]);
|
|
827
|
+
const setInternalValues = useCallback((name, value, {
|
|
828
|
+
shouldDirty,
|
|
829
|
+
shouldValidate
|
|
830
|
+
}) => {
|
|
831
|
+
const data = {};
|
|
832
|
+
set(data, name, value);
|
|
833
|
+
for (const fieldName of getPath(name, value)) {
|
|
834
|
+
if (fieldsRef.current[fieldName]) {
|
|
835
|
+
setFieldValue(fieldName, get(data, fieldName));
|
|
836
|
+
shouldDirty && updateAndGetDirtyState(fieldName);
|
|
837
|
+
shouldValidate && trigger(fieldName);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}, [trigger, setFieldValue, updateAndGetDirtyState]);
|
|
841
|
+
const setInternalValue = useCallback((name, value, config) => {
|
|
842
|
+
!shouldUnregister && !isPrimitive(value) && set(shallowFieldsStateRef.current, name, Array.isArray(value) ? [...value] : Object.assign({}, value));
|
|
843
|
+
if (fieldsRef.current[name]) {
|
|
844
|
+
setFieldValue(name, value);
|
|
845
|
+
config.shouldDirty && updateAndGetDirtyState(name);
|
|
846
|
+
config.shouldValidate && trigger(name);
|
|
847
|
+
} else if (!isPrimitive(value)) {
|
|
848
|
+
setInternalValues(name, value, config);
|
|
849
|
+
if (fieldArrayNamesRef.current.has(name)) {
|
|
850
|
+
const parentName = getFieldArrayParentName(name) || name;
|
|
851
|
+
set(fieldArrayDefaultValuesRef.current, name, value);
|
|
852
|
+
resetFieldArrayFunctionRef.current[parentName]({
|
|
853
|
+
[parentName]: get(fieldArrayDefaultValuesRef.current, parentName)
|
|
854
|
+
});
|
|
855
|
+
if ((readFormStateRef.current.isDirty || readFormStateRef.current.dirtyFields) && config.shouldDirty) {
|
|
856
|
+
set(formStateRef.current.dirtyFields, name, setFieldArrayDirtyFields(value, get(defaultValuesRef.current, name, []), get(formStateRef.current.dirtyFields, name, [])));
|
|
857
|
+
updateFormState({
|
|
858
|
+
isDirty: !deepEqual(Object.assign(Object.assign({}, getValues()), {
|
|
859
|
+
[name]: value
|
|
860
|
+
}), defaultValuesRef.current)
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
!shouldUnregister && set(shallowFieldsStateRef.current, name, value);
|
|
866
|
+
}, [updateAndGetDirtyState, setFieldValue, setInternalValues]);
|
|
867
|
+
const isFieldWatched = name => isWatchAllRef.current || watchFieldsRef.current.has(name) || watchFieldsRef.current.has((name.match(/\w+/) || [])[0]);
|
|
868
|
+
const renderWatchedInputs = name => {
|
|
869
|
+
let found = true;
|
|
870
|
+
if (!isEmptyObject(useWatchFieldsRef.current)) {
|
|
871
|
+
for (const key in useWatchFieldsRef.current) {
|
|
872
|
+
if (!name || !useWatchFieldsRef.current[key].size || useWatchFieldsRef.current[key].has(name) || useWatchFieldsRef.current[key].has(getFieldArrayParentName(name))) {
|
|
873
|
+
useWatchRenderFunctionsRef.current[key]();
|
|
874
|
+
found = false;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return found;
|
|
879
|
+
};
|
|
880
|
+
function setValue(name, value, config) {
|
|
881
|
+
setInternalValue(name, value, config || {});
|
|
882
|
+
isFieldWatched(name) && updateFormState();
|
|
883
|
+
renderWatchedInputs(name);
|
|
884
|
+
}
|
|
885
|
+
handleChangeRef.current = handleChangeRef.current ? handleChangeRef.current : async ({
|
|
886
|
+
type,
|
|
887
|
+
target
|
|
888
|
+
}) => {
|
|
889
|
+
let name = target.name;
|
|
890
|
+
const field = fieldsRef.current[name];
|
|
891
|
+
let error;
|
|
892
|
+
let isValid;
|
|
893
|
+
if (field) {
|
|
894
|
+
const isBlurEvent = type === EVENTS.BLUR;
|
|
895
|
+
const shouldSkipValidation = skipValidation(Object.assign({
|
|
896
|
+
isBlurEvent,
|
|
897
|
+
isReValidateOnChange,
|
|
898
|
+
isReValidateOnBlur,
|
|
899
|
+
isTouched: !!get(formStateRef.current.touched, name),
|
|
900
|
+
isSubmitted: formStateRef.current.isSubmitted
|
|
901
|
+
}, modeRef.current));
|
|
902
|
+
let state = updateAndGetDirtyState(name, false);
|
|
903
|
+
let shouldRender = !isEmptyObject(state) || !isBlurEvent && isFieldWatched(name);
|
|
904
|
+
if (isBlurEvent && !get(formStateRef.current.touched, name) && readFormStateRef.current.touched) {
|
|
905
|
+
set(formStateRef.current.touched, name, true);
|
|
906
|
+
state = Object.assign(Object.assign({}, state), {
|
|
907
|
+
touched: formStateRef.current.touched
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
if (!shouldUnregister && isCheckBoxInput(target)) {
|
|
911
|
+
set(shallowFieldsStateRef.current, name, getFieldValue(fieldsRef, name));
|
|
912
|
+
}
|
|
913
|
+
if (shouldSkipValidation) {
|
|
914
|
+
!isBlurEvent && renderWatchedInputs(name);
|
|
915
|
+
return (!isEmptyObject(state) || shouldRender && isEmptyObject(state)) && updateFormState(state);
|
|
916
|
+
}
|
|
917
|
+
updateIsValidating();
|
|
918
|
+
if (resolverRef.current) {
|
|
919
|
+
const {
|
|
920
|
+
errors
|
|
921
|
+
} = await resolverRef.current(getValues(), contextRef.current, isValidateAllFieldCriteria);
|
|
922
|
+
const previousFormIsValid = formStateRef.current.isValid;
|
|
923
|
+
error = get(errors, name);
|
|
924
|
+
if (isCheckBoxInput(target) && !error && resolverRef.current) {
|
|
925
|
+
const parentNodeName = getFieldArrayParentName(name);
|
|
926
|
+
const currentError = get(errors, parentNodeName, {});
|
|
927
|
+
currentError.type && currentError.message && (error = currentError);
|
|
928
|
+
if (parentNodeName && (currentError || get(formStateRef.current.errors, parentNodeName))) {
|
|
929
|
+
name = parentNodeName;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
isValid = isEmptyObject(errors);
|
|
933
|
+
previousFormIsValid !== isValid && (shouldRender = true);
|
|
934
|
+
} else {
|
|
935
|
+
error = (await validateField(fieldsRef, isValidateAllFieldCriteria, field, shallowFieldsStateRef))[name];
|
|
936
|
+
}
|
|
937
|
+
!isBlurEvent && renderWatchedInputs(name);
|
|
938
|
+
shouldRenderBaseOnError(name, error, shouldRender, state, isValid);
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
function setFieldArrayDefaultValues(data) {
|
|
942
|
+
if (!shouldUnregister) {
|
|
943
|
+
let copy = cloneObject(data);
|
|
944
|
+
for (const value of fieldArrayNamesRef.current) {
|
|
945
|
+
if (isKey(value) && !copy[value]) {
|
|
946
|
+
copy = Object.assign(Object.assign({}, copy), {
|
|
947
|
+
[value]: []
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
return copy;
|
|
952
|
+
}
|
|
953
|
+
return data;
|
|
954
|
+
}
|
|
955
|
+
function getValues(payload) {
|
|
956
|
+
if (isString(payload)) {
|
|
957
|
+
return getFieldValue(fieldsRef, payload, shallowFieldsStateRef);
|
|
958
|
+
}
|
|
959
|
+
if (Array.isArray(payload)) {
|
|
960
|
+
const data = {};
|
|
961
|
+
for (const name of payload) {
|
|
962
|
+
set(data, name, getFieldValue(fieldsRef, name, shallowFieldsStateRef));
|
|
963
|
+
}
|
|
964
|
+
return data;
|
|
965
|
+
}
|
|
966
|
+
return setFieldArrayDefaultValues(getFieldsValues(fieldsRef, cloneObject(shallowFieldsStateRef.current), shouldUnregister));
|
|
967
|
+
}
|
|
968
|
+
const validateResolver = useCallback(async (values = {}) => {
|
|
969
|
+
const newDefaultValues = isEmptyObject(fieldsRef.current) ? defaultValuesRef.current : {};
|
|
970
|
+
const {
|
|
971
|
+
errors
|
|
972
|
+
} = (await resolverRef.current(Object.assign(Object.assign(Object.assign({}, newDefaultValues), getValues()), values), contextRef.current, isValidateAllFieldCriteria)) || {};
|
|
973
|
+
const isValid = isEmptyObject(errors);
|
|
974
|
+
formStateRef.current.isValid !== isValid && updateFormState({
|
|
975
|
+
isValid
|
|
976
|
+
});
|
|
977
|
+
}, [isValidateAllFieldCriteria]);
|
|
978
|
+
const removeFieldEventListener = useCallback((field, forceDelete) => {
|
|
979
|
+
findRemovedFieldAndRemoveListener(fieldsRef, handleChangeRef.current, field, shallowFieldsStateRef, shouldUnregister, forceDelete);
|
|
980
|
+
if (shouldUnregister) {
|
|
981
|
+
unset(validFieldsRef.current, field.ref.name);
|
|
982
|
+
unset(fieldsWithValidationRef.current, field.ref.name);
|
|
983
|
+
}
|
|
984
|
+
}, [shouldUnregister]);
|
|
985
|
+
const updateWatchedValue = useCallback(name => {
|
|
986
|
+
if (isWatchAllRef.current) {
|
|
987
|
+
updateFormState();
|
|
988
|
+
} else {
|
|
989
|
+
for (const watchField of watchFieldsRef.current) {
|
|
990
|
+
if (watchField.startsWith(name)) {
|
|
991
|
+
updateFormState();
|
|
992
|
+
break;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
renderWatchedInputs(name);
|
|
996
|
+
}
|
|
997
|
+
}, []);
|
|
998
|
+
const removeFieldEventListenerAndRef = useCallback((field, forceDelete) => {
|
|
999
|
+
if (field) {
|
|
1000
|
+
removeFieldEventListener(field, forceDelete);
|
|
1001
|
+
if (shouldUnregister && !compact(field.options || []).length) {
|
|
1002
|
+
unset(formStateRef.current.errors, field.ref.name);
|
|
1003
|
+
set(formStateRef.current.dirtyFields, field.ref.name, true);
|
|
1004
|
+
updateFormState({
|
|
1005
|
+
isDirty: isFormDirty()
|
|
1006
|
+
});
|
|
1007
|
+
readFormStateRef.current.isValid && resolverRef.current && validateResolver();
|
|
1008
|
+
updateWatchedValue(field.ref.name);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
}, [validateResolver, removeFieldEventListener]);
|
|
1012
|
+
function clearErrors(name) {
|
|
1013
|
+
name && (Array.isArray(name) ? name : [name]).forEach(inputName => fieldsRef.current[inputName] && isKey(inputName) ? delete formStateRef.current.errors[inputName] : unset(formStateRef.current.errors, inputName));
|
|
1014
|
+
updateFormState({
|
|
1015
|
+
errors: name ? formStateRef.current.errors : {}
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
function setError(name, error) {
|
|
1019
|
+
const ref = (fieldsRef.current[name] || {}).ref;
|
|
1020
|
+
set(formStateRef.current.errors, name, Object.assign(Object.assign({}, error), {
|
|
1021
|
+
ref
|
|
1022
|
+
}));
|
|
1023
|
+
updateFormState({
|
|
1024
|
+
isValid: false
|
|
1025
|
+
});
|
|
1026
|
+
error.shouldFocus && ref && ref.focus && ref.focus();
|
|
1027
|
+
}
|
|
1028
|
+
const watchInternal = useCallback((fieldNames, defaultValue, watchId) => {
|
|
1029
|
+
const watchFields = watchId ? useWatchFieldsRef.current[watchId] : watchFieldsRef.current;
|
|
1030
|
+
let fieldValues = getFieldsValues(fieldsRef, cloneObject(shallowFieldsStateRef.current), shouldUnregister, false, fieldNames);
|
|
1031
|
+
if (isString(fieldNames)) {
|
|
1032
|
+
const parentNodeName = getFieldArrayParentName(fieldNames) || fieldNames;
|
|
1033
|
+
if (fieldArrayNamesRef.current.has(parentNodeName)) {
|
|
1034
|
+
fieldValues = Object.assign(Object.assign({}, fieldArrayValuesRef.current), fieldValues);
|
|
1035
|
+
}
|
|
1036
|
+
return assignWatchFields(fieldValues, fieldNames, watchFields, isUndefined(get(defaultValuesRef.current, fieldNames)) ? defaultValue : get(defaultValuesRef.current, fieldNames), true);
|
|
1037
|
+
}
|
|
1038
|
+
const combinedDefaultValues = isUndefined(defaultValue) ? defaultValuesRef.current : defaultValue;
|
|
1039
|
+
if (Array.isArray(fieldNames)) {
|
|
1040
|
+
return fieldNames.reduce((previous, name) => Object.assign(Object.assign({}, previous), {
|
|
1041
|
+
[name]: assignWatchFields(fieldValues, name, watchFields, combinedDefaultValues)
|
|
1042
|
+
}), {});
|
|
1043
|
+
}
|
|
1044
|
+
isWatchAllRef.current = isUndefined(watchId);
|
|
1045
|
+
return transformToNestObject(!isEmptyObject(fieldValues) && fieldValues || combinedDefaultValues);
|
|
1046
|
+
}, []);
|
|
1047
|
+
function watch(fieldNames, defaultValue) {
|
|
1048
|
+
return watchInternal(fieldNames, defaultValue);
|
|
1049
|
+
}
|
|
1050
|
+
function unregister(name) {
|
|
1051
|
+
for (const fieldName of Array.isArray(name) ? name : [name]) {
|
|
1052
|
+
removeFieldEventListenerAndRef(fieldsRef.current[fieldName], true);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
function registerFieldRef(ref, options = {}) {
|
|
1056
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1057
|
+
if (!ref.name) {
|
|
1058
|
+
return console.warn('📋 Field is missing `name` attribute', ref, `https://react-hook-form.com/api#useForm`);
|
|
1059
|
+
}
|
|
1060
|
+
if (fieldArrayNamesRef.current.has(ref.name.split(/\[\d+\]$/)[0]) && !RegExp(`^${ref.name.split(/\[\d+\]$/)[0]}[\\d+].\\w+`.replace(/\[/g, '\\[').replace(/\]/g, '\\]')).test(ref.name)) {
|
|
1061
|
+
return console.warn('📋 `name` prop should be in object shape: name="test[index].name"', ref, 'https://react-hook-form.com/api#useFieldArray');
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
const {
|
|
1065
|
+
name,
|
|
1066
|
+
type,
|
|
1067
|
+
value
|
|
1068
|
+
} = ref;
|
|
1069
|
+
const fieldRefAndValidationOptions = Object.assign({
|
|
1070
|
+
ref
|
|
1071
|
+
}, options);
|
|
1072
|
+
const fields = fieldsRef.current;
|
|
1073
|
+
const isRadioOrCheckbox = isRadioOrCheckboxFunction(ref);
|
|
1074
|
+
const isFieldArray = isNameInFieldArray(fieldArrayNamesRef.current, name);
|
|
1075
|
+
const compareRef = currentRef => isWeb && (!isHTMLElement(ref) || currentRef === ref);
|
|
1076
|
+
let field = fields[name];
|
|
1077
|
+
let isEmptyDefaultValue = true;
|
|
1078
|
+
let defaultValue;
|
|
1079
|
+
if (field && (isRadioOrCheckbox ? Array.isArray(field.options) && compact(field.options).find(option => {
|
|
1080
|
+
return value === option.ref.value && compareRef(option.ref);
|
|
1081
|
+
}) : compareRef(field.ref))) {
|
|
1082
|
+
fields[name] = Object.assign(Object.assign({}, field), options);
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
if (type) {
|
|
1086
|
+
field = isRadioOrCheckbox ? Object.assign({
|
|
1087
|
+
options: [...compact(field && field.options || []), {
|
|
1088
|
+
ref
|
|
1089
|
+
}],
|
|
1090
|
+
ref: {
|
|
1091
|
+
type,
|
|
1092
|
+
name
|
|
1093
|
+
}
|
|
1094
|
+
}, options) : Object.assign({}, fieldRefAndValidationOptions);
|
|
1095
|
+
} else {
|
|
1096
|
+
field = fieldRefAndValidationOptions;
|
|
1097
|
+
}
|
|
1098
|
+
fields[name] = field;
|
|
1099
|
+
const isEmptyUnmountFields = isUndefined(get(shallowFieldsStateRef.current, name));
|
|
1100
|
+
if (!isEmptyObject(defaultValuesRef.current) || !isEmptyUnmountFields) {
|
|
1101
|
+
defaultValue = get(isEmptyUnmountFields ? defaultValuesRef.current : shallowFieldsStateRef.current, name);
|
|
1102
|
+
isEmptyDefaultValue = isUndefined(defaultValue);
|
|
1103
|
+
if (!isEmptyDefaultValue && !isFieldArray) {
|
|
1104
|
+
setFieldValue(name, defaultValue);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
if (!isEmptyObject(options)) {
|
|
1108
|
+
set(fieldsWithValidationRef.current, name, true);
|
|
1109
|
+
if (!isOnSubmit && readFormStateRef.current.isValid) {
|
|
1110
|
+
validateField(fieldsRef, isValidateAllFieldCriteria, field, shallowFieldsStateRef).then(error => {
|
|
1111
|
+
const previousFormIsValid = formStateRef.current.isValid;
|
|
1112
|
+
isEmptyObject(error) ? set(validFieldsRef.current, name, true) : unset(validFieldsRef.current, name);
|
|
1113
|
+
previousFormIsValid !== isEmptyObject(error) && updateFormState();
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
if (shouldUnregister && !(isFieldArray && isEmptyDefaultValue)) {
|
|
1118
|
+
!isFieldArray && unset(formStateRef.current.dirtyFields, name);
|
|
1119
|
+
}
|
|
1120
|
+
if (type) {
|
|
1121
|
+
attachEventListeners(isRadioOrCheckbox && field.options ? field.options[field.options.length - 1] : field, isRadioOrCheckbox || isSelectInput(ref), handleChangeRef.current);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
function register(refOrRegisterOptions, options) {
|
|
1125
|
+
if (!isWindowUndefined) {
|
|
1126
|
+
if (isString(refOrRegisterOptions)) {
|
|
1127
|
+
registerFieldRef({
|
|
1128
|
+
name: refOrRegisterOptions
|
|
1129
|
+
}, options);
|
|
1130
|
+
} else if (isObject(refOrRegisterOptions) && 'name' in refOrRegisterOptions) {
|
|
1131
|
+
registerFieldRef(refOrRegisterOptions, options);
|
|
1132
|
+
} else {
|
|
1133
|
+
return ref => ref && registerFieldRef(ref, refOrRegisterOptions);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
const handleSubmit = useCallback((onValid, onInvalid) => async e => {
|
|
1138
|
+
if (e && e.preventDefault) {
|
|
1139
|
+
e.preventDefault();
|
|
1140
|
+
e.persist();
|
|
1141
|
+
}
|
|
1142
|
+
let fieldErrors = {};
|
|
1143
|
+
let fieldValues = setFieldArrayDefaultValues(getFieldsValues(fieldsRef, cloneObject(shallowFieldsStateRef.current), shouldUnregister, true));
|
|
1144
|
+
readFormStateRef.current.isSubmitting && updateFormState({
|
|
1145
|
+
isSubmitting: true
|
|
1146
|
+
});
|
|
1147
|
+
try {
|
|
1148
|
+
if (resolverRef.current) {
|
|
1149
|
+
const {
|
|
1150
|
+
errors,
|
|
1151
|
+
values
|
|
1152
|
+
} = await resolverRef.current(fieldValues, contextRef.current, isValidateAllFieldCriteria);
|
|
1153
|
+
formStateRef.current.errors = fieldErrors = errors;
|
|
1154
|
+
fieldValues = values;
|
|
1155
|
+
} else {
|
|
1156
|
+
for (const field of Object.values(fieldsRef.current)) {
|
|
1157
|
+
if (field) {
|
|
1158
|
+
const {
|
|
1159
|
+
name
|
|
1160
|
+
} = field.ref;
|
|
1161
|
+
const fieldError = await validateField(fieldsRef, isValidateAllFieldCriteria, field, shallowFieldsStateRef);
|
|
1162
|
+
if (fieldError[name]) {
|
|
1163
|
+
set(fieldErrors, name, fieldError[name]);
|
|
1164
|
+
unset(validFieldsRef.current, name);
|
|
1165
|
+
} else if (get(fieldsWithValidationRef.current, name)) {
|
|
1166
|
+
unset(formStateRef.current.errors, name);
|
|
1167
|
+
set(validFieldsRef.current, name, true);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
if (isEmptyObject(fieldErrors) && Object.keys(formStateRef.current.errors).every(name => name in fieldsRef.current)) {
|
|
1173
|
+
updateFormState({
|
|
1174
|
+
errors: {},
|
|
1175
|
+
isSubmitting: true
|
|
1176
|
+
});
|
|
1177
|
+
await onValid(fieldValues, e);
|
|
1178
|
+
} else {
|
|
1179
|
+
formStateRef.current.errors = Object.assign(Object.assign({}, formStateRef.current.errors), fieldErrors);
|
|
1180
|
+
onInvalid && (await onInvalid(formStateRef.current.errors, e));
|
|
1181
|
+
shouldFocusError && focusOnErrorField(fieldsRef.current, formStateRef.current.errors);
|
|
1182
|
+
}
|
|
1183
|
+
} finally {
|
|
1184
|
+
formStateRef.current.isSubmitting = false;
|
|
1185
|
+
updateFormState({
|
|
1186
|
+
isSubmitted: true,
|
|
1187
|
+
isSubmitting: false,
|
|
1188
|
+
isSubmitSuccessful: isEmptyObject(formStateRef.current.errors),
|
|
1189
|
+
submitCount: formStateRef.current.submitCount + 1
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
}, [shouldFocusError, isValidateAllFieldCriteria]);
|
|
1193
|
+
const resetRefs = ({
|
|
1194
|
+
errors,
|
|
1195
|
+
isDirty,
|
|
1196
|
+
isSubmitted,
|
|
1197
|
+
touched,
|
|
1198
|
+
isValid,
|
|
1199
|
+
submitCount,
|
|
1200
|
+
dirtyFields
|
|
1201
|
+
}) => {
|
|
1202
|
+
if (!isValid) {
|
|
1203
|
+
validFieldsRef.current = {};
|
|
1204
|
+
fieldsWithValidationRef.current = {};
|
|
1205
|
+
}
|
|
1206
|
+
fieldArrayDefaultValuesRef.current = {};
|
|
1207
|
+
watchFieldsRef.current = new Set();
|
|
1208
|
+
isWatchAllRef.current = false;
|
|
1209
|
+
updateFormState({
|
|
1210
|
+
submitCount: submitCount ? formStateRef.current.submitCount : 0,
|
|
1211
|
+
isDirty: isDirty ? formStateRef.current.isDirty : false,
|
|
1212
|
+
isSubmitted: isSubmitted ? formStateRef.current.isSubmitted : false,
|
|
1213
|
+
isValid: isValid ? formStateRef.current.isValid : false,
|
|
1214
|
+
dirtyFields: dirtyFields ? formStateRef.current.dirtyFields : {},
|
|
1215
|
+
touched: touched ? formStateRef.current.touched : {},
|
|
1216
|
+
errors: errors ? formStateRef.current.errors : {},
|
|
1217
|
+
isSubmitting: false,
|
|
1218
|
+
isSubmitSuccessful: false
|
|
1219
|
+
});
|
|
1220
|
+
};
|
|
1221
|
+
const reset = (values, omitResetState = {}) => {
|
|
1222
|
+
if (isWeb) {
|
|
1223
|
+
for (const field of Object.values(fieldsRef.current)) {
|
|
1224
|
+
if (field) {
|
|
1225
|
+
const {
|
|
1226
|
+
ref,
|
|
1227
|
+
options
|
|
1228
|
+
} = field;
|
|
1229
|
+
const inputRef = isRadioOrCheckboxFunction(ref) && Array.isArray(options) ? options[0].ref : ref;
|
|
1230
|
+
if (isHTMLElement(inputRef)) {
|
|
1231
|
+
try {
|
|
1232
|
+
inputRef.closest('form').reset();
|
|
1233
|
+
break;
|
|
1234
|
+
} catch (_a) {}
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
fieldsRef.current = {};
|
|
1240
|
+
defaultValuesRef.current = Object.assign({}, values || defaultValuesRef.current);
|
|
1241
|
+
values && renderWatchedInputs('');
|
|
1242
|
+
Object.values(resetFieldArrayFunctionRef.current).forEach(resetFieldArray => isFunction(resetFieldArray) && resetFieldArray());
|
|
1243
|
+
shallowFieldsStateRef.current = shouldUnregister ? {} : cloneObject(values || defaultValuesRef.current);
|
|
1244
|
+
resetRefs(omitResetState);
|
|
1245
|
+
};
|
|
1246
|
+
useEffect(() => {
|
|
1247
|
+
resolver && readFormStateRef.current.isValid && validateResolver();
|
|
1248
|
+
observerRef.current = observerRef.current || !isWeb ? observerRef.current : onDomRemove(fieldsRef, removeFieldEventListenerAndRef);
|
|
1249
|
+
}, [removeFieldEventListenerAndRef, defaultValuesRef.current]);
|
|
1250
|
+
useEffect(() => () => {
|
|
1251
|
+
observerRef.current && observerRef.current.disconnect();
|
|
1252
|
+
isUnMount.current = true;
|
|
1253
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
Object.values(fieldsRef.current).forEach(field => removeFieldEventListenerAndRef(field, true));
|
|
1257
|
+
}, []);
|
|
1258
|
+
if (!resolver && readFormStateRef.current.isValid) {
|
|
1259
|
+
formState.isValid = deepEqual(validFieldsRef.current, fieldsWithValidationRef.current) && isEmptyObject(formStateRef.current.errors);
|
|
1260
|
+
}
|
|
1261
|
+
const commonProps = {
|
|
1262
|
+
trigger,
|
|
1263
|
+
setValue: useCallback(setValue, [setInternalValue, trigger]),
|
|
1264
|
+
getValues: useCallback(getValues, []),
|
|
1265
|
+
register: useCallback(register, [defaultValuesRef.current]),
|
|
1266
|
+
unregister: useCallback(unregister, []),
|
|
1267
|
+
formState: isProxyEnabled ? new Proxy(formState, {
|
|
1268
|
+
get: (obj, prop) => {
|
|
1269
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1270
|
+
if (prop === 'isValid' && isOnSubmit) {
|
|
1271
|
+
console.warn('📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState');
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
if (prop in obj) {
|
|
1275
|
+
readFormStateRef.current[prop] = true;
|
|
1276
|
+
return obj[prop];
|
|
1277
|
+
}
|
|
1278
|
+
return undefined;
|
|
1279
|
+
}
|
|
1280
|
+
}) : formState
|
|
1281
|
+
};
|
|
1282
|
+
const control = useMemo(() => Object.assign({
|
|
1283
|
+
isFormDirty,
|
|
1284
|
+
updateWatchedValue,
|
|
1285
|
+
shouldUnregister,
|
|
1286
|
+
updateFormState,
|
|
1287
|
+
removeFieldEventListener,
|
|
1288
|
+
watchInternal,
|
|
1289
|
+
mode: modeRef.current,
|
|
1290
|
+
reValidateMode: {
|
|
1291
|
+
isReValidateOnBlur,
|
|
1292
|
+
isReValidateOnChange
|
|
1293
|
+
},
|
|
1294
|
+
validateResolver: resolver ? validateResolver : undefined,
|
|
1295
|
+
fieldsRef,
|
|
1296
|
+
resetFieldArrayFunctionRef,
|
|
1297
|
+
useWatchFieldsRef,
|
|
1298
|
+
useWatchRenderFunctionsRef,
|
|
1299
|
+
fieldArrayDefaultValuesRef,
|
|
1300
|
+
validFieldsRef,
|
|
1301
|
+
fieldsWithValidationRef,
|
|
1302
|
+
fieldArrayNamesRef,
|
|
1303
|
+
readFormStateRef,
|
|
1304
|
+
formStateRef,
|
|
1305
|
+
defaultValuesRef,
|
|
1306
|
+
shallowFieldsStateRef,
|
|
1307
|
+
fieldArrayValuesRef
|
|
1308
|
+
}, commonProps), [defaultValuesRef.current, updateWatchedValue, shouldUnregister, removeFieldEventListener, watchInternal]);
|
|
1309
|
+
return Object.assign({
|
|
1310
|
+
watch,
|
|
1311
|
+
control,
|
|
1312
|
+
handleSubmit,
|
|
1313
|
+
reset: useCallback(reset, []),
|
|
1314
|
+
clearErrors: useCallback(clearErrors, []),
|
|
1315
|
+
setError: useCallback(setError, []),
|
|
1316
|
+
errors: formState.errors
|
|
1317
|
+
}, commonProps);
|
|
1318
|
+
}
|
|
1319
|
+
function __rest(s, e) {
|
|
1320
|
+
var t = {};
|
|
1321
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
1322
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1323
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
1324
|
+
}
|
|
1325
|
+
return t;
|
|
1326
|
+
}
|
|
1327
|
+
const FormContext = createContext(null);
|
|
1328
|
+
FormContext.displayName = 'RHFContext';
|
|
1329
|
+
const useFormContext = () => useContext(FormContext);
|
|
1330
|
+
var getInputValue = event => isPrimitive(event) || !isObject(event.target) || isObject(event.target) && !event.type ? event : isUndefined(event.target.value) ? event.target.checked : event.target.value;
|
|
1331
|
+
function useController({
|
|
1332
|
+
name,
|
|
1333
|
+
rules,
|
|
1334
|
+
defaultValue,
|
|
1335
|
+
control,
|
|
1336
|
+
onFocus
|
|
1337
|
+
}) {
|
|
1338
|
+
const methods = useFormContext();
|
|
1339
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1340
|
+
if (!control && !methods) {
|
|
1341
|
+
throw new Error('📋 Controller is missing `control` prop. https://react-hook-form.com/api#Controller');
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
const {
|
|
1345
|
+
defaultValuesRef,
|
|
1346
|
+
setValue,
|
|
1347
|
+
register,
|
|
1348
|
+
unregister,
|
|
1349
|
+
trigger,
|
|
1350
|
+
mode,
|
|
1351
|
+
reValidateMode: {
|
|
1352
|
+
isReValidateOnBlur,
|
|
1353
|
+
isReValidateOnChange
|
|
1354
|
+
},
|
|
1355
|
+
formState,
|
|
1356
|
+
formStateRef: {
|
|
1357
|
+
current: {
|
|
1358
|
+
isSubmitted,
|
|
1359
|
+
touched,
|
|
1360
|
+
errors
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1363
|
+
updateFormState,
|
|
1364
|
+
readFormStateRef,
|
|
1365
|
+
fieldsRef,
|
|
1366
|
+
fieldArrayNamesRef,
|
|
1367
|
+
shallowFieldsStateRef
|
|
1368
|
+
} = control || methods.control;
|
|
1369
|
+
const isNotFieldArray = !isNameInFieldArray(fieldArrayNamesRef.current, name);
|
|
1370
|
+
const getInitialValue = () => !isUndefined(get(shallowFieldsStateRef.current, name)) && isNotFieldArray ? get(shallowFieldsStateRef.current, name) : isUndefined(defaultValue) ? get(defaultValuesRef.current, name) : defaultValue;
|
|
1371
|
+
const [value, setInputStateValue] = useState(getInitialValue());
|
|
1372
|
+
const valueRef = useRef(value);
|
|
1373
|
+
const ref = useRef({
|
|
1374
|
+
focus: () => null
|
|
1375
|
+
});
|
|
1376
|
+
const onFocusRef = useRef(onFocus || (() => {
|
|
1377
|
+
if (isFunction(ref.current.focus)) {
|
|
1378
|
+
ref.current.focus();
|
|
1379
|
+
}
|
|
1380
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1381
|
+
if (!isFunction(ref.current.focus)) {
|
|
1382
|
+
console.warn(`📋 'ref' from Controller render prop must be attached to a React component or a DOM Element whose ref provides a 'focus()' method`);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}));
|
|
1386
|
+
const shouldValidate = useCallback(isBlurEvent => !skipValidation(Object.assign({
|
|
1387
|
+
isBlurEvent,
|
|
1388
|
+
isReValidateOnBlur,
|
|
1389
|
+
isReValidateOnChange,
|
|
1390
|
+
isSubmitted,
|
|
1391
|
+
isTouched: !!get(touched, name)
|
|
1392
|
+
}, mode)), [isReValidateOnBlur, isReValidateOnChange, isSubmitted, touched, name, mode]);
|
|
1393
|
+
const commonTask = useCallback(([event]) => {
|
|
1394
|
+
const data = getInputValue(event);
|
|
1395
|
+
setInputStateValue(data);
|
|
1396
|
+
valueRef.current = data;
|
|
1397
|
+
return data;
|
|
1398
|
+
}, []);
|
|
1399
|
+
const registerField = useCallback(shouldUpdateValue => {
|
|
1400
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1401
|
+
if (!name) {
|
|
1402
|
+
return console.warn('📋 Field is missing `name` prop. https://react-hook-form.com/api#Controller');
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
if (fieldsRef.current[name]) {
|
|
1406
|
+
fieldsRef.current[name] = Object.assign({
|
|
1407
|
+
ref: fieldsRef.current[name].ref
|
|
1408
|
+
}, rules);
|
|
1409
|
+
} else {
|
|
1410
|
+
register(Object.defineProperties({
|
|
1411
|
+
name,
|
|
1412
|
+
focus: onFocusRef.current
|
|
1413
|
+
}, {
|
|
1414
|
+
value: {
|
|
1415
|
+
set(data) {
|
|
1416
|
+
setInputStateValue(data);
|
|
1417
|
+
valueRef.current = data;
|
|
1418
|
+
},
|
|
1419
|
+
get() {
|
|
1420
|
+
return valueRef.current;
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
}), rules);
|
|
1424
|
+
shouldUpdateValue = isUndefined(get(defaultValuesRef.current, name));
|
|
1425
|
+
}
|
|
1426
|
+
shouldUpdateValue && isNotFieldArray && setInputStateValue(getInitialValue());
|
|
1427
|
+
}, [rules, name, register]);
|
|
1428
|
+
useEffect(() => () => unregister(name), [name]);
|
|
1429
|
+
useEffect(() => {
|
|
1430
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1431
|
+
if (isUndefined(value)) {
|
|
1432
|
+
console.warn(`📋 ${name} is missing in the 'defaultValue' prop of either its Controller (https://react-hook-form.com/api#Controller) or useForm (https://react-hook-form.com/api#useForm)`);
|
|
1433
|
+
}
|
|
1434
|
+
if (!isNotFieldArray && isUndefined(defaultValue)) {
|
|
1435
|
+
console.warn('📋 Controller is missing `defaultValue` prop when using `useFieldArray`. https://react-hook-form.com/api#Controller');
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
registerField();
|
|
1439
|
+
}, [registerField]);
|
|
1440
|
+
useEffect(() => {
|
|
1441
|
+
!fieldsRef.current[name] && registerField(true);
|
|
1442
|
+
});
|
|
1443
|
+
const onBlur = useCallback(() => {
|
|
1444
|
+
if (readFormStateRef.current.touched && !get(touched, name)) {
|
|
1445
|
+
set(touched, name, true);
|
|
1446
|
+
updateFormState({
|
|
1447
|
+
touched
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
shouldValidate(true) && trigger(name);
|
|
1451
|
+
}, [name, updateFormState, shouldValidate, trigger, readFormStateRef]);
|
|
1452
|
+
const onChange = useCallback((...event) => setValue(name, commonTask(event), {
|
|
1453
|
+
shouldValidate: shouldValidate(),
|
|
1454
|
+
shouldDirty: true
|
|
1455
|
+
}), [setValue, name, shouldValidate]);
|
|
1456
|
+
return {
|
|
1457
|
+
field: {
|
|
1458
|
+
onChange,
|
|
1459
|
+
onBlur,
|
|
1460
|
+
name,
|
|
1461
|
+
value,
|
|
1462
|
+
ref
|
|
1463
|
+
},
|
|
1464
|
+
meta: Object.defineProperties({
|
|
1465
|
+
invalid: !!get(errors, name)
|
|
1466
|
+
}, {
|
|
1467
|
+
isDirty: {
|
|
1468
|
+
get() {
|
|
1469
|
+
return !!get(formState.dirtyFields, name);
|
|
1470
|
+
}
|
|
1471
|
+
},
|
|
1472
|
+
isTouched: {
|
|
1473
|
+
get() {
|
|
1474
|
+
return !!get(formState.touched, name);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
})
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
const Controller = props => {
|
|
1481
|
+
const {
|
|
1482
|
+
rules,
|
|
1483
|
+
as,
|
|
1484
|
+
render,
|
|
1485
|
+
defaultValue,
|
|
1486
|
+
control,
|
|
1487
|
+
onFocus
|
|
1488
|
+
} = props,
|
|
1489
|
+
rest = __rest(props, ["rules", "as", "render", "defaultValue", "control", "onFocus"]);
|
|
1490
|
+
const {
|
|
1491
|
+
field,
|
|
1492
|
+
meta
|
|
1493
|
+
} = useController(props);
|
|
1494
|
+
const componentProps = Object.assign(Object.assign({}, rest), field);
|
|
1495
|
+
return as ? isValidElement(as) ? cloneElement(as, componentProps) : createElement(as, componentProps) : render ? render(field, meta) : null;
|
|
1496
|
+
};
|
|
1497
|
+
|
|
1498
|
+
const SearchApplication = ({
|
|
1499
|
+
onSearch,
|
|
1500
|
+
searchFields,
|
|
1501
|
+
searchParams
|
|
1502
|
+
}) => {
|
|
1503
|
+
const {
|
|
1504
|
+
t
|
|
1505
|
+
} = useTranslation();
|
|
1506
|
+
const {
|
|
1507
|
+
register,
|
|
1508
|
+
handleSubmit,
|
|
1509
|
+
reset,
|
|
1510
|
+
watch,
|
|
1511
|
+
control
|
|
1512
|
+
} = useForm({
|
|
1513
|
+
defaultValues: searchParams
|
|
1514
|
+
});
|
|
1515
|
+
const onSubmitInput = data => {
|
|
1516
|
+
onSearch(data);
|
|
1517
|
+
};
|
|
1518
|
+
function clearSearch() {
|
|
1519
|
+
const resetValues = searchFields.reduce((acc, field) => ({
|
|
1520
|
+
...acc,
|
|
1521
|
+
[field === null || field === void 0 ? void 0 : field.name]: ""
|
|
1522
|
+
}), {});
|
|
1523
|
+
reset(resetValues);
|
|
1524
|
+
onSearch({
|
|
1525
|
+
...resetValues
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
return /*#__PURE__*/React.createElement("form", {
|
|
1529
|
+
onSubmit: handleSubmit(onSubmitInput),
|
|
1530
|
+
className: "ekyc-search-container"
|
|
1531
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1532
|
+
className: "search-inner"
|
|
1533
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1534
|
+
className: "search-field-wrapper"
|
|
1535
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1536
|
+
className: "search-fields-container"
|
|
1537
|
+
}, searchFields === null || searchFields === void 0 ? void 0 : searchFields.map(input => /*#__PURE__*/React.createElement("div", {
|
|
1538
|
+
key: input.name,
|
|
1539
|
+
className: "search-field"
|
|
1540
|
+
}, /*#__PURE__*/React.createElement(Label, null, input.label), input.type === "dropdown" ? /*#__PURE__*/React.createElement(Controller, {
|
|
1541
|
+
control: control,
|
|
1542
|
+
name: input.name,
|
|
1543
|
+
render: props => /*#__PURE__*/React.createElement(Dropdown, {
|
|
1544
|
+
selected: props.value,
|
|
1545
|
+
select: val => {
|
|
1546
|
+
props.onChange(val);
|
|
1547
|
+
},
|
|
1548
|
+
onBlur: props.onBlur,
|
|
1549
|
+
option: input.options,
|
|
1550
|
+
optionKey: input.optionsKey,
|
|
1551
|
+
t: t
|
|
1552
|
+
})
|
|
1553
|
+
}) : /*#__PURE__*/React.createElement(TextInput, Object.assign({}, input, {
|
|
1554
|
+
inputRef: register,
|
|
1555
|
+
watch: watch
|
|
1556
|
+
}))))), /*#__PURE__*/React.createElement("div", {
|
|
1557
|
+
className: "search-action-container"
|
|
1558
|
+
}, /*#__PURE__*/React.createElement(SubmitBar, {
|
|
1559
|
+
label: t("ES_COMMON_SEARCH"),
|
|
1560
|
+
submit: true
|
|
1561
|
+
}), /*#__PURE__*/React.createElement(LinkLabel, {
|
|
1562
|
+
onClick: clearSearch
|
|
1563
|
+
}, t("ES_COMMON_CLEAR_ALL"))))));
|
|
1564
|
+
};
|
|
1565
|
+
|
|
1566
|
+
const StatusCards = ({
|
|
1567
|
+
countData
|
|
1568
|
+
}) => {
|
|
1569
|
+
const {
|
|
1570
|
+
t
|
|
1571
|
+
} = useTranslation();
|
|
1572
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1573
|
+
className: "ekyc-status-container"
|
|
1574
|
+
}, /*#__PURE__*/React.createElement(Card, {
|
|
1575
|
+
className: "ekyc-status-card"
|
|
1576
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1577
|
+
className: "count"
|
|
1578
|
+
}, (countData === null || countData === void 0 ? void 0 : countData.total) || 0), /*#__PURE__*/React.createElement("div", {
|
|
1579
|
+
className: "label"
|
|
1580
|
+
}, t("EKYC_TOTAL"))), /*#__PURE__*/React.createElement(Card, {
|
|
1581
|
+
className: "ekyc-status-card"
|
|
1582
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1583
|
+
className: "count pending"
|
|
1584
|
+
}, (countData === null || countData === void 0 ? void 0 : countData.pending) || 0), /*#__PURE__*/React.createElement("div", {
|
|
1585
|
+
className: "label"
|
|
1586
|
+
}, t("EKYC_PENDING"))), /*#__PURE__*/React.createElement(Card, {
|
|
1587
|
+
className: "ekyc-status-card"
|
|
1588
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1589
|
+
className: "count completed"
|
|
1590
|
+
}, (countData === null || countData === void 0 ? void 0 : countData.completed) || 0), /*#__PURE__*/React.createElement("div", {
|
|
1591
|
+
className: "label"
|
|
1592
|
+
}, t("EKYC_COMPLETED"))));
|
|
1593
|
+
};
|
|
1594
|
+
|
|
1595
|
+
const DesktopInbox = ({
|
|
1596
|
+
data,
|
|
1597
|
+
isLoading,
|
|
1598
|
+
onSort,
|
|
1599
|
+
onNextPage,
|
|
1600
|
+
onPrevPage,
|
|
1601
|
+
currentPage,
|
|
1602
|
+
pageSizeLimit,
|
|
1603
|
+
onPageSizeChange,
|
|
1604
|
+
parentRoute,
|
|
1605
|
+
searchParams,
|
|
1606
|
+
sortParams,
|
|
1607
|
+
totalRecords,
|
|
1608
|
+
countData,
|
|
1609
|
+
onSearch,
|
|
1610
|
+
searchFields
|
|
1611
|
+
}) => {
|
|
1612
|
+
const {
|
|
1613
|
+
t
|
|
1614
|
+
} = useTranslation();
|
|
1615
|
+
const columns = useMemo(() => [{
|
|
1616
|
+
Header: t("EKYC_APPLICATION_NO"),
|
|
1617
|
+
accessor: "applicationNumber",
|
|
1618
|
+
Cell: ({
|
|
1619
|
+
row
|
|
1620
|
+
}) => {
|
|
1621
|
+
var _row$original;
|
|
1622
|
+
const applicationNumber = ((_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original.applicationNumber) || "NA";
|
|
1623
|
+
return /*#__PURE__*/React.createElement(Link, {
|
|
1624
|
+
to: `${parentRoute}/application-details/${applicationNumber}`
|
|
1625
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1626
|
+
className: "ekyc-application-link"
|
|
1627
|
+
}, applicationNumber));
|
|
1628
|
+
}
|
|
1629
|
+
}, {
|
|
1630
|
+
Header: t("EKYC_CITIZEN_NAME"),
|
|
1631
|
+
accessor: "citizenName",
|
|
1632
|
+
Cell: ({
|
|
1633
|
+
row
|
|
1634
|
+
}) => {
|
|
1635
|
+
var _row$original2;
|
|
1636
|
+
return /*#__PURE__*/React.createElement("span", null, ((_row$original2 = row.original) === null || _row$original2 === void 0 ? void 0 : _row$original2.citizenName) || "NA");
|
|
1637
|
+
}
|
|
1638
|
+
}, {
|
|
1639
|
+
Header: t("EKYC_MOBILE_NO"),
|
|
1640
|
+
accessor: "mobileNumber",
|
|
1641
|
+
Cell: ({
|
|
1642
|
+
row
|
|
1643
|
+
}) => {
|
|
1644
|
+
var _row$original3;
|
|
1645
|
+
return /*#__PURE__*/React.createElement("span", null, ((_row$original3 = row.original) === null || _row$original3 === void 0 ? void 0 : _row$original3.mobileNumber) || "NA");
|
|
1646
|
+
}
|
|
1647
|
+
}, {
|
|
1648
|
+
Header: t("EKYC_STATUS"),
|
|
1649
|
+
accessor: "status",
|
|
1650
|
+
Cell: ({
|
|
1651
|
+
row
|
|
1652
|
+
}) => {
|
|
1653
|
+
var _row$original4;
|
|
1654
|
+
const status = ((_row$original4 = row.original) === null || _row$original4 === void 0 ? void 0 : _row$original4.status) || "DEFAULT";
|
|
1655
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
1656
|
+
className: `ekyc-status-tag ${status}`
|
|
1657
|
+
}, t(`EKYC_STATUS_${status}`));
|
|
1658
|
+
}
|
|
1659
|
+
}], [t, parentRoute]);
|
|
1660
|
+
const tableData = useMemo(() => {
|
|
1661
|
+
return (data === null || data === void 0 ? void 0 : data.items) || [];
|
|
1662
|
+
}, [data]);
|
|
1663
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1664
|
+
className: "inbox-wrapper"
|
|
1665
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1666
|
+
className: "ekyc-header-container module-header"
|
|
1667
|
+
}, /*#__PURE__*/React.createElement(Header, {
|
|
1668
|
+
className: "title"
|
|
1669
|
+
}, t("EKYC_INBOX_HEADER")), /*#__PURE__*/React.createElement(Link, {
|
|
1670
|
+
to: `${parentRoute}/create-kyc`
|
|
1671
|
+
}, /*#__PURE__*/React.createElement(SubmitBar, {
|
|
1672
|
+
label: t("EKYC_CREATE_KYC"),
|
|
1673
|
+
style: {
|
|
1674
|
+
borderRadius: "8px"
|
|
1675
|
+
}
|
|
1676
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
1677
|
+
className: "ekyc-metrics-section"
|
|
1678
|
+
}, /*#__PURE__*/React.createElement(StatusCards, {
|
|
1679
|
+
countData: countData
|
|
1680
|
+
})), /*#__PURE__*/React.createElement(Card, {
|
|
1681
|
+
className: "ekyc-search-card"
|
|
1682
|
+
}, /*#__PURE__*/React.createElement(SearchApplication, {
|
|
1683
|
+
onSearch: onSearch,
|
|
1684
|
+
searchFields: searchFields,
|
|
1685
|
+
searchParams: searchParams
|
|
1686
|
+
})), /*#__PURE__*/React.createElement(Card, {
|
|
1687
|
+
className: "ekyc-table-card"
|
|
1688
|
+
}, /*#__PURE__*/React.createElement(Table, {
|
|
1689
|
+
t: t,
|
|
1690
|
+
data: tableData,
|
|
1691
|
+
columns: columns,
|
|
1692
|
+
isLoading: isLoading,
|
|
1693
|
+
onSort: onSort,
|
|
1694
|
+
sortParams: sortParams,
|
|
1695
|
+
totalRecords: totalRecords,
|
|
1696
|
+
onNextPage: onNextPage,
|
|
1697
|
+
onPrevPage: onPrevPage,
|
|
1698
|
+
currentPage: currentPage,
|
|
1699
|
+
pageSizeLimit: pageSizeLimit,
|
|
1700
|
+
onPageSizeChange: onPageSizeChange,
|
|
1701
|
+
getCellProps: cellInfo => {
|
|
1702
|
+
return {
|
|
1703
|
+
className: "ekyc-table-cell"
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
})));
|
|
1707
|
+
};
|
|
1708
|
+
|
|
1709
|
+
const MobileInbox = ({
|
|
1710
|
+
data,
|
|
1711
|
+
isLoading,
|
|
1712
|
+
onSearch,
|
|
1713
|
+
searchFields,
|
|
1714
|
+
searchParams,
|
|
1715
|
+
parentRoute,
|
|
1716
|
+
countData
|
|
1717
|
+
}) => {
|
|
1718
|
+
var _data$items;
|
|
1719
|
+
const {
|
|
1720
|
+
t
|
|
1721
|
+
} = useTranslation();
|
|
1722
|
+
const mobileData = (data === null || data === void 0 ? void 0 : (_data$items = data.items) === null || _data$items === void 0 ? void 0 : _data$items.map(item => ({
|
|
1723
|
+
[t("EKYC_APPLICATION_NO")]: item.applicationNumber,
|
|
1724
|
+
[t("EKYC_CITIZEN_NAME")]: item.citizenName,
|
|
1725
|
+
[t("EKYC_MOBILE_NO")]: item.mobileNumber,
|
|
1726
|
+
[t("EKYC_STATUS")]: /*#__PURE__*/React.createElement("span", {
|
|
1727
|
+
className: `ekyc-status-tag ${item.status}`
|
|
1728
|
+
}, t(`EKYC_STATUS_${item.status}`))
|
|
1729
|
+
}))) || [];
|
|
1730
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1731
|
+
className: "inbox-wrapper"
|
|
1732
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1733
|
+
className: "ekyc-header-container module-header"
|
|
1734
|
+
}, /*#__PURE__*/React.createElement(Header, {
|
|
1735
|
+
className: "title"
|
|
1736
|
+
}, t("EKYC_INBOX_HEADER")), /*#__PURE__*/React.createElement(Link, {
|
|
1737
|
+
to: `${parentRoute}/create-kyc`
|
|
1738
|
+
}, /*#__PURE__*/React.createElement(SubmitBar, {
|
|
1739
|
+
label: t("EKYC_CREATE_KYC")
|
|
1740
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
1741
|
+
className: "ekyc-metrics-section"
|
|
1742
|
+
}, /*#__PURE__*/React.createElement(StatusCards, {
|
|
1743
|
+
countData: countData
|
|
1744
|
+
})), /*#__PURE__*/React.createElement(Card, {
|
|
1745
|
+
className: "ekyc-search-card"
|
|
1746
|
+
}, /*#__PURE__*/React.createElement(SearchApplication, {
|
|
1747
|
+
onSearch: onSearch,
|
|
1748
|
+
searchFields: searchFields,
|
|
1749
|
+
searchParams: searchParams
|
|
1750
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
1751
|
+
className: "mobile-data-container"
|
|
1752
|
+
}, isLoading ? /*#__PURE__*/React.createElement(Loader, null) : (mobileData === null || mobileData === void 0 ? void 0 : mobileData.length) > 0 ? /*#__PURE__*/React.createElement(DetailsCard, {
|
|
1753
|
+
data: mobileData,
|
|
1754
|
+
t: t,
|
|
1755
|
+
serviceRequestIdKey: t("EKYC_APPLICATION_NO"),
|
|
1756
|
+
linkPrefix: `${parentRoute}/application-details/`
|
|
1757
|
+
}) : /*#__PURE__*/React.createElement(Card, null, t("ES_COMMON_NO_DATA").split("\\n").map((text, index) => /*#__PURE__*/React.createElement("p", {
|
|
1758
|
+
key: index,
|
|
1759
|
+
style: {
|
|
1760
|
+
textAlign: "center"
|
|
1761
|
+
}
|
|
1762
|
+
}, text)))));
|
|
1763
|
+
};
|
|
1764
|
+
|
|
1765
|
+
const MOCK_DATA_ITEMS = [{
|
|
1766
|
+
applicationNumber: "EKYC-2024-001",
|
|
1767
|
+
citizenName: "Rahul Sharma",
|
|
1768
|
+
mobileNumber: "9876543210",
|
|
1769
|
+
status: "COMPLETED"
|
|
1770
|
+
}, {
|
|
1771
|
+
applicationNumber: "EKYC-2024-002",
|
|
1772
|
+
citizenName: "Anjali Devi",
|
|
1773
|
+
mobileNumber: "9123456789",
|
|
1774
|
+
status: "PENDING"
|
|
1775
|
+
}, {
|
|
1776
|
+
applicationNumber: "EKYC-2024-003",
|
|
1777
|
+
citizenName: "Amit Kumar",
|
|
1778
|
+
mobileNumber: "8888888888",
|
|
1779
|
+
status: "REJECTED"
|
|
1780
|
+
}, {
|
|
1781
|
+
applicationNumber: "EKYC-2024-004",
|
|
1782
|
+
citizenName: "Priya Singh",
|
|
1783
|
+
mobileNumber: "7777777777",
|
|
1784
|
+
status: "COMPLETED"
|
|
1785
|
+
}, {
|
|
1786
|
+
applicationNumber: "EKYC-2024-005",
|
|
1787
|
+
citizenName: "Suresh Gupta",
|
|
1788
|
+
mobileNumber: "6666666666",
|
|
1789
|
+
status: "PENDING"
|
|
1790
|
+
}];
|
|
1791
|
+
const Inbox = ({
|
|
1792
|
+
parentRoute,
|
|
1793
|
+
businessService: _businessService = "EKYC",
|
|
1794
|
+
initialStates: _initialStates = {},
|
|
1795
|
+
filterComponent,
|
|
1796
|
+
isInbox
|
|
1797
|
+
}) => {
|
|
1798
|
+
const tenantId = Digit.ULBService.getCurrentTenantId();
|
|
1799
|
+
const {
|
|
1800
|
+
t
|
|
1801
|
+
} = useTranslation();
|
|
1802
|
+
const [pageOffset, setPageOffset] = useState(_initialStates.pageOffset || 0);
|
|
1803
|
+
const [pageSize, setPageSize] = useState(_initialStates.pageSize || 10);
|
|
1804
|
+
const [sortParams, setSortParams] = useState(_initialStates.sortParams || [{
|
|
1805
|
+
id: "createdTime",
|
|
1806
|
+
desc: true
|
|
1807
|
+
}]);
|
|
1808
|
+
const defaultStatusOption = useMemo(() => ({
|
|
1809
|
+
label: t("EKYC_STATUS_ALL"),
|
|
1810
|
+
value: ""
|
|
1811
|
+
}), [t]);
|
|
1812
|
+
const [searchParams, setSearchParams] = useState(_initialStates.searchParams || {
|
|
1813
|
+
status: defaultStatusOption
|
|
1814
|
+
});
|
|
1815
|
+
const filteredStaticData = useMemo(() => {
|
|
1816
|
+
return MOCK_DATA_ITEMS.filter(item => {
|
|
1817
|
+
var _searchParams$status;
|
|
1818
|
+
let match = true;
|
|
1819
|
+
const currentStatus = ((_searchParams$status = searchParams.status) === null || _searchParams$status === void 0 ? void 0 : _searchParams$status.value) !== undefined ? searchParams.status.value : searchParams.status;
|
|
1820
|
+
if (currentStatus && item.status !== currentStatus) {
|
|
1821
|
+
match = false;
|
|
1822
|
+
}
|
|
1823
|
+
return match;
|
|
1824
|
+
});
|
|
1825
|
+
}, [searchParams]);
|
|
1826
|
+
const staticCountData = useMemo(() => {
|
|
1827
|
+
return {
|
|
1828
|
+
total: MOCK_DATA_ITEMS.length,
|
|
1829
|
+
completed: MOCK_DATA_ITEMS.filter(i => i.status === "COMPLETED").length,
|
|
1830
|
+
pending: MOCK_DATA_ITEMS.filter(i => i.status === "PENDING").length,
|
|
1831
|
+
rejected: MOCK_DATA_ITEMS.filter(i => i.status === "REJECTED").length
|
|
1832
|
+
};
|
|
1833
|
+
}, []);
|
|
1834
|
+
const handleSearch = useCallback(filterParam => {
|
|
1835
|
+
setSearchParams(prev => ({
|
|
1836
|
+
...prev,
|
|
1837
|
+
...filterParam
|
|
1838
|
+
}));
|
|
1839
|
+
setPageOffset(0);
|
|
1840
|
+
}, []);
|
|
1841
|
+
const fetchNextPage = () => setPageOffset(prev => prev + pageSize);
|
|
1842
|
+
const fetchPrevPage = () => setPageOffset(prev => Math.max(prev - pageSize, 0));
|
|
1843
|
+
const handlePageSizeChange = e => {
|
|
1844
|
+
const newSize = Number(e.target.value);
|
|
1845
|
+
setPageSize(newSize);
|
|
1846
|
+
setPageOffset(0);
|
|
1847
|
+
};
|
|
1848
|
+
const handleSort = useCallback(args => {
|
|
1849
|
+
if (args.length > 0) setSortParams(args);
|
|
1850
|
+
}, []);
|
|
1851
|
+
const searchFields = useMemo(() => [{
|
|
1852
|
+
label: t("EKYC_STATUS"),
|
|
1853
|
+
name: "status",
|
|
1854
|
+
type: "dropdown",
|
|
1855
|
+
options: [{
|
|
1856
|
+
label: t("CHOOSE_STATUS"),
|
|
1857
|
+
value: ""
|
|
1858
|
+
}, {
|
|
1859
|
+
label: t("EKYC_STATUS_COMPLETED"),
|
|
1860
|
+
value: "COMPLETED"
|
|
1861
|
+
}, {
|
|
1862
|
+
label: t("EKYC_STATUS_PENDING"),
|
|
1863
|
+
value: "PENDING"
|
|
1864
|
+
}, {
|
|
1865
|
+
label: t("EKYC_STATUS_REJECTED"),
|
|
1866
|
+
value: "REJECTED"
|
|
1867
|
+
}],
|
|
1868
|
+
optionsKey: "label"
|
|
1869
|
+
}], [t]);
|
|
1870
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1871
|
+
className: "ekyc-employee-container"
|
|
1872
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1873
|
+
className: "inbox-main-container"
|
|
1874
|
+
}, Digit.Utils.browser.isMobile() ? /*#__PURE__*/React.createElement(MobileInbox, {
|
|
1875
|
+
data: {
|
|
1876
|
+
items: filteredStaticData,
|
|
1877
|
+
totalCount: filteredStaticData.length
|
|
1878
|
+
},
|
|
1879
|
+
isLoading: false,
|
|
1880
|
+
onSearch: handleSearch,
|
|
1881
|
+
searchFields: searchFields,
|
|
1882
|
+
searchParams: searchParams,
|
|
1883
|
+
parentRoute: parentRoute,
|
|
1884
|
+
countData: staticCountData
|
|
1885
|
+
}) : /*#__PURE__*/React.createElement(DesktopInbox, {
|
|
1886
|
+
businessService: _businessService,
|
|
1887
|
+
data: {
|
|
1888
|
+
items: filteredStaticData,
|
|
1889
|
+
totalCount: filteredStaticData.length
|
|
1890
|
+
},
|
|
1891
|
+
isLoading: false,
|
|
1892
|
+
searchFields: searchFields,
|
|
1893
|
+
onSearch: handleSearch,
|
|
1894
|
+
onSort: handleSort,
|
|
1895
|
+
onNextPage: fetchNextPage,
|
|
1896
|
+
onPrevPage: fetchPrevPage,
|
|
1897
|
+
currentPage: Math.floor(pageOffset / pageSize),
|
|
1898
|
+
pageSizeLimit: pageSize,
|
|
1899
|
+
onPageSizeChange: handlePageSizeChange,
|
|
1900
|
+
parentRoute: parentRoute,
|
|
1901
|
+
searchParams: searchParams,
|
|
1902
|
+
sortParams: sortParams,
|
|
1903
|
+
totalRecords: filteredStaticData.length,
|
|
1904
|
+
countData: staticCountData
|
|
1905
|
+
})));
|
|
1906
|
+
};
|
|
1907
|
+
|
|
1908
|
+
const Create = () => {
|
|
1909
|
+
const {
|
|
1910
|
+
t
|
|
1911
|
+
} = useTranslation();
|
|
1912
|
+
const history = useHistory();
|
|
1913
|
+
const {
|
|
1914
|
+
path
|
|
1915
|
+
} = useRouteMatch();
|
|
1916
|
+
const [kNumber, setKNumber] = useState("");
|
|
1917
|
+
const [kName, setKName] = useState("");
|
|
1918
|
+
const handleContinue = () => {
|
|
1919
|
+
const parentPath = path.replace("/create-kyc", "");
|
|
1920
|
+
history.push(`${parentPath}/k-details`, {
|
|
1921
|
+
kNumber,
|
|
1922
|
+
kName
|
|
1923
|
+
});
|
|
1924
|
+
};
|
|
1925
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1926
|
+
className: "ekyc-employee-container"
|
|
1927
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1928
|
+
className: "ekyc-create-container",
|
|
1929
|
+
style: {
|
|
1930
|
+
padding: "24px"
|
|
1931
|
+
}
|
|
1932
|
+
}, /*#__PURE__*/React.createElement(Card, {
|
|
1933
|
+
className: "ekyc-create-card"
|
|
1934
|
+
}, /*#__PURE__*/React.createElement(CardHeader, null, t("EKYC_ENTER_DETAILS_HEADER")), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, {
|
|
1935
|
+
style: {
|
|
1936
|
+
marginBottom: "8px",
|
|
1937
|
+
fontWeight: "600"
|
|
1938
|
+
}
|
|
1939
|
+
}, t("EKYC_K_NUMBER")), /*#__PURE__*/React.createElement("div", {
|
|
1940
|
+
className: "field"
|
|
1941
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
1942
|
+
value: kNumber,
|
|
1943
|
+
onChange: e => setKNumber(e.target.value),
|
|
1944
|
+
placeholder: t("EKYC_K_NUMBER_PLACEHOLDER"),
|
|
1945
|
+
style: {
|
|
1946
|
+
borderRadius: "8px"
|
|
1947
|
+
}
|
|
1948
|
+
}))), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, {
|
|
1949
|
+
style: {
|
|
1950
|
+
marginBottom: "8px",
|
|
1951
|
+
fontWeight: "600"
|
|
1952
|
+
}
|
|
1953
|
+
}, t("EKYC_K_NAME")), /*#__PURE__*/React.createElement("div", {
|
|
1954
|
+
className: "field"
|
|
1955
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
1956
|
+
value: kName,
|
|
1957
|
+
onChange: e => setKName(e.target.value),
|
|
1958
|
+
placeholder: t("EKYC_K_NAME_PLACEHOLDER"),
|
|
1959
|
+
style: {
|
|
1960
|
+
borderRadius: "12px"
|
|
1961
|
+
}
|
|
1962
|
+
})))), /*#__PURE__*/React.createElement(ActionBar, null, /*#__PURE__*/React.createElement(SubmitBar, {
|
|
1963
|
+
label: t("ES_COMMON_CONTINUE"),
|
|
1964
|
+
onSubmit: handleContinue,
|
|
1965
|
+
style: {
|
|
1966
|
+
borderRadius: "8px"
|
|
1967
|
+
}
|
|
1968
|
+
}))));
|
|
1969
|
+
};
|
|
1970
|
+
|
|
1971
|
+
const KDetails = () => {
|
|
1972
|
+
const {
|
|
1973
|
+
t
|
|
1974
|
+
} = useTranslation();
|
|
1975
|
+
const location = useLocation();
|
|
1976
|
+
const history = useHistory();
|
|
1977
|
+
const {
|
|
1978
|
+
path
|
|
1979
|
+
} = useRouteMatch();
|
|
1980
|
+
const {
|
|
1981
|
+
kNumber,
|
|
1982
|
+
kName
|
|
1983
|
+
} = location.state || {
|
|
1984
|
+
kNumber: "EKYC-12345",
|
|
1985
|
+
kName: "Mock Name"
|
|
1986
|
+
};
|
|
1987
|
+
const [showModal, setShowModal] = useState(false);
|
|
1988
|
+
const [selectedOption, setSelectedOption] = useState({
|
|
1989
|
+
code: "SELF",
|
|
1990
|
+
name: "EKYC_SELF"
|
|
1991
|
+
});
|
|
1992
|
+
const options = [{
|
|
1993
|
+
code: "SELF",
|
|
1994
|
+
name: "EKYC_SELF"
|
|
1995
|
+
}, {
|
|
1996
|
+
code: "OTHER",
|
|
1997
|
+
name: "EKYC_OTHER"
|
|
1998
|
+
}];
|
|
1999
|
+
const connectionDetails = {
|
|
2000
|
+
consumerName: "Rahul Sharma",
|
|
2001
|
+
address: "123, Street Name, City",
|
|
2002
|
+
connectionType: "Domestic",
|
|
2003
|
+
meterNo: "MTR-987654",
|
|
2004
|
+
phoneNo: "9876543210",
|
|
2005
|
+
email: "rahul@example.com",
|
|
2006
|
+
status: "ACTIVE"
|
|
2007
|
+
};
|
|
2008
|
+
const handleStartVerification = () => {
|
|
2009
|
+
setShowModal(true);
|
|
2010
|
+
};
|
|
2011
|
+
const onModalConfirm = () => {
|
|
2012
|
+
const parentPath = path.replace("/k-details", "");
|
|
2013
|
+
history.push(`${parentPath}/aadhaar-verification`, {
|
|
2014
|
+
kNumber,
|
|
2015
|
+
selectedOption
|
|
2016
|
+
});
|
|
2017
|
+
setShowModal(false);
|
|
2018
|
+
};
|
|
2019
|
+
const handleRaiseCorrection = () => {
|
|
2020
|
+
console.log("Raise Correction clicked");
|
|
2021
|
+
};
|
|
2022
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2023
|
+
className: "ekyc-employee-container"
|
|
2024
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2025
|
+
className: "ekyc-kdetails-container",
|
|
2026
|
+
style: {
|
|
2027
|
+
padding: "24px"
|
|
2028
|
+
}
|
|
2029
|
+
}, /*#__PURE__*/React.createElement(Card, {
|
|
2030
|
+
className: "ekyc-create-card"
|
|
2031
|
+
}, /*#__PURE__*/React.createElement(CardHeader, null, t("EKYC_K_NUMBER_DETAILS")), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, {
|
|
2032
|
+
style: {
|
|
2033
|
+
marginBottom: "8px",
|
|
2034
|
+
fontWeight: "600"
|
|
2035
|
+
}
|
|
2036
|
+
}, t("EKYC_K_NUMBER")), /*#__PURE__*/React.createElement("div", {
|
|
2037
|
+
className: "field"
|
|
2038
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
2039
|
+
value: kNumber,
|
|
2040
|
+
disable: true,
|
|
2041
|
+
style: {
|
|
2042
|
+
borderRadius: "12px"
|
|
2043
|
+
}
|
|
2044
|
+
}))), /*#__PURE__*/React.createElement(CardHeader, {
|
|
2045
|
+
style: {
|
|
2046
|
+
marginTop: "24px"
|
|
2047
|
+
}
|
|
2048
|
+
}, t("EKYC_CONNECTION_DETAILS")), /*#__PURE__*/React.createElement(StatusTable, null, /*#__PURE__*/React.createElement(Row, {
|
|
2049
|
+
label: t("EKYC_CONSUMER_NAME"),
|
|
2050
|
+
text: connectionDetails.consumerName
|
|
2051
|
+
}), /*#__PURE__*/React.createElement(Row, {
|
|
2052
|
+
label: t("EKYC_ADDRESS"),
|
|
2053
|
+
text: connectionDetails.address
|
|
2054
|
+
}), /*#__PURE__*/React.createElement(Row, {
|
|
2055
|
+
label: t("EKYC_CONNECTION_TYPE"),
|
|
2056
|
+
text: connectionDetails.connectionType
|
|
2057
|
+
}), /*#__PURE__*/React.createElement(Row, {
|
|
2058
|
+
label: t("EKYC_METER_NO"),
|
|
2059
|
+
text: connectionDetails.meterNo
|
|
2060
|
+
}), /*#__PURE__*/React.createElement(Row, {
|
|
2061
|
+
label: t("EKYC_PHONE_NO"),
|
|
2062
|
+
text: connectionDetails.phoneNo
|
|
2063
|
+
}), /*#__PURE__*/React.createElement(Row, {
|
|
2064
|
+
label: t("EKYC_EMAIL"),
|
|
2065
|
+
text: connectionDetails.email
|
|
2066
|
+
}), /*#__PURE__*/React.createElement(Row, {
|
|
2067
|
+
label: t("EKYC_STATUS"),
|
|
2068
|
+
text: connectionDetails.status
|
|
2069
|
+
})))), /*#__PURE__*/React.createElement(ActionBar, null, /*#__PURE__*/React.createElement(SubmitBar, {
|
|
2070
|
+
label: t("EKYC_START_VERIFICATION"),
|
|
2071
|
+
onSubmit: handleStartVerification,
|
|
2072
|
+
style: {
|
|
2073
|
+
borderRadius: "12px"
|
|
2074
|
+
}
|
|
2075
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
2076
|
+
className: "submit-bar",
|
|
2077
|
+
style: {
|
|
2078
|
+
marginLeft: "10px",
|
|
2079
|
+
background: "#f47738",
|
|
2080
|
+
border: "none",
|
|
2081
|
+
color: "#fff",
|
|
2082
|
+
padding: "10px 24px",
|
|
2083
|
+
borderRadius: "12px",
|
|
2084
|
+
fontWeight: "600",
|
|
2085
|
+
cursor: "pointer",
|
|
2086
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.1)"
|
|
2087
|
+
},
|
|
2088
|
+
onClick: handleRaiseCorrection
|
|
2089
|
+
}, t("EKYC_RAISE_CORRECTION"))), showModal && /*#__PURE__*/React.createElement(Modal, {
|
|
2090
|
+
headerBarMain: t("EKYC_SELECT_VERIFICATION_TYPE"),
|
|
2091
|
+
headerBarEnd: /*#__PURE__*/React.createElement("span", {
|
|
2092
|
+
onClick: () => setShowModal(false),
|
|
2093
|
+
style: {
|
|
2094
|
+
cursor: "pointer",
|
|
2095
|
+
padding: "8px"
|
|
2096
|
+
}
|
|
2097
|
+
}, "X"),
|
|
2098
|
+
actionSaveLabel: t("ES_COMMON_CONFIRM"),
|
|
2099
|
+
actionSaveOnSubmit: onModalConfirm,
|
|
2100
|
+
actionCancelLabel: t("ES_COMMON_CANCEL"),
|
|
2101
|
+
actionCancelOnSubmit: () => setShowModal(false),
|
|
2102
|
+
style: {
|
|
2103
|
+
borderRadius: "12px"
|
|
2104
|
+
}
|
|
2105
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2106
|
+
style: {
|
|
2107
|
+
padding: "24px"
|
|
2108
|
+
}
|
|
2109
|
+
}, /*#__PURE__*/React.createElement(RadioButtons, {
|
|
2110
|
+
options: options,
|
|
2111
|
+
optionsKey: "name",
|
|
2112
|
+
selectedOption: selectedOption,
|
|
2113
|
+
onSelect: setSelectedOption,
|
|
2114
|
+
t: t
|
|
2115
|
+
}))));
|
|
2116
|
+
};
|
|
2117
|
+
|
|
2118
|
+
const AadhaarVerification = () => {
|
|
2119
|
+
const {
|
|
2120
|
+
t
|
|
2121
|
+
} = useTranslation();
|
|
2122
|
+
const location = useLocation();
|
|
2123
|
+
const history = useHistory();
|
|
2124
|
+
const [aadhaarLastFour, setAadhaarLastFour] = useState("");
|
|
2125
|
+
const [isAadhaarVerified, setIsAadhaarVerified] = useState(false);
|
|
2126
|
+
const [nameCorrect, setNameCorrect] = useState({
|
|
2127
|
+
code: "NO",
|
|
2128
|
+
name: "CORE_COMMON_NO"
|
|
2129
|
+
});
|
|
2130
|
+
const [userName, setUserName] = useState("");
|
|
2131
|
+
const [mobileChange, setMobileChange] = useState({
|
|
2132
|
+
code: "NO",
|
|
2133
|
+
name: "CORE_COMMON_NO"
|
|
2134
|
+
});
|
|
2135
|
+
const [mobileNumber, setMobileNumber] = useState("");
|
|
2136
|
+
const [whatsappNumber, setWhatsappNumber] = useState("");
|
|
2137
|
+
const [email, setEmail] = useState("");
|
|
2138
|
+
const [noOfPersons, setNoOfPersons] = useState("");
|
|
2139
|
+
const yesNoOptions = [{
|
|
2140
|
+
code: "YES",
|
|
2141
|
+
name: "CORE_COMMON_YES"
|
|
2142
|
+
}, {
|
|
2143
|
+
code: "NO",
|
|
2144
|
+
name: "CORE_COMMON_NO"
|
|
2145
|
+
}];
|
|
2146
|
+
const handleVerifyAadhaar = () => {
|
|
2147
|
+
if (aadhaarLastFour.length === 4) {
|
|
2148
|
+
setIsAadhaarVerified(true);
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2151
|
+
const handleSaveAndContinue = () => {
|
|
2152
|
+
history.push("/digit-ui/employee/ekyc/address-details");
|
|
2153
|
+
};
|
|
2154
|
+
const FingerprintIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
2155
|
+
width: "24",
|
|
2156
|
+
height: "24",
|
|
2157
|
+
viewBox: "0 0 24 24",
|
|
2158
|
+
fill: "none",
|
|
2159
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
2160
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
2161
|
+
d: "M17.81 4.47c-.08 0-.16-.02-.23-.06C15.66 3.42 14 3 12.01 3c-1.98 0-3.86.47-5.57 1.41-.24.13-.54.04-.67-.2-.13-.24-.04-.55.2-.68C7.82 2.52 9.86 2 12.01 2c2.13 0 3.96.46 5.57 1.41.24.13.33.43.2.67-.09.13-.24.39-.39.39zM12 21c-.28 0-.5-.22-.5-.5v-4.42c-2.33-.21-4.44-1.35-5.94-3.21-1.5-1.86-2.22-4.18-2.02-6.52.05-.59.55-1.03 1.14-.98s1.03.55.98 1.14c-.15 1.76.39 3.51 1.52 4.91 1.12 1.4 2.7 2.26 4.45 2.42.21.02.37.19.37.4v6.26c0 .28-.22.5-.5.5zm4.83-9.17c-.59.05-1.03-.55-.98-1.14.39-4.59-2.03-8.86-6.17-10.87-.25-.12-.35-.43-.23-.68s.42-.36.67-.24c4.61 2.24 7.31 7 6.87 12.1-.05.27-.27.48-.54.5v.33z",
|
|
2162
|
+
fill: "#505A5F"
|
|
2163
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
2164
|
+
d: "M12 11c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-5.17-3.66c-.15 1.76.39 3.51 1.52 4.91 1.13 1.4 2.71 2.26 4.45 2.42.06 0 .11.01.17.01.24 0 .44-.17.48-.41.04-.27-.14-.53-.41-.58-1.46-.14-2.77-.85-3.71-2.01-.94-1.17-1.39-2.63-1.27-4.11.02-.28-.19-.51-.47-.53-.28-.02-.53.18-.55.46-.01.28.01.55.21.84z",
|
|
2165
|
+
fill: "#505A5F"
|
|
2166
|
+
}));
|
|
2167
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2168
|
+
className: "ekyc-employee-container"
|
|
2169
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2170
|
+
className: "ekyc-aadhaar-verification-container",
|
|
2171
|
+
style: {
|
|
2172
|
+
padding: "24px"
|
|
2173
|
+
}
|
|
2174
|
+
}, /*#__PURE__*/React.createElement(Card, {
|
|
2175
|
+
className: "ekyc-create-card"
|
|
2176
|
+
}, /*#__PURE__*/React.createElement(CardHeader, null, t("EKYC_AADHAAR_NUMBER_HEADER") || "Aadhaar Number"), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, {
|
|
2177
|
+
style: {
|
|
2178
|
+
marginBottom: "8px",
|
|
2179
|
+
fontWeight: "600"
|
|
2180
|
+
}
|
|
2181
|
+
}, t("EKYC_LAST_4_DIGIT_AADHAAR") || "Last 4-Digit Aadhaar Number"), /*#__PURE__*/React.createElement("div", {
|
|
2182
|
+
className: "field",
|
|
2183
|
+
style: {
|
|
2184
|
+
position: "relative"
|
|
2185
|
+
}
|
|
2186
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
2187
|
+
value: aadhaarLastFour,
|
|
2188
|
+
onChange: e => {
|
|
2189
|
+
const val = e.target.value;
|
|
2190
|
+
if (val.length <= 4 && /^\d*$/.test(val)) {
|
|
2191
|
+
setAadhaarLastFour(val);
|
|
2192
|
+
}
|
|
2193
|
+
},
|
|
2194
|
+
placeholder: t("EKYC_ENTER_LAST_4_DIGIT") || "Enter Last 4-digit Aadhaar number",
|
|
2195
|
+
textInputStyle: {
|
|
2196
|
+
paddingLeft: "40px",
|
|
2197
|
+
borderRadius: "12px"
|
|
2198
|
+
},
|
|
2199
|
+
style: {
|
|
2200
|
+
borderRadius: "12px"
|
|
2201
|
+
}
|
|
2202
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
2203
|
+
style: {
|
|
2204
|
+
position: "absolute",
|
|
2205
|
+
left: "10px",
|
|
2206
|
+
top: "50%",
|
|
2207
|
+
transform: "translateY(-50%)"
|
|
2208
|
+
}
|
|
2209
|
+
}, /*#__PURE__*/React.createElement(FingerprintIcon, null)), isAadhaarVerified && /*#__PURE__*/React.createElement("div", {
|
|
2210
|
+
style: {
|
|
2211
|
+
position: "absolute",
|
|
2212
|
+
right: "10px",
|
|
2213
|
+
top: "50%",
|
|
2214
|
+
transform: "translateY(-50%)"
|
|
2215
|
+
}
|
|
2216
|
+
}, /*#__PURE__*/React.createElement(TickMark, {
|
|
2217
|
+
fillColor: "#00703C"
|
|
2218
|
+
})))), !isAadhaarVerified && /*#__PURE__*/React.createElement(SubmitBar, {
|
|
2219
|
+
label: t("EKYC_VERIFY_AADHAAR_BTN") || "Verify Aadhaar",
|
|
2220
|
+
onSubmit: handleVerifyAadhaar,
|
|
2221
|
+
style: {
|
|
2222
|
+
borderRadius: "12px"
|
|
2223
|
+
}
|
|
2224
|
+
}), isAadhaarVerified && /*#__PURE__*/React.createElement("div", {
|
|
2225
|
+
style: {
|
|
2226
|
+
backgroundColor: "#E7F4EE",
|
|
2227
|
+
padding: "20px",
|
|
2228
|
+
borderRadius: "12px",
|
|
2229
|
+
marginTop: "16px",
|
|
2230
|
+
marginBottom: "24px",
|
|
2231
|
+
border: "1px solid #D1E9DB"
|
|
2232
|
+
}
|
|
2233
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2234
|
+
style: {
|
|
2235
|
+
display: "flex",
|
|
2236
|
+
alignItems: "center",
|
|
2237
|
+
gap: "10px",
|
|
2238
|
+
marginBottom: "16px"
|
|
2239
|
+
}
|
|
2240
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2241
|
+
style: {
|
|
2242
|
+
backgroundColor: "#D1E9DB",
|
|
2243
|
+
padding: "4px",
|
|
2244
|
+
borderRadius: "50%",
|
|
2245
|
+
display: "flex"
|
|
2246
|
+
}
|
|
2247
|
+
}, /*#__PURE__*/React.createElement(TickMark, {
|
|
2248
|
+
fillColor: "#00703C"
|
|
2249
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
2250
|
+
style: {
|
|
2251
|
+
fontWeight: "700",
|
|
2252
|
+
color: "#00703C",
|
|
2253
|
+
fontSize: "18px"
|
|
2254
|
+
}
|
|
2255
|
+
}, t("EKYC_AADHAAR_VERIFIED") || "Aadhaar Verified")), /*#__PURE__*/React.createElement("div", {
|
|
2256
|
+
style: {
|
|
2257
|
+
display: "flex",
|
|
2258
|
+
flexDirection: "column",
|
|
2259
|
+
gap: "12px"
|
|
2260
|
+
}
|
|
2261
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2262
|
+
style: {
|
|
2263
|
+
display: "flex",
|
|
2264
|
+
flexDirection: "column"
|
|
2265
|
+
}
|
|
2266
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
2267
|
+
style: {
|
|
2268
|
+
color: "#667085",
|
|
2269
|
+
fontSize: "14px",
|
|
2270
|
+
fontWeight: "500"
|
|
2271
|
+
}
|
|
2272
|
+
}, t("EKYC_NAME") || "Name"), /*#__PURE__*/React.createElement("span", {
|
|
2273
|
+
style: {
|
|
2274
|
+
fontWeight: "700",
|
|
2275
|
+
fontSize: "16px",
|
|
2276
|
+
color: "#101828"
|
|
2277
|
+
}
|
|
2278
|
+
}, "Rajesh Kumar Singh")), /*#__PURE__*/React.createElement("div", {
|
|
2279
|
+
style: {
|
|
2280
|
+
display: "flex",
|
|
2281
|
+
flexDirection: "column"
|
|
2282
|
+
}
|
|
2283
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
2284
|
+
style: {
|
|
2285
|
+
color: "#667085",
|
|
2286
|
+
fontSize: "14px",
|
|
2287
|
+
fontWeight: "500"
|
|
2288
|
+
}
|
|
2289
|
+
}, t("EKYC_ADDRESS") || "Address"), /*#__PURE__*/React.createElement("span", {
|
|
2290
|
+
style: {
|
|
2291
|
+
fontWeight: "400",
|
|
2292
|
+
fontSize: "16px",
|
|
2293
|
+
color: "#344054"
|
|
2294
|
+
}
|
|
2295
|
+
}, "House No. 45, Sector 12, New Delhi - 110001")))), /*#__PURE__*/React.createElement(CardHeader, {
|
|
2296
|
+
style: {
|
|
2297
|
+
marginTop: "24px"
|
|
2298
|
+
}
|
|
2299
|
+
}, t("EKYC_CONTACT_DETAILS_HEADER") || "Contact Details"), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, {
|
|
2300
|
+
style: {
|
|
2301
|
+
marginBottom: "8px",
|
|
2302
|
+
fontWeight: "600"
|
|
2303
|
+
}
|
|
2304
|
+
}, t("EKYC_NAME_CORRECTION_PROMPT") || "Do you want to correct the Name?"), /*#__PURE__*/React.createElement(RadioButtons, {
|
|
2305
|
+
options: yesNoOptions,
|
|
2306
|
+
optionsKey: "name",
|
|
2307
|
+
selectedOption: nameCorrect,
|
|
2308
|
+
onSelect: setNameCorrect,
|
|
2309
|
+
t: t,
|
|
2310
|
+
innerStyles: {
|
|
2311
|
+
display: "flex",
|
|
2312
|
+
gap: "24px",
|
|
2313
|
+
marginTop: "8px"
|
|
2314
|
+
}
|
|
2315
|
+
})), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, {
|
|
2316
|
+
style: {
|
|
2317
|
+
marginBottom: "8px",
|
|
2318
|
+
fontWeight: "600"
|
|
2319
|
+
}
|
|
2320
|
+
}, t("EKYC_ENTER_NAME") || "Enter Name"), /*#__PURE__*/React.createElement("div", {
|
|
2321
|
+
className: "field"
|
|
2322
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
2323
|
+
value: userName,
|
|
2324
|
+
onChange: e => setUserName(e.target.value),
|
|
2325
|
+
placeholder: t("EKYC_ENTER_NAME_PLACEHOLDER") || "Enter Enter name",
|
|
2326
|
+
style: {
|
|
2327
|
+
borderRadius: "12px"
|
|
2328
|
+
}
|
|
2329
|
+
}))), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, {
|
|
2330
|
+
style: {
|
|
2331
|
+
marginBottom: "8px",
|
|
2332
|
+
fontWeight: "600"
|
|
2333
|
+
}
|
|
2334
|
+
}, t("EKYC_MOBILE_CHANGE_PROMPT") || "Change your mobile number?"), /*#__PURE__*/React.createElement(RadioButtons, {
|
|
2335
|
+
options: yesNoOptions,
|
|
2336
|
+
optionsKey: "name",
|
|
2337
|
+
selectedOption: mobileChange,
|
|
2338
|
+
onSelect: setMobileChange,
|
|
2339
|
+
t: t,
|
|
2340
|
+
innerStyles: {
|
|
2341
|
+
display: "flex",
|
|
2342
|
+
gap: "24px",
|
|
2343
|
+
marginTop: "8px"
|
|
2344
|
+
}
|
|
2345
|
+
})), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, {
|
|
2346
|
+
style: {
|
|
2347
|
+
marginBottom: "8px",
|
|
2348
|
+
fontWeight: "600"
|
|
2349
|
+
}
|
|
2350
|
+
}, t("EKYC_MOBILE_NUMBER") || "Mobile Number"), /*#__PURE__*/React.createElement("div", {
|
|
2351
|
+
className: "field"
|
|
2352
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
2353
|
+
value: mobileNumber,
|
|
2354
|
+
onChange: e => setMobileNumber(e.target.value),
|
|
2355
|
+
placeholder: t("EKYC_ENTER_MOBILE_NUMBER") || "Enter Mobile number",
|
|
2356
|
+
style: {
|
|
2357
|
+
borderRadius: "12px"
|
|
2358
|
+
}
|
|
2359
|
+
}))), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, {
|
|
2360
|
+
style: {
|
|
2361
|
+
marginBottom: "8px",
|
|
2362
|
+
fontWeight: "600"
|
|
2363
|
+
}
|
|
2364
|
+
}, t("EKYC_WHATSAPP_NUMBER") || "Whatsapp Number"), /*#__PURE__*/React.createElement("div", {
|
|
2365
|
+
className: "field"
|
|
2366
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
2367
|
+
value: whatsappNumber,
|
|
2368
|
+
onChange: e => setWhatsappNumber(e.target.value),
|
|
2369
|
+
placeholder: t("EKYC_ENTER_WHATSAPP_NUMBER") || "Enter Whatsapp Number",
|
|
2370
|
+
style: {
|
|
2371
|
+
borderRadius: "12px"
|
|
2372
|
+
}
|
|
2373
|
+
}))), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, {
|
|
2374
|
+
style: {
|
|
2375
|
+
marginBottom: "8px",
|
|
2376
|
+
fontWeight: "600"
|
|
2377
|
+
}
|
|
2378
|
+
}, t("EKYC_EMAIL_ADDRESS") || "Email address (Optional)"), /*#__PURE__*/React.createElement("div", {
|
|
2379
|
+
className: "field"
|
|
2380
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
2381
|
+
value: email,
|
|
2382
|
+
onChange: e => setEmail(e.target.value),
|
|
2383
|
+
placeholder: t("EKYC_EMAIL_ADDRESS_PLACEHOLDER") || "Email address",
|
|
2384
|
+
style: {
|
|
2385
|
+
borderRadius: "12px"
|
|
2386
|
+
}
|
|
2387
|
+
}))), /*#__PURE__*/React.createElement(CardHeader, {
|
|
2388
|
+
style: {
|
|
2389
|
+
marginTop: "24px"
|
|
2390
|
+
}
|
|
2391
|
+
}, t("EKYC_FAMILY_DETAILS_HEADER") || "Family Details"), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, {
|
|
2392
|
+
style: {
|
|
2393
|
+
marginBottom: "8px",
|
|
2394
|
+
fontWeight: "600"
|
|
2395
|
+
}
|
|
2396
|
+
}, t("EKYC_NO_OF_PERSONS") || "No Of Persons"), /*#__PURE__*/React.createElement("div", {
|
|
2397
|
+
className: "field"
|
|
2398
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
2399
|
+
value: noOfPersons,
|
|
2400
|
+
onChange: e => setNoOfPersons(e.target.value),
|
|
2401
|
+
placeholder: t("EKYC_ENTER_NO_OF_PERSONS") || "Enter No of Persons",
|
|
2402
|
+
style: {
|
|
2403
|
+
borderRadius: "12px"
|
|
2404
|
+
}
|
|
2405
|
+
}))))), /*#__PURE__*/React.createElement(ActionBar, null, /*#__PURE__*/React.createElement(SubmitBar, {
|
|
2406
|
+
label: t("ES_COMMON_SAVE_CONTINUE") || "Save & Continue",
|
|
2407
|
+
onSubmit: handleSaveAndContinue,
|
|
2408
|
+
style: {
|
|
2409
|
+
borderRadius: "12px"
|
|
2410
|
+
}
|
|
2411
|
+
})));
|
|
2412
|
+
};
|
|
2413
|
+
|
|
2414
|
+
const AddressDetails = () => {
|
|
2415
|
+
const {
|
|
2416
|
+
t
|
|
2417
|
+
} = useTranslation();
|
|
2418
|
+
const history = useHistory();
|
|
2419
|
+
const [addressType, setAddressType] = useState({
|
|
2420
|
+
code: "AADHAAR",
|
|
2421
|
+
name: "EKYC_AADHAAR_ADDRESS"
|
|
2422
|
+
});
|
|
2423
|
+
const [correctAddress, setCorrectAddress] = useState({
|
|
2424
|
+
code: "NO",
|
|
2425
|
+
name: "CORE_COMMON_NO"
|
|
2426
|
+
});
|
|
2427
|
+
const [fullAddress, setFullAddress] = useState("");
|
|
2428
|
+
const [flatNo, setFlatNo] = useState("");
|
|
2429
|
+
const [building, setBuilding] = useState("");
|
|
2430
|
+
const [landmark, setLandmark] = useState("");
|
|
2431
|
+
const [pincode, setPincode] = useState("");
|
|
2432
|
+
const addressOptions = [{
|
|
2433
|
+
code: "AADHAAR",
|
|
2434
|
+
name: "EKYC_AADHAAR_ADDRESS"
|
|
2435
|
+
}, {
|
|
2436
|
+
code: "OLD",
|
|
2437
|
+
name: "EKYC_OLD_ADDRESS"
|
|
2438
|
+
}];
|
|
2439
|
+
const yesNoOptions = [{
|
|
2440
|
+
code: "YES",
|
|
2441
|
+
name: "CORE_COMMON_YES"
|
|
2442
|
+
}, {
|
|
2443
|
+
code: "NO",
|
|
2444
|
+
name: "CORE_COMMON_NO"
|
|
2445
|
+
}];
|
|
2446
|
+
const handleCompleteVerification = () => {
|
|
2447
|
+
console.log("Verification Completed");
|
|
2448
|
+
};
|
|
2449
|
+
const FlagIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
2450
|
+
width: "24",
|
|
2451
|
+
height: "24",
|
|
2452
|
+
viewBox: "0 0 24 24",
|
|
2453
|
+
fill: "none",
|
|
2454
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
2455
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
2456
|
+
d: "M14.4 6L13.6 4H5V21H7V14H12.6L13.4 16H20V6H14.4Z",
|
|
2457
|
+
fill: "#00703C"
|
|
2458
|
+
}));
|
|
2459
|
+
const IdCardIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
2460
|
+
width: "24",
|
|
2461
|
+
height: "24",
|
|
2462
|
+
viewBox: "0 0 24 24",
|
|
2463
|
+
fill: "none",
|
|
2464
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
2465
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
2466
|
+
d: "M2 7V17C2 18.1 2.9 19 4 19H20C21.1 19 22 18.1 22 17V7C22 5.9 21.1 5 20 5H4C2.9 5 2 5.9 2 7ZM12 11H14V13H12V11ZM12 7H14V9H12V7ZM16 11H20V13H16V11ZM16 7H20V9H16V7ZM4 7H10V15H4V7ZM20 17H4V16H20V17Z",
|
|
2467
|
+
fill: "#3D51B0"
|
|
2468
|
+
}));
|
|
2469
|
+
const CameraIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
2470
|
+
width: "32",
|
|
2471
|
+
height: "32",
|
|
2472
|
+
viewBox: "0 0 24 24",
|
|
2473
|
+
fill: "none",
|
|
2474
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
2475
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
2476
|
+
d: "M9 2L7.17 4H4C2.9 4 2 4.9 2 6V18C2 19.1 2.9 20 4 20H20C21.1 20 22 19.1 22 18V6C22 4.9 21.1 4 20 4H16.83L15 2H9ZM12 17C9.24 17 7 14.76 7 12C7 9.24 9.24 7 12 7C14.76 7 17 9.24 17 12C17 14.76 14.76 17 12 17ZM12 9C10.34 9 9 10.34 9 12C9 13.66 10.34 15 12 15C13.66 15 15 13.66 15 12C15 10.34 13.66 9 12 9Z",
|
|
2477
|
+
fill: "#3D51B0"
|
|
2478
|
+
}));
|
|
2479
|
+
const TargetIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
2480
|
+
width: "24",
|
|
2481
|
+
height: "24",
|
|
2482
|
+
viewBox: "0 0 24 24",
|
|
2483
|
+
fill: "none",
|
|
2484
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
2485
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
2486
|
+
d: "M12 8C9.79 8 8 9.79 8 12C8 14.21 9.79 16 12 16C14.21 16 16 14.21 16 12C16 9.79 14.21 8 12 8ZM20.94 11C20.48 6.83 17.17 3.52 13 3.06V1H11V3.06C6.83 3.52 3.52 6.83 3.06 11H1V13H3.06C3.52 17.17 6.83 20.48 11 20.94V23H13V20.94C17.17 20.48 20.48 17.17 20.94 13H23V11H20.94ZM12 19C8.13 19 5 15.87 5 12C5 8.13 8.13 5 12 5C15.87 5 19 8.13 19 12C19 15.87 15.87 19 12 19Z",
|
|
2487
|
+
fill: "#3D51B0"
|
|
2488
|
+
}));
|
|
2489
|
+
const PincodeIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
2490
|
+
width: "24",
|
|
2491
|
+
height: "24",
|
|
2492
|
+
viewBox: "0 0 24 24",
|
|
2493
|
+
fill: "none",
|
|
2494
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
2495
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
2496
|
+
d: "M13 13V11H15V13H13ZM13 9V7H15V9H13ZM17 13V11H19V13H17ZM17 9V7H19V9H17ZM11 13V11H9V13H11ZM11 9V7H9V9H11ZM7 13V11H5V13H7ZM7 9V7H5V9H7ZM21 3H3C1.9 3 1 3.9 1 5V19C1 20.1 1.9 21 3 21H21C22.1 21 23 20.1 23 19V5C23 3.9 22.1 3 21 3ZM21 19H3V5H21V19Z",
|
|
2497
|
+
fill: "#3D51B0"
|
|
2498
|
+
}));
|
|
2499
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2500
|
+
className: "ekyc-address-details-container"
|
|
2501
|
+
}, /*#__PURE__*/React.createElement(Header, null, t("EKYC_ADDRESS_DETAILS_HEADER") || "Address Details"), /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement("div", {
|
|
2502
|
+
style: {
|
|
2503
|
+
display: "flex",
|
|
2504
|
+
justifyContent: "space-between",
|
|
2505
|
+
marginBottom: "20px"
|
|
2506
|
+
}
|
|
2507
|
+
}, /*#__PURE__*/React.createElement(RadioButtons, {
|
|
2508
|
+
options: addressOptions,
|
|
2509
|
+
optionsKey: "name",
|
|
2510
|
+
selectedOption: addressType,
|
|
2511
|
+
onSelect: setAddressType,
|
|
2512
|
+
t: t,
|
|
2513
|
+
innerStyles: {
|
|
2514
|
+
display: "flex",
|
|
2515
|
+
gap: "10px",
|
|
2516
|
+
width: "100%"
|
|
2517
|
+
},
|
|
2518
|
+
style: {
|
|
2519
|
+
width: "48%"
|
|
2520
|
+
}
|
|
2521
|
+
})), addressType.code === "AADHAAR" && /*#__PURE__*/React.createElement("div", {
|
|
2522
|
+
style: {
|
|
2523
|
+
backgroundColor: "#E7F4EE",
|
|
2524
|
+
padding: "16px",
|
|
2525
|
+
borderRadius: "8px",
|
|
2526
|
+
marginBottom: "24px",
|
|
2527
|
+
border: "1px solid #C4E1D1"
|
|
2528
|
+
}
|
|
2529
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2530
|
+
style: {
|
|
2531
|
+
fontSize: "16px",
|
|
2532
|
+
lineHeight: "1.5"
|
|
2533
|
+
}
|
|
2534
|
+
}, "H.No. 123, Sector 15, Rohini", /*#__PURE__*/React.createElement("br", null), "Delhi - 110085")), addressType.code === "OLD" && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("EKYC_ADDRESS_CORRECTION_PROMPT") || "Do you want to correct the address?"), /*#__PURE__*/React.createElement(RadioButtons, {
|
|
2535
|
+
options: yesNoOptions,
|
|
2536
|
+
optionsKey: "name",
|
|
2537
|
+
selectedOption: correctAddress,
|
|
2538
|
+
onSelect: setCorrectAddress,
|
|
2539
|
+
t: t,
|
|
2540
|
+
innerStyles: {
|
|
2541
|
+
display: "flex",
|
|
2542
|
+
gap: "20px"
|
|
2543
|
+
}
|
|
2544
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
2545
|
+
style: {
|
|
2546
|
+
border: "1px solid #E0E0E0",
|
|
2547
|
+
borderRadius: "8px",
|
|
2548
|
+
padding: "12px",
|
|
2549
|
+
display: "flex",
|
|
2550
|
+
alignItems: "center",
|
|
2551
|
+
justifyContent: "space-between",
|
|
2552
|
+
marginBottom: "20px",
|
|
2553
|
+
cursor: "pointer"
|
|
2554
|
+
}
|
|
2555
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2556
|
+
style: {
|
|
2557
|
+
display: "flex",
|
|
2558
|
+
alignItems: "center",
|
|
2559
|
+
gap: "12px"
|
|
2560
|
+
}
|
|
2561
|
+
}, /*#__PURE__*/React.createElement(TargetIcon, null), /*#__PURE__*/React.createElement("span", {
|
|
2562
|
+
style: {
|
|
2563
|
+
fontWeight: "bold"
|
|
2564
|
+
}
|
|
2565
|
+
}, t("EKYC_USE_CURRENT_LOCATION") || "Use Current Location")), /*#__PURE__*/React.createElement("span", {
|
|
2566
|
+
style: {
|
|
2567
|
+
fontSize: "20px"
|
|
2568
|
+
}
|
|
2569
|
+
}, "\u203A")), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("EKYC_FULL_ADDRESS") || "Full Address"), /*#__PURE__*/React.createElement("div", {
|
|
2570
|
+
className: "field",
|
|
2571
|
+
style: {
|
|
2572
|
+
position: "relative"
|
|
2573
|
+
}
|
|
2574
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
2575
|
+
value: fullAddress,
|
|
2576
|
+
onChange: e => setFullAddress(e.target.value),
|
|
2577
|
+
placeholder: t("EKYC_ENTER_FULL_ADDRESS") || "Enter Full Address",
|
|
2578
|
+
textInputStyle: {
|
|
2579
|
+
paddingLeft: "40px",
|
|
2580
|
+
height: "80px"
|
|
2581
|
+
}
|
|
2582
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
2583
|
+
style: {
|
|
2584
|
+
position: "absolute",
|
|
2585
|
+
left: "10px",
|
|
2586
|
+
top: "20px"
|
|
2587
|
+
}
|
|
2588
|
+
}, /*#__PURE__*/React.createElement(PropertyHouse, {
|
|
2589
|
+
styles: {
|
|
2590
|
+
fill: "#3D51B0"
|
|
2591
|
+
}
|
|
2592
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
|
2593
|
+
style: {
|
|
2594
|
+
display: "flex",
|
|
2595
|
+
gap: "16px"
|
|
2596
|
+
}
|
|
2597
|
+
}, /*#__PURE__*/React.createElement(LabelFieldPair, {
|
|
2598
|
+
style: {
|
|
2599
|
+
flex: 1
|
|
2600
|
+
}
|
|
2601
|
+
}, /*#__PURE__*/React.createElement(CardLabel, null, t("EKYC_FLAT_HOUSE_NUMBER") || "Flat/House Number"), /*#__PURE__*/React.createElement("div", {
|
|
2602
|
+
className: "field",
|
|
2603
|
+
style: {
|
|
2604
|
+
position: "relative"
|
|
2605
|
+
}
|
|
2606
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
2607
|
+
value: flatNo,
|
|
2608
|
+
onChange: e => setFlatNo(e.target.value),
|
|
2609
|
+
placeholder: t("EKYC_ENTER_FLAT_NO") || "Enter Flat/...",
|
|
2610
|
+
textInputStyle: {
|
|
2611
|
+
paddingLeft: "40px"
|
|
2612
|
+
}
|
|
2613
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
2614
|
+
style: {
|
|
2615
|
+
position: "absolute",
|
|
2616
|
+
left: "10px",
|
|
2617
|
+
top: "50%",
|
|
2618
|
+
transform: "translateY(-50%)"
|
|
2619
|
+
}
|
|
2620
|
+
}, /*#__PURE__*/React.createElement(PropertyHouse, {
|
|
2621
|
+
styles: {
|
|
2622
|
+
fill: "#3D51B0",
|
|
2623
|
+
width: "20px",
|
|
2624
|
+
height: "20px"
|
|
2625
|
+
}
|
|
2626
|
+
})))), /*#__PURE__*/React.createElement(LabelFieldPair, {
|
|
2627
|
+
style: {
|
|
2628
|
+
flex: 1
|
|
2629
|
+
}
|
|
2630
|
+
}, /*#__PURE__*/React.createElement(CardLabel, null, t("EKYC_BUILDING_TOWER") || "Building/Tower"), /*#__PURE__*/React.createElement("div", {
|
|
2631
|
+
className: "field",
|
|
2632
|
+
style: {
|
|
2633
|
+
position: "relative"
|
|
2634
|
+
}
|
|
2635
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
2636
|
+
value: building,
|
|
2637
|
+
onChange: e => setBuilding(e.target.value),
|
|
2638
|
+
placeholder: t("EKYC_ENTER_BUILDING") || "Enter Build...",
|
|
2639
|
+
textInputStyle: {
|
|
2640
|
+
paddingLeft: "40px"
|
|
2641
|
+
}
|
|
2642
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
2643
|
+
style: {
|
|
2644
|
+
position: "absolute",
|
|
2645
|
+
left: "10px",
|
|
2646
|
+
top: "50%",
|
|
2647
|
+
transform: "translateY(-50%)"
|
|
2648
|
+
}
|
|
2649
|
+
}, /*#__PURE__*/React.createElement(PropertyHouse, {
|
|
2650
|
+
styles: {
|
|
2651
|
+
fill: "#3D51B0",
|
|
2652
|
+
width: "20px",
|
|
2653
|
+
height: "20px"
|
|
2654
|
+
}
|
|
2655
|
+
}))))), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("EKYC_LANDMARK") || "Landmark (Optional)"), /*#__PURE__*/React.createElement("div", {
|
|
2656
|
+
className: "field",
|
|
2657
|
+
style: {
|
|
2658
|
+
position: "relative"
|
|
2659
|
+
}
|
|
2660
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
2661
|
+
value: landmark,
|
|
2662
|
+
onChange: e => setLandmark(e.target.value),
|
|
2663
|
+
placeholder: t("EKYC_ENTER_LANDMARK") || "Enter Landmark (Optional)",
|
|
2664
|
+
textInputStyle: {
|
|
2665
|
+
paddingLeft: "40px"
|
|
2666
|
+
}
|
|
2667
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
2668
|
+
style: {
|
|
2669
|
+
position: "absolute",
|
|
2670
|
+
left: "10px",
|
|
2671
|
+
top: "50%",
|
|
2672
|
+
transform: "translateY(-50%)"
|
|
2673
|
+
}
|
|
2674
|
+
}, /*#__PURE__*/React.createElement(LocationIcon, {
|
|
2675
|
+
className: "icon",
|
|
2676
|
+
styles: {
|
|
2677
|
+
fill: "#3D51B0"
|
|
2678
|
+
}
|
|
2679
|
+
})))), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("EKYC_PINCODE") || "Pincode"), /*#__PURE__*/React.createElement("div", {
|
|
2680
|
+
className: "field",
|
|
2681
|
+
style: {
|
|
2682
|
+
position: "relative"
|
|
2683
|
+
}
|
|
2684
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
2685
|
+
value: pincode,
|
|
2686
|
+
onChange: e => setPincode(e.target.value),
|
|
2687
|
+
placeholder: t("EKYC_ENTER_PINCODE") || "Enter Pincode",
|
|
2688
|
+
textInputStyle: {
|
|
2689
|
+
paddingLeft: "40px"
|
|
2690
|
+
}
|
|
2691
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
2692
|
+
style: {
|
|
2693
|
+
position: "absolute",
|
|
2694
|
+
left: "10px",
|
|
2695
|
+
top: "50%",
|
|
2696
|
+
transform: "translateY(-50%)"
|
|
2697
|
+
}
|
|
2698
|
+
}, /*#__PURE__*/React.createElement(PincodeIcon, null))))), /*#__PURE__*/React.createElement("div", {
|
|
2699
|
+
style: {
|
|
2700
|
+
display: "flex",
|
|
2701
|
+
alignItems: "center",
|
|
2702
|
+
gap: "10px",
|
|
2703
|
+
marginTop: "20px",
|
|
2704
|
+
marginBottom: "16px"
|
|
2705
|
+
}
|
|
2706
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2707
|
+
style: {
|
|
2708
|
+
backgroundColor: "#E8EAF6",
|
|
2709
|
+
padding: "8px",
|
|
2710
|
+
borderRadius: "8px"
|
|
2711
|
+
}
|
|
2712
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
2713
|
+
width: "24",
|
|
2714
|
+
height: "24",
|
|
2715
|
+
viewBox: "0 0 24 24",
|
|
2716
|
+
fill: "none",
|
|
2717
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
2718
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
2719
|
+
d: "M12 7V3H2V21H22V7H12ZM6 19H4V17H6V19ZM6 15H4V13H6V15ZM6 11H4V9H6V11ZM6 7H4V5H6V7ZM10 19H8V17H10V19ZM10 15H8V13H10V15ZM10 11H8V9H10V11ZM10 7H8V5H10V7ZM20 19H12V9H20V19ZM18 11H14V13H18V11ZM18 15H14V17H18V15Z",
|
|
2720
|
+
fill: "#3D51B0"
|
|
2721
|
+
}))), /*#__PURE__*/React.createElement(CardHeader, {
|
|
2722
|
+
style: {
|
|
2723
|
+
margin: 0
|
|
2724
|
+
}
|
|
2725
|
+
}, t("EKYC_ADMINISTRATIVE_DIVISION") || "Administrative Division")), /*#__PURE__*/React.createElement("div", {
|
|
2726
|
+
style: {
|
|
2727
|
+
display: "flex",
|
|
2728
|
+
flexDirection: "column",
|
|
2729
|
+
gap: "12px"
|
|
2730
|
+
}
|
|
2731
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2732
|
+
style: {
|
|
2733
|
+
backgroundColor: "#F1F8F4",
|
|
2734
|
+
padding: "16px",
|
|
2735
|
+
borderRadius: "8px",
|
|
2736
|
+
display: "flex",
|
|
2737
|
+
alignItems: "center",
|
|
2738
|
+
gap: "16px",
|
|
2739
|
+
border: "1px solid #C4E1D1"
|
|
2740
|
+
}
|
|
2741
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2742
|
+
style: {
|
|
2743
|
+
backgroundColor: "#D0E7D8",
|
|
2744
|
+
padding: "8px",
|
|
2745
|
+
borderRadius: "8px"
|
|
2746
|
+
}
|
|
2747
|
+
}, /*#__PURE__*/React.createElement(FlagIcon, null)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
2748
|
+
style: {
|
|
2749
|
+
color: "#00703C",
|
|
2750
|
+
fontSize: "12px",
|
|
2751
|
+
fontWeight: "bold"
|
|
2752
|
+
}
|
|
2753
|
+
}, t("EKYC_ASSEMBLY") || "ASSEMBLY"), /*#__PURE__*/React.createElement("div", {
|
|
2754
|
+
style: {
|
|
2755
|
+
fontSize: "16px",
|
|
2756
|
+
fontWeight: "bold"
|
|
2757
|
+
}
|
|
2758
|
+
}, "AC-12 Chandni Chowk"))), /*#__PURE__*/React.createElement("div", {
|
|
2759
|
+
style: {
|
|
2760
|
+
backgroundColor: "#F1F3F9",
|
|
2761
|
+
padding: "16px",
|
|
2762
|
+
borderRadius: "8px",
|
|
2763
|
+
display: "flex",
|
|
2764
|
+
alignItems: "center",
|
|
2765
|
+
gap: "16px",
|
|
2766
|
+
border: "1px solid #D1D8E5"
|
|
2767
|
+
}
|
|
2768
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2769
|
+
style: {
|
|
2770
|
+
backgroundColor: "#D1D8E5",
|
|
2771
|
+
padding: "8px",
|
|
2772
|
+
borderRadius: "8px"
|
|
2773
|
+
}
|
|
2774
|
+
}, /*#__PURE__*/React.createElement(IdCardIcon, null)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
2775
|
+
style: {
|
|
2776
|
+
color: "#3D51B0",
|
|
2777
|
+
fontSize: "12px",
|
|
2778
|
+
fontWeight: "bold"
|
|
2779
|
+
}
|
|
2780
|
+
}, t("EKYC_WARD") || "WARD"), /*#__PURE__*/React.createElement("div", {
|
|
2781
|
+
style: {
|
|
2782
|
+
fontSize: "16px",
|
|
2783
|
+
fontWeight: "bold"
|
|
2784
|
+
}
|
|
2785
|
+
}, "WARD-45 Civil Lines")))), /*#__PURE__*/React.createElement(CardHeader, {
|
|
2786
|
+
style: {
|
|
2787
|
+
marginTop: "24px"
|
|
2788
|
+
}
|
|
2789
|
+
}, t("EKYC_DOOR_PHOTO_HEADER") || "Door Photo with GPS Stamp"), /*#__PURE__*/React.createElement("div", {
|
|
2790
|
+
style: {
|
|
2791
|
+
color: "#707070",
|
|
2792
|
+
fontSize: "14px",
|
|
2793
|
+
marginBottom: "16px"
|
|
2794
|
+
}
|
|
2795
|
+
}, t("EKYC_REQUIRED_FOR_VERIFICATION") || "Required for verification"), /*#__PURE__*/React.createElement("div", {
|
|
2796
|
+
style: {
|
|
2797
|
+
backgroundColor: "#FFF4E5",
|
|
2798
|
+
padding: "12px",
|
|
2799
|
+
borderRadius: "8px",
|
|
2800
|
+
display: "flex",
|
|
2801
|
+
alignItems: "center",
|
|
2802
|
+
gap: "12px",
|
|
2803
|
+
marginBottom: "20px",
|
|
2804
|
+
border: "1px solid #FFD180"
|
|
2805
|
+
}
|
|
2806
|
+
}, /*#__PURE__*/React.createElement(InfoBannerIcon, {
|
|
2807
|
+
fill: "#EF6C00"
|
|
2808
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
2809
|
+
style: {
|
|
2810
|
+
color: "#EF6C00"
|
|
2811
|
+
}
|
|
2812
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2813
|
+
style: {
|
|
2814
|
+
fontWeight: "bold"
|
|
2815
|
+
}
|
|
2816
|
+
}, t("EKYC_IMPORTANT") || "Important"), /*#__PURE__*/React.createElement("div", {
|
|
2817
|
+
style: {
|
|
2818
|
+
fontSize: "13px"
|
|
2819
|
+
}
|
|
2820
|
+
}, t("EKYC_CAPTURE_LIVE_CAMERA") || "Capture with live camera for GPS metadata"))), /*#__PURE__*/React.createElement("div", {
|
|
2821
|
+
style: {
|
|
2822
|
+
border: "2px dashed #D1D8E5",
|
|
2823
|
+
borderRadius: "12px",
|
|
2824
|
+
padding: "40px 20px",
|
|
2825
|
+
textAlign: "center",
|
|
2826
|
+
cursor: "pointer"
|
|
2827
|
+
}
|
|
2828
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2829
|
+
style: {
|
|
2830
|
+
backgroundColor: "#F1F3F9",
|
|
2831
|
+
width: "64px",
|
|
2832
|
+
height: "64px",
|
|
2833
|
+
borderRadius: "50%",
|
|
2834
|
+
display: "flex",
|
|
2835
|
+
alignItems: "center",
|
|
2836
|
+
justifyContent: "center",
|
|
2837
|
+
margin: "0 auto 16px"
|
|
2838
|
+
}
|
|
2839
|
+
}, /*#__PURE__*/React.createElement(CameraIcon, null)), /*#__PURE__*/React.createElement("div", {
|
|
2840
|
+
style: {
|
|
2841
|
+
fontWeight: "bold",
|
|
2842
|
+
fontSize: "16px",
|
|
2843
|
+
marginBottom: "4px"
|
|
2844
|
+
}
|
|
2845
|
+
}, t("EKYC_TAP_TO_CAPTURE") || "Tap to Capture"), /*#__PURE__*/React.createElement("div", {
|
|
2846
|
+
style: {
|
|
2847
|
+
color: "#707070",
|
|
2848
|
+
fontSize: "14px"
|
|
2849
|
+
}
|
|
2850
|
+
}, t("EKYC_CAPTURE_DOOR_IMAGE") || "Capture Door Image"))), /*#__PURE__*/React.createElement(ActionBar, null, /*#__PURE__*/React.createElement(SubmitBar, {
|
|
2851
|
+
label: t("EKYC_COMPLETE_VERIFICATION") || "Complete Verification",
|
|
2852
|
+
onSubmit: handleCompleteVerification
|
|
2853
|
+
})));
|
|
2854
|
+
};
|
|
2855
|
+
|
|
2856
|
+
const EmployeeApp = ({
|
|
2857
|
+
path
|
|
2858
|
+
}) => {
|
|
2859
|
+
const {
|
|
2860
|
+
t
|
|
2861
|
+
} = useTranslation();
|
|
2862
|
+
const location = useLocation();
|
|
2863
|
+
sessionStorage.removeItem("revalidateddone");
|
|
2864
|
+
const getBreadcrumbLabel = () => {
|
|
2865
|
+
const pathname = location.pathname;
|
|
2866
|
+
if (pathname.includes("/dashboard")) return "ES_COMMON_INBOX";
|
|
2867
|
+
if (pathname.includes("/create-kyc")) return "EKYC_CREATE_KYC";
|
|
2868
|
+
if (pathname.includes("/k-details")) return "EKYC_K_DETAILS";
|
|
2869
|
+
if (pathname.includes("/aadhaar-verification")) return "EKYC_AADHAAR_VERIFICATION";
|
|
2870
|
+
if (pathname.includes("/address-details")) return "EKYC_ADDRESS_DETAILS";
|
|
2871
|
+
return "ES_COMMON_INBOX";
|
|
2872
|
+
};
|
|
2873
|
+
const breadcrumbs = [{
|
|
2874
|
+
icon: HomeIcon,
|
|
2875
|
+
path: "/digit-ui/employee"
|
|
2876
|
+
}, {
|
|
2877
|
+
label: t(getBreadcrumbLabel())
|
|
2878
|
+
}];
|
|
2879
|
+
return /*#__PURE__*/React.createElement(AppContainer, null, /*#__PURE__*/React.createElement("div", {
|
|
2880
|
+
className: "ground-container employee-app-container"
|
|
2881
|
+
}, /*#__PURE__*/React.createElement(ModuleHeader, {
|
|
2882
|
+
leftContent: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ArrowLeft, {
|
|
2883
|
+
className: "icon"
|
|
2884
|
+
}), "Back"),
|
|
2885
|
+
onLeftClick: () => window.history.back(),
|
|
2886
|
+
breadcrumbs: breadcrumbs
|
|
2887
|
+
}), /*#__PURE__*/React.createElement(Switch, null, /*#__PURE__*/React.createElement(PrivateRoute, {
|
|
2888
|
+
path: `${path}/dashboard`,
|
|
2889
|
+
component: () => /*#__PURE__*/React.createElement(Inbox, {
|
|
2890
|
+
parentRoute: path,
|
|
2891
|
+
businessService: "EKYC",
|
|
2892
|
+
moduleCode: "EKYC",
|
|
2893
|
+
isInbox: true
|
|
2894
|
+
})
|
|
2895
|
+
}), /*#__PURE__*/React.createElement(PrivateRoute, {
|
|
2896
|
+
path: `${path}/create-kyc`,
|
|
2897
|
+
component: () => /*#__PURE__*/React.createElement(Create, null)
|
|
2898
|
+
}), /*#__PURE__*/React.createElement(PrivateRoute, {
|
|
2899
|
+
path: `${path}/k-details`,
|
|
2900
|
+
component: () => /*#__PURE__*/React.createElement(KDetails, null)
|
|
2901
|
+
}), /*#__PURE__*/React.createElement(PrivateRoute, {
|
|
2902
|
+
path: `${path}/aadhaar-verification`,
|
|
2903
|
+
component: () => /*#__PURE__*/React.createElement(AadhaarVerification, null)
|
|
2904
|
+
}), /*#__PURE__*/React.createElement(PrivateRoute, {
|
|
2905
|
+
path: `${path}/address-details`,
|
|
2906
|
+
component: () => /*#__PURE__*/React.createElement(AddressDetails, null)
|
|
2907
|
+
}), /*#__PURE__*/React.createElement(PrivateRoute, {
|
|
2908
|
+
path: `${path}/`,
|
|
2909
|
+
component: () => /*#__PURE__*/React.createElement(Inbox, {
|
|
2910
|
+
parentRoute: path,
|
|
2911
|
+
businessService: "EKYC",
|
|
2912
|
+
moduleCode: "EKYC",
|
|
2913
|
+
isInbox: true
|
|
2914
|
+
})
|
|
2915
|
+
}))));
|
|
2916
|
+
};
|
|
2917
|
+
|
|
2918
|
+
const EkycModule = ({
|
|
2919
|
+
stateCode,
|
|
2920
|
+
userType,
|
|
2921
|
+
tenants
|
|
2922
|
+
}) => {
|
|
2923
|
+
const {
|
|
2924
|
+
path,
|
|
2925
|
+
url
|
|
2926
|
+
} = useRouteMatch();
|
|
2927
|
+
const moduleCode = "EKYC";
|
|
2928
|
+
const language = Digit.StoreData.getCurrentLanguage();
|
|
2929
|
+
const {
|
|
2930
|
+
isLoading,
|
|
2931
|
+
data: store
|
|
2932
|
+
} = Digit.Services.useStore({
|
|
2933
|
+
stateCode,
|
|
2934
|
+
moduleCode,
|
|
2935
|
+
language
|
|
2936
|
+
});
|
|
2937
|
+
Digit.SessionStorage.set("EKYC_TENANTS", tenants);
|
|
2938
|
+
if (isLoading) {
|
|
2939
|
+
return null;
|
|
2940
|
+
}
|
|
2941
|
+
if (userType === "employee") {
|
|
2942
|
+
return /*#__PURE__*/React.createElement(EmployeeApp, {
|
|
2943
|
+
path: path,
|
|
2944
|
+
url: url,
|
|
2945
|
+
userType: userType,
|
|
2946
|
+
tenants: tenants
|
|
2947
|
+
});
|
|
2948
|
+
} else return null;
|
|
2949
|
+
};
|
|
2950
|
+
const componentsToRegister = {
|
|
2951
|
+
EKYCModule: EkycModule,
|
|
2952
|
+
EKYCCard,
|
|
2953
|
+
EKYCInbox: Inbox,
|
|
2954
|
+
EKYCDesktopInbox: DesktopInbox,
|
|
2955
|
+
EKYCMobileInbox: MobileInbox
|
|
2956
|
+
};
|
|
2957
|
+
const initEkycComponents = () => {
|
|
2958
|
+
Object.entries(componentsToRegister).forEach(([key, value]) => {
|
|
2959
|
+
Digit.ComponentRegistryService.setComponent(key, value);
|
|
2960
|
+
});
|
|
2961
|
+
};
|
|
2962
|
+
|
|
2963
|
+
export default EkycModule;
|
|
2964
|
+
export { EkycModule, initEkycComponents };
|
|
2965
|
+
//# sourceMappingURL=index.modern.js.map
|