@djb25/digit-ui-module-ekyc 1.0.11 → 1.0.13
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.css +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +2884 -682
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
- package/src/Module.js +28 -7
- package/src/components/AadhaarVerification.js +415 -0
- package/src/components/AddressDetails.js +207 -0
- package/src/components/CeoDashboard.js +201 -0
- package/src/components/DesktopInbox.js +1 -1
- package/src/components/EKYCCard.js +4 -0
- package/src/components/MeterDetails.js +372 -0
- package/src/components/PropertyInfo.js +303 -0
- package/src/components/Review.js +572 -0
- package/src/components/analytics/charts/ClusterHeatmap.js +88 -0
- package/src/components/analytics/charts/TaskStatusChart.js +92 -0
- package/src/components/analytics/components/AnalyticsTable.js +106 -0
- package/src/components/analytics/components/DashboardLayout.js +72 -0
- package/src/components/analytics/components/EmptyState.js +27 -0
- package/src/components/analytics/components/ErrorBoundary.js +27 -0
- package/src/components/analytics/components/FilterBar.js +73 -0
- package/src/components/analytics/components/NotificationPanel.js +77 -0
- package/src/components/analytics/components/SLAWidget.js +56 -0
- package/src/components/analytics/components/SkeletonLoader.js +53 -0
- package/src/components/analytics/components/SummaryCard.js +74 -0
- package/src/components/analytics/components/WorkflowTimeline.js +55 -0
- package/src/components/analytics/styles/Dashboard.css +54 -0
- package/src/components/analytics/utils/exportUtils.js +64 -0
- package/src/components/analytics/utils/filterSerializer.js +50 -0
- package/src/config/config.js +1 -1
- package/src/pages/citizen/index.js +74 -18
- package/src/pages/employee/ConsumerDetails.js +10 -281
- package/src/pages/employee/Inbox.js +6 -4
- package/src/pages/employee/index.js +55 -8
- package/src/pages/employee/AadhaarVerification.js +0 -512
- package/src/pages/employee/AddressDetails.js +0 -548
- package/src/pages/employee/MeterDetails.js +0 -496
- package/src/pages/employee/PropertyInfo.js +0 -489
- package/src/pages/employee/Review.js +0 -314
|
@@ -1,548 +0,0 @@
|
|
|
1
|
-
// import React, { useState, useRef, Fragment, useEffect } from "react";
|
|
2
|
-
// import {
|
|
3
|
-
// Card,
|
|
4
|
-
// CardLabel,
|
|
5
|
-
// TextInput,
|
|
6
|
-
// SubmitBar,
|
|
7
|
-
// CardHeader,
|
|
8
|
-
// RadioButtons,
|
|
9
|
-
// ActionBar,
|
|
10
|
-
// Dropdown,
|
|
11
|
-
// Loader,
|
|
12
|
-
// UploadFile,
|
|
13
|
-
// Toast,
|
|
14
|
-
// FormStep,
|
|
15
|
-
// } from "@djb25/digit-ui-react-components";
|
|
16
|
-
// import { useTranslation } from "react-i18next";
|
|
17
|
-
// import { useHistory, useLocation } from "react-router-dom";
|
|
18
|
-
// import { getSavedData } from "../../utils";
|
|
19
|
-
|
|
20
|
-
// const AddressDetails = ({ config, onSelect, formData, t: tProps }) => {
|
|
21
|
-
// const { t } = useTranslation();
|
|
22
|
-
// const history = useHistory();
|
|
23
|
-
// const location = useLocation();
|
|
24
|
-
|
|
25
|
-
// const flowState = location.state || {};
|
|
26
|
-
// const { isEditing, kNumber } = flowState;
|
|
27
|
-
|
|
28
|
-
// // Robust data extraction from formData (which includes reviewData and edits from EKYCForm)
|
|
29
|
-
// const activeEdits = formData || {};
|
|
30
|
-
// const rawReviewData = formData?.reviewData || formData?.connectionDetails || {};
|
|
31
|
-
// const reviewWrapper = rawReviewData?.applicationReview || rawReviewData;
|
|
32
|
-
// const applicationData = (Array.isArray(reviewWrapper) ? reviewWrapper[0] : reviewWrapper) || {};
|
|
33
|
-
// const apiData = applicationData?.newData || applicationData;
|
|
34
|
-
// const apiAddr = apiData?.addressDetails || apiData || {};
|
|
35
|
-
|
|
36
|
-
// const addrData = activeEdits?.addressDetails || {};
|
|
37
|
-
|
|
38
|
-
// const [addressType, setAddressType] = useState(addrData.addressType || { code: "AADHAAR", name: "EKYC_AADHAAR_ADDRESS" });
|
|
39
|
-
// const [correctAddress, setCorrectAddress] = useState(addrData.correctAddress || { code: "NO", name: "CORE_COMMON_NO" });
|
|
40
|
-
// const [fullAddress, setFullAddress] = useState(addrData.fullAddress || apiAddr.addressRaw || apiAddr.fullAddress || "");
|
|
41
|
-
// const [flatHouseNumber, setFlatHouseNumber] = useState(addrData.flatHouseNumber || addrData.flatNo || apiAddr.flatHouseNumber || apiAddr.flatNo || "");
|
|
42
|
-
// const [buildingTower, setBuildingTower] = useState(addrData.buildingTower || addrData.building || apiAddr.buildingTower || apiAddr.building || "");
|
|
43
|
-
// const [landmark, setLandmark] = useState(addrData.landmark || apiAddr.landmark || "");
|
|
44
|
-
// const [pinCode, setPinCode] = useState(addrData.pinCode || addrData.pincode || apiAddr.pinCode || apiAddr.pincode || "");
|
|
45
|
-
// const [doorPhoto, setDoorPhoto] = useState(addrData.doorPhoto || null);
|
|
46
|
-
// const [doorPhotoFileStoreId, setDoorPhotoFileStoreId] = useState(addrData.doorPhotoFilestoreId || addrData.doorPhotoFileStoreId || apiAddr.doorPhotoFilestoreId || null);
|
|
47
|
-
|
|
48
|
-
// const [gpsValid, setGpsValid] = useState(addrData.gpsValid !== undefined ? addrData.gpsValid : (apiAddr.gpsValid !== undefined ? apiAddr.gpsValid : true));
|
|
49
|
-
// const [latitude, setLatitude] = useState(addrData.latitude || apiAddr.latitude || "");
|
|
50
|
-
// const [longitude, setLongitude] = useState(addrData.longitude || apiAddr.longitude || "");
|
|
51
|
-
// const [mobileNo, setMobileNo] = useState(addrData.mobileNo || apiAddr.mobileNo || "");
|
|
52
|
-
// const [whatsappNo, setWhatsappNo] = useState(addrData.whatsappNo || apiAddr.whatsappNo || "");
|
|
53
|
-
// const [email, setEmail] = useState(addrData.email || apiAddr.email || "");
|
|
54
|
-
// const [noOfPerson, setNoOfPerson] = useState(addrData.noOfPerson || apiAddr.noOfPerson || apiAddr.noOfPersons || "");
|
|
55
|
-
// const [knumber, setKnumber] = useState(addrData.knumber || apiAddr.knumber || apiAddr.kno || kNumber || "");
|
|
56
|
-
|
|
57
|
-
// const [toast, setToast] = useState(null);
|
|
58
|
-
|
|
59
|
-
// const tenantId = Digit.ULBService.getCurrentTenantId();
|
|
60
|
-
// const { data: mdmsData, isLoading: isMdmsLoading } = Digit.Hooks.useCommonMDMS(tenantId, "egov-location", ["TenantBoundary"]);
|
|
61
|
-
// const assemblies = mdmsData?.MdmsRes?.["egov-location"]?.TenantBoundary?.[0]?.boundary?.children || [];
|
|
62
|
-
// const [assembly, setAssembly] = useState(addrData.assemblyData || (apiAddr.assembly ? { name: apiAddr.assembly } : null));
|
|
63
|
-
// const [ward, setWard] = useState(addrData.wardData || (apiAddr.ward ? { name: apiAddr.ward } : null));
|
|
64
|
-
|
|
65
|
-
// const getUpdatedData = () => ({
|
|
66
|
-
// addressType,
|
|
67
|
-
// correctAddress,
|
|
68
|
-
// fullAddress,
|
|
69
|
-
// flatHouseNumber,
|
|
70
|
-
// buildingTower,
|
|
71
|
-
// landmark,
|
|
72
|
-
// pinCode,
|
|
73
|
-
// doorPhoto,
|
|
74
|
-
// doorPhotoFilestoreId: doorPhotoFileStoreId,
|
|
75
|
-
// assembly: assembly?.name,
|
|
76
|
-
// ward: ward?.name,
|
|
77
|
-
// assemblyData: assembly,
|
|
78
|
-
// wardData: ward,
|
|
79
|
-
// gpsValid,
|
|
80
|
-
// latitude,
|
|
81
|
-
// longitude,
|
|
82
|
-
// mobileNo,
|
|
83
|
-
// whatsappNo,
|
|
84
|
-
// email,
|
|
85
|
-
// noOfPerson,
|
|
86
|
-
// knumber
|
|
87
|
-
// });
|
|
88
|
-
|
|
89
|
-
// const selectphoto = async (e) => {
|
|
90
|
-
// const file = e.target.files[0];
|
|
91
|
-
// if (file) {
|
|
92
|
-
// if (file.size >= 2000000) {
|
|
93
|
-
// setToast({ type: "error", message: t("EKYC_MAXIMUM_UPLOAD_SIZE_EXCEEDED") });
|
|
94
|
-
// return;
|
|
95
|
-
// }
|
|
96
|
-
// try {
|
|
97
|
-
// const res = await Digit.UploadServices.Filestorage("EKYC", file, tenantId);
|
|
98
|
-
// if (res?.data?.files?.[0]?.fileStoreId) {
|
|
99
|
-
// const fileStoreId = res.data.files[0].fileStoreId;
|
|
100
|
-
// setDoorPhotoFileStoreId(fileStoreId);
|
|
101
|
-
// const reader = new FileReader();
|
|
102
|
-
// reader.onloadend = () => {
|
|
103
|
-
// setDoorPhoto(reader.result);
|
|
104
|
-
// if (onSelect) {
|
|
105
|
-
// onSelect(config.key, { ...getUpdatedData(), doorPhoto: reader.result, doorPhotoFilestoreId: fileStoreId });
|
|
106
|
-
// }
|
|
107
|
-
// };
|
|
108
|
-
// reader.readAsDataURL(file);
|
|
109
|
-
// setToast({ type: "success", message: t("EKYC_UPLOAD_SUCCESS") });
|
|
110
|
-
// }
|
|
111
|
-
// } catch (err) {
|
|
112
|
-
// setToast({ type: "error", message: t("EKYC_FILE_UPLOAD_ERROR") });
|
|
113
|
-
// }
|
|
114
|
-
// }
|
|
115
|
-
// };
|
|
116
|
-
|
|
117
|
-
// const removePhoto = () => {
|
|
118
|
-
// setDoorPhoto(null);
|
|
119
|
-
// setDoorPhotoFileStoreId(null);
|
|
120
|
-
// if (onSelect) {
|
|
121
|
-
// onSelect(config.key, { ...getUpdatedData(), doorPhoto: null, doorPhotoFilestoreId: null });
|
|
122
|
-
// }
|
|
123
|
-
// };
|
|
124
|
-
|
|
125
|
-
// const onStepSelect = () => {
|
|
126
|
-
// const updatedData = getUpdatedData();
|
|
127
|
-
// if (onSelect) {
|
|
128
|
-
// onSelect(config.key, updatedData);
|
|
129
|
-
// } else {
|
|
130
|
-
// if (isEditing) {
|
|
131
|
-
// history.push("/digit-ui/employee/ekyc/review", { ...location.state, edits: { ...edits, addressDetails: updatedData } });
|
|
132
|
-
// } else {
|
|
133
|
-
// history.push("/digit-ui/employee/ekyc/property-info", {
|
|
134
|
-
// ...location.state,
|
|
135
|
-
// edits: { ...edits, addressDetails: updatedData }
|
|
136
|
-
// });
|
|
137
|
-
// }
|
|
138
|
-
// }
|
|
139
|
-
// };
|
|
140
|
-
|
|
141
|
-
// const handleUpdateAndReturn = () => {
|
|
142
|
-
// history.push("/digit-ui/employee/ekyc/review", { ...location.state, edits: { ...edits, addressDetails: getUpdatedData() } });
|
|
143
|
-
// };
|
|
144
|
-
|
|
145
|
-
// const addressOptions = [
|
|
146
|
-
// { code: "AADHAAR", name: "EKYC_AADHAAR_ADDRESS" },
|
|
147
|
-
// { code: "CURRENT", name: "EKYC_CURRENT_ADDRESS" },
|
|
148
|
-
// ];
|
|
149
|
-
|
|
150
|
-
// const yesNoOptions = [
|
|
151
|
-
// { code: "YES", name: "CORE_COMMON_YES" },
|
|
152
|
-
// { code: "NO", name: "CORE_COMMON_NO" },
|
|
153
|
-
// ];
|
|
154
|
-
|
|
155
|
-
// if (isMdmsLoading) return <Loader />;
|
|
156
|
-
|
|
157
|
-
// return (
|
|
158
|
-
// <Fragment>
|
|
159
|
-
// <FormStep t={t} onSelect={onStepSelect} config={config || {}} label={t(config?.texts?.submitBarLabel) || (isEditing ? t("EKYC_UPDATE_AND_RETURN") : t("ES_COMMON_CONTINUE"))}>
|
|
160
|
-
// <CardLabel>{t("EKYC_ADDRESS_TYPE")}</CardLabel>
|
|
161
|
-
// <RadioButtons
|
|
162
|
-
// options={addressOptions}
|
|
163
|
-
// optionsKey="name"
|
|
164
|
-
// selectedOption={addressType}
|
|
165
|
-
// onSelect={setAddressType}
|
|
166
|
-
// />
|
|
167
|
-
|
|
168
|
-
// <CardLabel>{t("EKYC_IS_ADDRESS_CORRECT")}</CardLabel>
|
|
169
|
-
// <RadioButtons
|
|
170
|
-
// options={yesNoOptions}
|
|
171
|
-
// optionsKey="name"
|
|
172
|
-
// selectedOption={correctAddress}
|
|
173
|
-
// onSelect={setCorrectAddress}
|
|
174
|
-
// />
|
|
175
|
-
|
|
176
|
-
// {correctAddress?.code === "NO" && (
|
|
177
|
-
// <Fragment>
|
|
178
|
-
// <CardLabel>{t("EKYC_FULL_ADDRESS")}</CardLabel>
|
|
179
|
-
// <TextInput
|
|
180
|
-
// id="fullAddress"
|
|
181
|
-
// name="fullAddress"
|
|
182
|
-
// value={fullAddress}
|
|
183
|
-
// onChange={(e) => setFullAddress(e.target.value)}
|
|
184
|
-
// placeholder={t("EKYC_ENTER_FULL_ADDRESS")}
|
|
185
|
-
// />
|
|
186
|
-
|
|
187
|
-
// <CardLabel>{t("EKYC_FLAT_HOUSE_NO")}</CardLabel>
|
|
188
|
-
// <TextInput
|
|
189
|
-
// id="flatHouseNumber"
|
|
190
|
-
// name="flatHouseNumber"
|
|
191
|
-
// value={flatHouseNumber}
|
|
192
|
-
// onChange={(e) => setFlatHouseNumber(e.target.value)}
|
|
193
|
-
// placeholder={t("EKYC_ENTER_FLAT_HOUSE_NO")}
|
|
194
|
-
// />
|
|
195
|
-
|
|
196
|
-
// <CardLabel>{t("EKYC_BUILDING_TOWER")}</CardLabel>
|
|
197
|
-
// <TextInput
|
|
198
|
-
// id="buildingTower"
|
|
199
|
-
// name="buildingTower"
|
|
200
|
-
// value={buildingTower}
|
|
201
|
-
// onChange={(e) => setBuildingTower(e.target.value)}
|
|
202
|
-
// placeholder={t("EKYC_ENTER_BUILDING_TOWER")}
|
|
203
|
-
// />
|
|
204
|
-
|
|
205
|
-
// <CardLabel>{t("EKYC_LANDMARK")}</CardLabel>
|
|
206
|
-
// <TextInput
|
|
207
|
-
// id="landmark"
|
|
208
|
-
// name="landmark"
|
|
209
|
-
// value={landmark}
|
|
210
|
-
// onChange={(e) => setLandmark(e.target.value)}
|
|
211
|
-
// placeholder={t("EKYC_ENTER_LANDMARK")}
|
|
212
|
-
// />
|
|
213
|
-
|
|
214
|
-
// <CardLabel>{t("EKYC_PINCODE")}</CardLabel>
|
|
215
|
-
// <TextInput
|
|
216
|
-
// id="pinCode"
|
|
217
|
-
// name="pinCode"
|
|
218
|
-
// value={pinCode}
|
|
219
|
-
// onChange={(e) => setPinCode(e.target.value)}
|
|
220
|
-
// placeholder={t("EKYC_ENTER_PINCODE")}
|
|
221
|
-
// />
|
|
222
|
-
// </Fragment>
|
|
223
|
-
// )}
|
|
224
|
-
|
|
225
|
-
// <CardLabel>{t("EKYC_ASSEMBLY_WARD")}</CardLabel>
|
|
226
|
-
// <Dropdown
|
|
227
|
-
// option={assemblies}
|
|
228
|
-
// optionKey="name"
|
|
229
|
-
// selected={assembly}
|
|
230
|
-
// select={setAssembly}
|
|
231
|
-
// t={t}
|
|
232
|
-
// />
|
|
233
|
-
|
|
234
|
-
// {assembly && (
|
|
235
|
-
// <Fragment>
|
|
236
|
-
// <CardLabel>{t("EKYC_WARD")}</CardLabel>
|
|
237
|
-
// <Dropdown
|
|
238
|
-
// option={assembly.children || []}
|
|
239
|
-
// optionKey="name"
|
|
240
|
-
// selected={ward}
|
|
241
|
-
// select={setWard}
|
|
242
|
-
// t={t}
|
|
243
|
-
// />
|
|
244
|
-
// </Fragment>
|
|
245
|
-
// )}
|
|
246
|
-
|
|
247
|
-
// <CardLabel>{t("EKYC_GPS_VALID")}</CardLabel>
|
|
248
|
-
// <RadioButtons
|
|
249
|
-
// options={[
|
|
250
|
-
// { code: true, name: "CORE_COMMON_YES" },
|
|
251
|
-
// { code: false, name: "CORE_COMMON_NO" },
|
|
252
|
-
// ]}
|
|
253
|
-
// optionsKey="name"
|
|
254
|
-
// selectedOption={gpsValid ? { code: true, name: "CORE_COMMON_YES" } : { code: false, name: "CORE_COMMON_NO" }}
|
|
255
|
-
// onSelect={(val) => setGpsValid(val.code)}
|
|
256
|
-
// />
|
|
257
|
-
|
|
258
|
-
// <CardLabel>{t("EKYC_LATITUDE")}</CardLabel>
|
|
259
|
-
// <TextInput
|
|
260
|
-
// id="latitude"
|
|
261
|
-
// name="latitude"
|
|
262
|
-
// value={latitude}
|
|
263
|
-
// onChange={(e) => setLatitude(e.target.value)}
|
|
264
|
-
// placeholder={t("EKYC_ENTER_LATITUDE")}
|
|
265
|
-
// />
|
|
266
|
-
|
|
267
|
-
// <CardLabel>{t("EKYC_LONGITUDE")}</CardLabel>
|
|
268
|
-
// <TextInput
|
|
269
|
-
// id="longitude"
|
|
270
|
-
// name="longitude"
|
|
271
|
-
// value={longitude}
|
|
272
|
-
// onChange={(e) => setLongitude(e.target.value)}
|
|
273
|
-
// placeholder={t("EKYC_ENTER_LONGITUDE")}
|
|
274
|
-
// />
|
|
275
|
-
|
|
276
|
-
// <CardLabel>{t("EKYC_MOBILE_NO")}</CardLabel>
|
|
277
|
-
// <TextInput
|
|
278
|
-
// id="mobileNo"
|
|
279
|
-
// name="mobileNo"
|
|
280
|
-
// value={mobileNo}
|
|
281
|
-
// onChange={(e) => setMobileNo(e.target.value)}
|
|
282
|
-
// placeholder={t("EKYC_ENTER_MOBILE_NO")}
|
|
283
|
-
// />
|
|
284
|
-
|
|
285
|
-
// <CardLabel>{t("EKYC_WHATSAPP_NO")}</CardLabel>
|
|
286
|
-
// <TextInput
|
|
287
|
-
// id="whatsappNo"
|
|
288
|
-
// name="whatsappNo"
|
|
289
|
-
// value={whatsappNo}
|
|
290
|
-
// onChange={(e) => setWhatsappNo(e.target.value)}
|
|
291
|
-
// placeholder={t("EKYC_ENTER_WHATSAPP_NO")}
|
|
292
|
-
// />
|
|
293
|
-
|
|
294
|
-
// <CardLabel>{t("EKYC_EMAIL")}</CardLabel>
|
|
295
|
-
// <TextInput
|
|
296
|
-
// id="email"
|
|
297
|
-
// name="email"
|
|
298
|
-
// value={email}
|
|
299
|
-
// onChange={(e) => setEmail(e.target.value)}
|
|
300
|
-
// placeholder={t("EKYC_ENTER_EMAIL")}
|
|
301
|
-
// />
|
|
302
|
-
|
|
303
|
-
// <CardLabel>{t("EKYC_NO_OF_PERSONS")}</CardLabel>
|
|
304
|
-
// <TextInput
|
|
305
|
-
// id="noOfPerson"
|
|
306
|
-
// name="noOfPerson"
|
|
307
|
-
// value={noOfPerson}
|
|
308
|
-
// onChange={(e) => setNoOfPerson(e.target.value)}
|
|
309
|
-
// placeholder={t("EKYC_ENTER_NO_OF_PERSONS")}
|
|
310
|
-
// />
|
|
311
|
-
|
|
312
|
-
// <CardLabel>{t("EKYC_K_NUMBER")}</CardLabel>
|
|
313
|
-
// <TextInput
|
|
314
|
-
// id="knumber"
|
|
315
|
-
// name="knumber"
|
|
316
|
-
// value={knumber}
|
|
317
|
-
// onChange={(e) => setKnumber(e.target.value)}
|
|
318
|
-
// placeholder={t("EKYC_ENTER_K_NUMBER")}
|
|
319
|
-
// />
|
|
320
|
-
|
|
321
|
-
// <CardLabel>{t("EKYC_DOOR_PHOTO")}</CardLabel>
|
|
322
|
-
// <UploadFile
|
|
323
|
-
// onUpload={selectphoto}
|
|
324
|
-
// onDelete={removePhoto}
|
|
325
|
-
// message={doorPhotoFileStoreId ? t("EKYC_FILE_UPLOADED") : t("EKYC_NO_FILE_SELECTED")}
|
|
326
|
-
// />
|
|
327
|
-
// {doorPhoto && <img src={doorPhoto} style={{ width: "100%", marginTop: "10px", borderRadius: "8px" }} />}
|
|
328
|
-
|
|
329
|
-
// {toast && <Toast label={toast.message} error={toast.type === "error"} onClose={() => setToast(null)} />}
|
|
330
|
-
// </FormStep>
|
|
331
|
-
// {isEditing && !onSelect && (
|
|
332
|
-
// // <ActionBar style={{ position: "static", marginTop: "20px" }}>
|
|
333
|
-
// <SubmitBar label={t("EKYC_UPDATE_AND_RETURN")} onSubmit={handleUpdateAndReturn} />
|
|
334
|
-
// // </ActionBar>
|
|
335
|
-
// )}
|
|
336
|
-
// </Fragment>
|
|
337
|
-
// );
|
|
338
|
-
// };
|
|
339
|
-
|
|
340
|
-
// export default AddressDetails;
|
|
341
|
-
|
|
342
|
-
import React, { useState, useEffect, Fragment } from "react";
|
|
343
|
-
import { CardLabel, TextInput, Dropdown, UploadFile, Toast, FormStep, Loader } from "@djb25/digit-ui-react-components";
|
|
344
|
-
import { useTranslation } from "react-i18next";
|
|
345
|
-
|
|
346
|
-
const AddressDetails = ({ config, onSelect }) => {
|
|
347
|
-
const { t } = useTranslation();
|
|
348
|
-
|
|
349
|
-
const tenantId = Digit.ULBService.getCurrentTenantId();
|
|
350
|
-
|
|
351
|
-
// 🔹 STATES
|
|
352
|
-
const [houseNo, setHouseNo] = useState("");
|
|
353
|
-
const [street, setStreet] = useState("");
|
|
354
|
-
const [locality, setLocality] = useState("");
|
|
355
|
-
const [landmark, setLandmark] = useState("");
|
|
356
|
-
const [subLocality, setSubLocality] = useState(null);
|
|
357
|
-
|
|
358
|
-
const [pinCode, setPinCode] = useState("");
|
|
359
|
-
const [assembly, setAssembly] = useState(null);
|
|
360
|
-
const [ward, setWard] = useState(null);
|
|
361
|
-
const [zone, setZone] = useState(null);
|
|
362
|
-
|
|
363
|
-
const [latitude, setLatitude] = useState("");
|
|
364
|
-
const [longitude, setLongitude] = useState("");
|
|
365
|
-
|
|
366
|
-
const [addressType, setAddressType] = useState(null);
|
|
367
|
-
|
|
368
|
-
const [doorPhoto, setDoorPhoto] = useState(null);
|
|
369
|
-
const [doorPhotoFileStoreId, setDoorPhotoFileStoreId] = useState(null);
|
|
370
|
-
|
|
371
|
-
const [toast, setToast] = useState(null);
|
|
372
|
-
|
|
373
|
-
// 🔹 MDMS DATA
|
|
374
|
-
const { data: mdmsData, isLoading } = Digit.Hooks.useCommonMDMS(tenantId, "egov-location", ["TenantBoundary"]);
|
|
375
|
-
|
|
376
|
-
const assemblies = mdmsData?.MdmsRes?.["egov-location"]?.TenantBoundary?.[0]?.boundary?.children || [];
|
|
377
|
-
|
|
378
|
-
// 🔹 AUTO GPS
|
|
379
|
-
useEffect(() => {
|
|
380
|
-
let isMounted = true;
|
|
381
|
-
|
|
382
|
-
if (navigator.geolocation) {
|
|
383
|
-
navigator.geolocation.getCurrentPosition(
|
|
384
|
-
(pos) => {
|
|
385
|
-
if (!isMounted) return;
|
|
386
|
-
setLatitude(pos.coords.latitude);
|
|
387
|
-
setLongitude(pos.coords.longitude);
|
|
388
|
-
},
|
|
389
|
-
() => {
|
|
390
|
-
if (!isMounted) return;
|
|
391
|
-
setToast({ type: "error", message: "GPS access denied" });
|
|
392
|
-
}
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
return () => {
|
|
397
|
-
isMounted = false;
|
|
398
|
-
};
|
|
399
|
-
}, []);
|
|
400
|
-
|
|
401
|
-
// 🔹 PIN CODE HANDLER
|
|
402
|
-
const handlePincodeChange = (e) => {
|
|
403
|
-
const value = e.target.value;
|
|
404
|
-
if (/^\d{0,6}$/.test(value)) {
|
|
405
|
-
setPinCode(value);
|
|
406
|
-
|
|
407
|
-
if (value.length === 6) {
|
|
408
|
-
fetchLocationByPincode(value);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
// 🔹 MOCK PIN API (Replace with real API)
|
|
414
|
-
const fetchLocationByPincode = (pin) => {
|
|
415
|
-
// 🔥 Replace this with backend API
|
|
416
|
-
console.log("Fetching location for PIN:", pin);
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
// 🔹 FILE UPLOAD
|
|
420
|
-
const selectphoto = async (e) => {
|
|
421
|
-
let isMounted = true;
|
|
422
|
-
|
|
423
|
-
const file = e.target.files[0];
|
|
424
|
-
if (!file) return;
|
|
425
|
-
|
|
426
|
-
if (file.size >= 2000000) {
|
|
427
|
-
setToast({ type: "error", message: "Max size 2MB exceeded" });
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
try {
|
|
432
|
-
const res = await Digit.UploadServices.Filestorage("EKYC", file, tenantId);
|
|
433
|
-
|
|
434
|
-
if (!isMounted) return;
|
|
435
|
-
|
|
436
|
-
const fileStoreId = res?.data?.files?.[0]?.fileStoreId;
|
|
437
|
-
|
|
438
|
-
if (fileStoreId) {
|
|
439
|
-
setDoorPhotoFileStoreId(fileStoreId);
|
|
440
|
-
|
|
441
|
-
const reader = new FileReader();
|
|
442
|
-
reader.onloadend = () => {
|
|
443
|
-
if (!isMounted) return;
|
|
444
|
-
setDoorPhoto(reader.result);
|
|
445
|
-
};
|
|
446
|
-
reader.readAsDataURL(file);
|
|
447
|
-
|
|
448
|
-
setToast({ type: "success", message: "Upload successful" });
|
|
449
|
-
}
|
|
450
|
-
} catch {
|
|
451
|
-
if (!isMounted) return;
|
|
452
|
-
setToast({ type: "error", message: "Upload failed" });
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
return () => {
|
|
456
|
-
isMounted = false;
|
|
457
|
-
};
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
const removePhoto = () => {
|
|
461
|
-
setDoorPhoto(null);
|
|
462
|
-
setDoorPhotoFileStoreId(null);
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
// 🔹 VALIDATION
|
|
466
|
-
const isValid = () => {
|
|
467
|
-
return houseNo && street && pinCode.length === 6 && assembly && ward && zone && latitude && longitude && doorPhotoFileStoreId;
|
|
468
|
-
};
|
|
469
|
-
|
|
470
|
-
// 🔹 SUBMIT
|
|
471
|
-
const onStepSelect = () => {
|
|
472
|
-
if (!isValid()) {
|
|
473
|
-
setToast({ type: "error", message: "Please fill all mandatory fields" });
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
const data = {
|
|
478
|
-
houseNo,
|
|
479
|
-
street,
|
|
480
|
-
locality,
|
|
481
|
-
landmark,
|
|
482
|
-
subLocality,
|
|
483
|
-
pinCode,
|
|
484
|
-
assembly: assembly?.name,
|
|
485
|
-
ward: ward?.name,
|
|
486
|
-
zone: zone?.name,
|
|
487
|
-
latitude,
|
|
488
|
-
longitude,
|
|
489
|
-
addressType: addressType?.name,
|
|
490
|
-
doorPhotoFilestoreId: doorPhotoFileStoreId,
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
onSelect(config.key, data);
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
if (isLoading) return <Loader />;
|
|
497
|
-
|
|
498
|
-
return (
|
|
499
|
-
<Fragment>
|
|
500
|
-
<FormStep t={t} onSelect={onStepSelect} config={config} label={t("ES_COMMON_CONTINUE")}>
|
|
501
|
-
<CardLabel>House No / Flat No *</CardLabel>
|
|
502
|
-
<TextInput value={houseNo} onChange={(e) => setHouseNo(e.target.value)} />
|
|
503
|
-
|
|
504
|
-
<CardLabel>Street / Address Line *</CardLabel>
|
|
505
|
-
<TextInput value={street} onChange={(e) => setStreet(e.target.value)} />
|
|
506
|
-
|
|
507
|
-
<CardLabel>Locality</CardLabel>
|
|
508
|
-
<TextInput value={locality} onChange={(e) => setLocality(e.target.value)} />
|
|
509
|
-
|
|
510
|
-
<CardLabel>Landmark</CardLabel>
|
|
511
|
-
<TextInput value={landmark} onChange={(e) => setLandmark(e.target.value)} />
|
|
512
|
-
|
|
513
|
-
<CardLabel>Sub Locality</CardLabel>
|
|
514
|
-
<Dropdown option={[]} selected={subLocality} select={setSubLocality} />
|
|
515
|
-
|
|
516
|
-
<CardLabel>PIN Code *</CardLabel>
|
|
517
|
-
<TextInput value={pinCode} onChange={handlePincodeChange} maxLength={6} />
|
|
518
|
-
|
|
519
|
-
<CardLabel>Assembly *</CardLabel>
|
|
520
|
-
<Dropdown option={assemblies} selected={assembly} select={setAssembly} />
|
|
521
|
-
|
|
522
|
-
<CardLabel>Ward *</CardLabel>
|
|
523
|
-
<Dropdown option={assembly?.children || []} selected={ward} select={setWard} />
|
|
524
|
-
|
|
525
|
-
<CardLabel>Zone *</CardLabel>
|
|
526
|
-
<Dropdown option={ward?.children || []} selected={zone} select={setZone} />
|
|
527
|
-
|
|
528
|
-
<CardLabel>Latitude</CardLabel>
|
|
529
|
-
<TextInput value={latitude} disabled />
|
|
530
|
-
|
|
531
|
-
<CardLabel>Longitude</CardLabel>
|
|
532
|
-
<TextInput value={longitude} disabled />
|
|
533
|
-
|
|
534
|
-
<CardLabel>Address Type</CardLabel>
|
|
535
|
-
<Dropdown option={[{ name: "Permanent" }, { name: "Correspondence" }, { name: "Other" }]} selected={addressType} select={setAddressType} />
|
|
536
|
-
|
|
537
|
-
<CardLabel>Door Image *</CardLabel>
|
|
538
|
-
<UploadFile onUpload={selectphoto} onDelete={removePhoto} message={doorPhotoFileStoreId ? "Uploaded" : "No file selected"} />
|
|
539
|
-
|
|
540
|
-
{doorPhoto && <img src={doorPhoto} alt="preview" style={{ width: "100%", marginTop: "10px" }} />}
|
|
541
|
-
|
|
542
|
-
{toast && <Toast label={toast.message} error={toast.type === "error"} onClose={() => setToast(null)} />}
|
|
543
|
-
</FormStep>
|
|
544
|
-
</Fragment>
|
|
545
|
-
);
|
|
546
|
-
};
|
|
547
|
-
|
|
548
|
-
export default AddressDetails;
|