@djb25/digit-ui-module-ekyc 1.0.24 → 1.0.25

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.
@@ -1,4 +1,4 @@
1
- import React, { useMemo, useState } from "react";
1
+ import React, { useMemo, useState, useRef, useEffect } from "react";
2
2
  import { ResponsiveContainer, BarChart, Bar, XAxis, YAxis, Tooltip, CartesianGrid, PieChart, Pie, Cell, Legend } from "recharts";
3
3
 
4
4
  import { Card, SubmitBar, ActionBar, Menu, Loader, Table } from "@djb25/digit-ui-react-components";
@@ -7,6 +7,7 @@ import { useTranslation } from "react-i18next";
7
7
  import { useParams } from "react-router-dom";
8
8
 
9
9
  import AssignEkycModal from "./AssignEkycModal";
10
+ import { downloadSurveyorPDF } from "../utils/reportDownloader";
10
11
 
11
12
  const SurveyorDetailsDashboard = () => {
12
13
  const tenantId = Digit.ULBService.getCurrentTenantId();
@@ -29,6 +30,25 @@ const SurveyorDetailsDashboard = () => {
29
30
  return surveyorSearchResponse?.surveyors?.[0] || null;
30
31
  }, [surveyorSearchResponse]);
31
32
 
33
+ const { data: vendorData } = Digit.Hooks.fsm.useDsoSearch(tenantId, { status: "ACTIVE" }, { enabled: !!tenantId });
34
+ const { data: supervisorSearchResponse } = Digit.Hooks.fsm.useSupervisorSearch(tenantId, { status: "ACTIVE" }, { enabled: !!tenantId });
35
+
36
+ const vendorName = useMemo(() => {
37
+ if (!vendorData || !surveyor?.vendorId) return "N/A";
38
+ const mappedVendor = vendorData.find((v) => v.dsoDetails?.id === surveyor.vendorId || v.dsoDetails?.vendorId === surveyor.vendorId);
39
+ return mappedVendor?.dsoDetails?.name || surveyor.vendorId || "N/A";
40
+ }, [vendorData, surveyor?.vendorId]);
41
+
42
+ const supervisorName = useMemo(() => {
43
+ if (!supervisorSearchResponse?.supervisors || !surveyor?.supervisorId) return "N/A";
44
+ const mappedSupervisor = supervisorSearchResponse.supervisors.find((s) => s.id === surveyor.supervisorId || s.owner?.uuid === surveyor.supervisorId);
45
+ return mappedSupervisor?.name || mappedSupervisor?.owner?.name || surveyor.supervisorId || "N/A";
46
+ }, [supervisorSearchResponse, surveyor?.supervisorId]);
47
+
48
+ const fullName = surveyor?.owner?.name || surveyor?.name || "N/A";
49
+ const employeeId = surveyor?.employeeId || surveyor?.owner?.uuid || surveyor?.id;
50
+ const mobileNumber = surveyor?.owner?.mobileNumber || surveyor?.mobileNo || "N/A";
51
+
32
52
  const [currentPage, setCurrentPage] = useState(0);
33
53
  const [pageSize, setPageSize] = useState(20);
34
54
  const queryParams = {
@@ -82,6 +102,24 @@ const SurveyorDetailsDashboard = () => {
82
102
  []
83
103
  );
84
104
 
105
+ // ─── Download Report hooks (must be before any early returns) ───────
106
+
107
+ const [showReportMenu, setShowReportMenu] = useState(false);
108
+ const [customDate, setCustomDate] = useState({ from: "", to: "" });
109
+ const [showCustomPicker, setShowCustomPicker] = useState(false);
110
+ const reportMenuRef = useRef(null);
111
+
112
+ useEffect(() => {
113
+ const handler = (e) => {
114
+ if (reportMenuRef.current && !reportMenuRef.current.contains(e.target)) {
115
+ setShowReportMenu(false);
116
+ setShowCustomPicker(false);
117
+ }
118
+ };
119
+ document.addEventListener("mousedown", handler);
120
+ return () => document.removeEventListener("mousedown", handler);
121
+ }, []);
122
+
85
123
  if (isLoading) {
86
124
  return <Loader />;
87
125
  }
@@ -122,6 +160,85 @@ const SurveyorDetailsDashboard = () => {
122
160
  },
123
161
  ];
124
162
 
163
+ const getDateRange = (filter) => {
164
+ const now = new Date();
165
+ const start = new Date(now);
166
+ if (filter === "today") {
167
+ start.setHours(0, 0, 0, 0);
168
+ return { from: start, to: now };
169
+ }
170
+ if (filter === "week") {
171
+ start.setDate(now.getDate() - now.getDay());
172
+ start.setHours(0, 0, 0, 0);
173
+ return { from: start, to: now };
174
+ }
175
+ if (filter === "month") {
176
+ start.setDate(1);
177
+ start.setHours(0, 0, 0, 0);
178
+ return { from: start, to: now };
179
+ }
180
+ return null;
181
+ };
182
+
183
+ const handlePresetDownload = (filter) => {
184
+ const allRows = dashboardData?.dashboardInfo?.consumerList || [];
185
+
186
+ const range = getDateRange(filter);
187
+
188
+ if (!range) return;
189
+
190
+ const filtered = allRows.filter((r) => {
191
+ const ts =
192
+ r.submittedAt ||
193
+ r.createdTime ||
194
+ r.lastModifiedTime ||
195
+ 0;
196
+
197
+ return ts >= range.from.getTime() && ts <= range.to.getTime();
198
+ });
199
+
200
+ downloadSurveyorPDF({
201
+ rows: filtered.length ? filtered : allRows,
202
+ surveyorName: fullName,
203
+ vendorName,
204
+ supervisorName,
205
+ employeeId,
206
+ mobileNumber,
207
+ dashboardInfo: dashboardData?.dashboardInfo,
208
+ t,
209
+ });
210
+
211
+ setShowReportMenu(false);
212
+ setShowCustomPicker(false);
213
+ };
214
+
215
+ const handleCustomDownload = () => {
216
+ if (!customDate.from || !customDate.to) {
217
+ alert(t("SELECT_DATE_RANGE") || "Please select both From and To dates.");
218
+ return;
219
+ }
220
+ const from = new Date(customDate.from);
221
+ const to = new Date(customDate.to);
222
+ to.setHours(23, 59, 59, 999);
223
+ const allRows = dashboardData?.dashboardInfo?.consumerList || [];
224
+ const filtered = allRows.filter((r) => {
225
+ const ts = r.createdTime || r.lastModifiedTime || 0;
226
+ return ts >= from.getTime() && ts <= to.getTime();
227
+ });
228
+ downloadSurveyorPDF({
229
+ rows: filtered.length ? filtered : allRows,
230
+ surveyorName: fullName,
231
+ vendorName,
232
+ supervisorName,
233
+ employeeId,
234
+ mobileNumber,
235
+ dashboardInfo: dashboardData?.dashboardInfo,
236
+ t,
237
+ });
238
+ setShowReportMenu(false);
239
+ setShowCustomPicker(false);
240
+ };
241
+
125
242
  const StatCard = ({ title, value, type, isLoading }) => (
126
243
  <div className={`stat-card ${type}`}>
127
244
  {isLoading ? (
@@ -140,23 +257,18 @@ const SurveyorDetailsDashboard = () => {
140
257
 
141
258
  const options = [{ action: "Assign" }];
142
259
 
143
- const fullName = surveyor?.owner?.name || surveyor?.name || "N/A";
144
-
145
- const employeeId = surveyor?.employeeId || surveyor?.owner?.uuid || surveyor?.id;
146
-
147
260
  const handleMenuSelect = (option) => {
148
261
  setShowOptions(false); // close menu
149
262
  setShowModal(true);
150
263
  };
151
264
 
152
265
  const closeModal = async () => {
153
- await refetchDashboard();
154
266
  setShowModal(false);
155
267
  };
156
268
 
157
269
  return (
158
270
  <Card className="surveyor-dashboard">
159
- {/* Header */}
271
+ {/* Header + Download Report */}
160
272
  <div className="ekyc-dashboard-section">
161
273
  <div className="ekyc-dashboard-header">
162
274
  <div className="avatar">{fullName?.charAt(0)?.toUpperCase()}</div>
@@ -171,6 +283,83 @@ const SurveyorDetailsDashboard = () => {
171
283
  </div>
172
284
  </div>
173
285
  </div>
286
+
287
+ {/* Download Report — far right */}
288
+ <div className="report-download" ref={reportMenuRef}>
289
+ <button
290
+ className="download-btn"
291
+ onClick={() => {
292
+ setShowReportMenu((p) => !p);
293
+ setShowCustomPicker(false);
294
+ }}
295
+ >
296
+ {t("DOWNLOAD_REPORT") || "Download Report"}
297
+ </button>
298
+
299
+ {showReportMenu && (
300
+ <div className="report-menu">
301
+ {[
302
+ { label: t("TODAY") || "Today", key: "today" },
303
+ { label: t("THIS_WEEK") || "This Week", key: "week" },
304
+ { label: t("THIS_MONTH") || "This Month", key: "month" },
305
+ ].map(({ label, key }) => (
306
+ <div
307
+ key={key}
308
+ className="menu-item"
309
+ onClick={() => handlePresetDownload(key)}
310
+ >
311
+ {label}
312
+ </div>
313
+ ))}
314
+
315
+ <div
316
+ className="custom-date-trigger"
317
+ onClick={() => setShowCustomPicker((p) => !p)}
318
+ >
319
+ {t("CUSTOM_DATE") || "Custom Date"}
320
+ </div>
321
+
322
+ {showCustomPicker && (
323
+ <div className="custom-picker">
324
+ <div className="date-field">
325
+ <label className="date-label">
326
+ {t("FROM_DATE") || "From"}
327
+ </label>
328
+ <input
329
+ type="date"
330
+ className="date-input"
331
+ value={customDate.from}
332
+ onChange={(e) =>
333
+ setCustomDate((d) => ({ ...d, from: e.target.value }))
334
+ }
335
+ />
336
+ </div>
337
+
338
+ <div className="date-field">
339
+ <label className="date-label">
340
+ {t("TO_DATE") || "To"}
341
+ </label>
342
+ <input
343
+ type="date"
344
+ className="date-input"
345
+ value={customDate.to}
346
+ onChange={(e) =>
347
+ setCustomDate((d) => ({ ...d, to: e.target.value }))
348
+ }
349
+ />
350
+ </div>
351
+
352
+ <button
353
+ className="download-action-btn"
354
+ onClick={handleCustomDownload}
355
+ >
356
+ {t("DOWNLOAD") || "Download"}
357
+ </button>
358
+ </div>
359
+ )}
360
+ </div>
361
+ )}
362
+ </div>
174
363
  </div>
175
364
 
176
365
  {/* Stats */}
@@ -291,27 +480,31 @@ const SurveyorDetailsDashboard = () => {
291
480
  />
292
481
  </Card>
293
482
  {/* Actions */}
294
- {(!roles.includes("EKYC_SURVEYOR") || roles.includes("EMPLOYEE")) && (
295
- <ActionBar>
296
- <SubmitBar label={t("EKYC_ASSIGN_KNOS")} onSubmit={() => setShowOptions((prev) => !prev)} />
297
-
298
- {showOptions && (
299
- <Menu
300
- options={options}
301
- optionKey={"action"}
302
- t={t}
303
- onSelect={handleMenuSelect}
304
- style={{
305
- color: "#FFFFFF",
306
- fontSize: "18px",
307
- }}
308
- />
309
- )}
310
- </ActionBar>
311
- )}
312
-
313
- {showModal && <AssignEkycModal surveyor={surveyor} closeModal={closeModal} />}
483
+ {
484
+ (!roles.includes("EKYC_SURVEYOR") || roles.includes("EMPLOYEE")) && (
485
+ <ActionBar>
486
+ <SubmitBar label={t("EKYC_ASSIGN_KNOS")} onSubmit={() => setShowOptions((prev) => !prev)} />
487
+
488
+ {showOptions && (
489
+ <Menu
490
+ options={options}
491
+ optionKey={"action"}
492
+ t={t}
493
+ onSelect={handleMenuSelect}
494
+ style={{
495
+ color: "#FFFFFF",
496
+ fontSize: "18px",
497
+ }}
498
+ />
499
+ )}
500
+ </ActionBar>
501
+
502
+ )
503
+ }
504
+
505
+ {showModal && <AssignEkycModal surveyor={surveyor} closeModal={closeModal} refetchDashboard={refetchDashboard} />}
314
506
  </Card>
507
+
315
508
  );
316
509
  };
317
510
 
@@ -1,6 +1,6 @@
1
- import React from "react";
2
1
  import { useHistory } from "react-router-dom";
3
2
  import { useTranslation } from "react-i18next";
3
+ import { tableColumnConfig } from "../../../vendor/src/config/tableConfig";
4
4
 
5
5
  const SupervisorInboxTableConfig = ({
6
6
  onPageSizeChange,
@@ -8,7 +8,6 @@ const SupervisorInboxTableConfig = ({
8
8
  totalCount,
9
9
  table,
10
10
  dispatch,
11
- checkPathName,
12
11
  onSortingByData,
13
12
  inboxStyles = {},
14
13
  tableStyle = {},
@@ -25,52 +24,6 @@ const SupervisorInboxTableConfig = ({
25
24
  const limit = formState?.tableForm?.limit || 10;
26
25
  const offset = formState?.tableForm?.offset || 0;
27
26
 
28
- const tableColumnConfig = [
29
- {
30
- Header: t("SURVEYOR_ID"),
31
- accessor: "id",
32
- Cell: ({ row }) => {
33
- const id = row.original?.id;
34
- return (
35
- <span
36
- className="ekyc-application-link"
37
- style={{ color: "#add8f7", cursor: "pointer", fontWeight: "bold" }}
38
- onClick={() => handleReview(id)}
39
- >
40
- {id || "NA"}
41
- </span>
42
- );
43
- },
44
- },
45
-
46
- {
47
- Header: t("SURVEYOR_NAME"),
48
- accessor: "surveyorName",
49
- Cell: ({ row }) => <span>{row.original?.surveyorName || row.original?.name || "NA"}</span>,
50
- },
51
-
52
- {
53
- Header: t("MOBILE_NUMBER"),
54
- accessor: "mobileNo",
55
- Cell: ({ row }) => <span>{row.original?.mobileNo || row.original?.owner?.mobileNumber || "NA"}</span>,
56
- },
57
-
58
- {
59
- Header: t("STATUS"),
60
- accessor: "status",
61
- Cell: ({ row }) => {
62
- const status = row.original?.status || "DEFAULT";
63
- return <span className={`ekyc-status-tag ${status}`}>{t(status)}</span>;
64
- },
65
- },
66
-
67
- {
68
- Header: t("SERVICE_TYPE"),
69
- accessor: "serviceType",
70
- Cell: ({ row }) => <span>{row.original?.serviceType || "NA"}</span>,
71
- },
72
- ];
73
-
74
27
  return {
75
28
  getCellProps: () => ({
76
29
  style: {
@@ -94,7 +47,6 @@ const SupervisorInboxTableConfig = ({
94
47
  ...formState.tableForm,
95
48
  offset: Number(offset) + Number(limit),
96
49
  },
97
- checkPathName,
98
50
  }),
99
51
 
100
52
  onPrevPage: () =>
@@ -104,7 +56,6 @@ const SupervisorInboxTableConfig = ({
104
56
  ...formState.tableForm,
105
57
  offset: Number(offset) - Number(limit),
106
58
  },
107
- checkPathName,
108
59
  }),
109
60
 
110
61
  onLastPage: () =>
@@ -114,21 +65,19 @@ const SupervisorInboxTableConfig = ({
114
65
  ...formState.tableForm,
115
66
  offset: Math.ceil(totalCount / limit) * limit - Number(limit),
116
67
  },
117
- checkPathName,
118
68
  }),
119
69
 
120
70
  onFirstPage: () =>
121
71
  dispatch({
122
72
  action: "mutateTableForm",
123
73
  data: { ...formState.tableForm, offset: 0 },
124
- checkPathName,
125
74
  }),
126
75
 
127
76
  totalRecords: totalCount,
128
77
  onSort: onSortingByData,
129
78
 
130
79
  data: table,
131
- columns: tableColumnConfig,
80
+ columns: tableColumnConfig(t, handleReview),
132
81
 
133
82
  inboxStyles: { ...inboxStyles },
134
83
  tableStyle: { ...tableStyle },
@@ -106,17 +106,17 @@ const useInboxTableConfig = ({
106
106
  manualPagination: true,
107
107
  initSortId: "applicationDate",
108
108
  onPageSizeChange: onPageSizeChange,
109
- currentPage: Math.floor(offset / limit),
109
+ currentPage: offset,
110
110
  onNextPage: () =>
111
111
  dispatch({
112
112
  action: "mutateTableForm",
113
- data: { ...formState.tableForm, offset: parseInt(formState.tableForm?.offset) + parseInt(formState.tableForm?.limit) },
113
+ data: { ...formState.tableForm, offset: parseInt(formState.tableForm?.offset) + 10 },
114
114
  checkPathName,
115
115
  }),
116
116
  onPrevPage: () =>
117
117
  dispatch({
118
118
  action: "mutateTableForm",
119
- data: { ...formState.tableForm, offset: parseInt(formState.tableForm?.offset) - parseInt(formState.tableForm?.limit) },
119
+ data: { ...formState.tableForm, offset: parseInt(formState.tableForm?.offset) - 10 },
120
120
  checkPathName,
121
121
  }),
122
122
  pageSizeLimit: limit,
@@ -127,7 +127,7 @@ const useInboxTableConfig = ({
127
127
  onLastPage: () =>
128
128
  dispatch({
129
129
  action: "mutateTableForm",
130
- data: { ...formState.tableForm, offset: Math.ceil(totalCount / 10) * 10 - parseInt(formState.tableForm?.limit) },
130
+ data: { ...formState.tableForm, offset: Math.max(0, Math.ceil(totalCount / limit) - 10) },
131
131
  checkPathName,
132
132
  }),
133
133
  onFirstPage: () => dispatch({ action: "mutateTableForm", data: { ...formState.tableForm, offset: 0 }, checkPathName }),
@@ -102,7 +102,7 @@ const Inbox = ({ parentRoute }) => {
102
102
 
103
103
  const checkPathName = location.pathname.includes("ekyc/inbox");
104
104
  const PropsForInboxLinks = {
105
- headerText: checkPathName ? "MODULE_WATER" : "MODULE_SW",
105
+ headerText: "EKYC_MODULE",
106
106
  };
107
107
 
108
108
  const SearchFormFields = useCallback(
@@ -154,10 +154,10 @@ const Inbox = ({ parentRoute }) => {
154
154
 
155
155
  const propsForFilterForm = {
156
156
  FilterFormFields,
157
- onFilterFormSubmit: () => {},
157
+ onFilterFormSubmit: () => { },
158
158
  filterFormDefaultValues: "",
159
159
  resetFilterFormDefaultValues: "",
160
- onFilterFormReset: () => {},
160
+ onFilterFormReset: () => { },
161
161
  };
162
162
 
163
163
  function formReducer(state, payload) {
@@ -239,9 +239,9 @@ const Inbox = ({ parentRoute }) => {
239
239
  <InboxComposer
240
240
  {...{
241
241
  isInboxLoading,
242
- PropsForInboxLinks,
242
+ // PropsForInboxLinks,
243
243
  ...propsForSearchForm,
244
- ...propsForFilterForm,
244
+ // ...propsForFilterForm,
245
245
  // ...propsForMobileSortForm,
246
246
  propsForInboxTable,
247
247
  // propsForInboxMobileCards,
@@ -7,9 +7,7 @@ import PropertyInfo from "../../components/PropertyInfo";
7
7
  import MeterDetails from "../../components/MeterDetails";
8
8
  import Review from "../../components/Review";
9
9
  import Home from "./Home";
10
- import Dashboard from "../../components/Dashboard";
11
10
  import Inbox from "./Inbox";
12
- import AddressDetails from "../../components/AddressDetails";
13
11
  import AssignEkyc from "../../components/AssignEkyc";
14
12
  import SurveyorDetailsCard from "../../components/SurveyorDetailsCard";
15
13
  import VendorDetails from "../../components/VendorDetails";
@@ -21,21 +19,50 @@ const CitizenApp = () => {
21
19
 
22
20
  sessionStorage.removeItem("revalidateddone");
23
21
 
24
- const getBreadcrumbLabel = () => {
22
+ const getDynamicBreadcrumbs = () => {
25
23
  const pathname = location.pathname;
26
- if (pathname.includes("/create-kyc")) return "EKYC_CREATE_KYC";
27
- if (pathname.includes("/aadhaar-verification")) return "EKYC_AADHAAR_VERIFICATION";
28
- if (pathname.includes("/address-details")) return "EKYC_ADDRESS_DETAILS";
29
- if (pathname.includes("/property-info")) return "EKYC_PROPERTY_INFO";
30
- if (pathname.includes("/meter-details")) return "EKYC_METER_DETAILS";
31
- if (pathname.includes("/review")) return "EKYC_REVIEW";
32
- return "EKYC_HOME";
33
- };
34
24
 
35
- const breadcrumbs = [{ icon: HomeIcon, path: "/digit-ui/citizen" }, { label: t(getBreadcrumbLabel()) }];
25
+ // Parent crumb always present and clickable redirects to eKYC citizen home
26
+ const crumbs = [
27
+ { icon: HomeIcon, path: "/digit-ui/citizen" },
28
+ { label: t("EKYC_MODULE_NAME"), path: `/digit-ui/citizen/ekyc` },
29
+ ];
30
+
31
+ // Child crumb — only appended when on a sub-page
32
+ if (pathname.includes("/create-kyc")) {
33
+ crumbs.push({ label: t("EKYC_CREATE_KYC") });
34
+ } else if (pathname.includes("/aadhaar-verification")) {
35
+ crumbs.push({ label: t("EKYC_AADHAAR_VERIFICATION") });
36
+ } else if (pathname.includes("/address-details")) {
37
+ crumbs.push({ label: t("EKYC_ADDRESS_DETAILS") });
38
+ } else if (pathname.includes("/property-info")) {
39
+ crumbs.push({ label: t("EKYC_PROPERTY_INFO") });
40
+ } else if (pathname.includes("/meter-details")) {
41
+ crumbs.push({ label: t("EKYC_METER_DETAILS") });
42
+ } else if (pathname.includes("/review")) {
43
+ crumbs.push({ label: t("EKYC_INBOX"), path: `/digit-ui/citizen/ekyc/inbox` });
44
+ crumbs.push({ label: t("EKYC_REVIEW") });
45
+ } else if (pathname.includes("/assign/surveyor-details")) {
46
+ crumbs.push({ label: t("EKYC_ASSIGN"), path: `/digit-ui/citizen/ekyc/assign` });
47
+ crumbs.push({ label: t("EKYC_SURVEYOR_DETAILS") });
48
+ } else if (pathname.includes("/assign")) {
49
+ crumbs.push({ label: t("EKYC_ASSIGN") });
50
+ } else if (pathname.includes("/surveyor-dashboard")) {
51
+ crumbs.push({ label: t("EKYC_SURVEYOR_DASHBOARD") });
52
+ } else if (pathname.includes("/dashboard")) {
53
+ crumbs.push({ label: t("EKYC_DASHBOARD") });
54
+ } else if (pathname.includes("/inbox")) {
55
+ crumbs.push({ label: t("EKYC_INBOX") });
56
+ } else if (pathname.includes("/status/")) {
57
+ crumbs.push({ label: t("EKYC_STATUS") });
58
+ }
59
+ // home (exact path) → no child crumb
60
+
61
+ return crumbs;
62
+ };
36
63
 
37
- const roles = Digit.SessionStorage.get("User")?.info?.roles.map((ele) => ele.code);
38
- const isEkyAction = (!roles?.includes("EKYC_SURVEYOR") || roles?.includes("EMPLOYEE"))
64
+ // const roles = Digit.SessionStorage.get("User")?.info?.roles.map((ele) => ele.code);
65
+ // const isEkyAction = (!roles?.includes("EKYC_SURVEYOR") || roles?.includes("EMPLOYEE"))
39
66
  return (
40
67
  <React.Fragment>
41
68
  <div className="ground-container form-container">
@@ -47,7 +74,7 @@ const CitizenApp = () => {
47
74
  </React.Fragment>
48
75
  }
49
76
  onLeftClick={() => window.history.back()}
50
- breadcrumbs={breadcrumbs}
77
+ breadcrumbs={getDynamicBreadcrumbs()}
51
78
  />
52
79
 
53
80
  <Switch>
@@ -86,14 +113,14 @@ const CitizenApp = () => {
86
113
  )}
87
114
  />
88
115
 
89
- <PrivateRoute
116
+ {/* <PrivateRoute
90
117
  path={`${path}/address-details`}
91
118
  component={() => (
92
119
  <LayoutWrapper layoutClass="normal">
93
120
  <AddressDetails />
94
121
  </LayoutWrapper>
95
122
  )}
96
- />
123
+ /> */}
97
124
 
98
125
  <PrivateRoute
99
126
  path={`${path}/property-info`}
@@ -1,12 +1,12 @@
1
- import React, { useState, useEffect, useRef } from "react";
1
+ import React, { useEffect, useRef } from "react";
2
2
  import { useTranslation } from "react-i18next";
3
- import { useQueryClient } from "react-query";
3
+ // import { useQueryClient } from "react-query";
4
4
  import { Redirect, Route, Switch, useHistory, useLocation, useRouteMatch } from "react-router-dom";
5
- import { Header, VerticalTimeline } from "@djb25/digit-ui-react-components";
5
+ import { VerticalTimeline } from "@djb25/digit-ui-react-components";
6
6
  import { ekycConfig } from "../../config/config";
7
7
 
8
8
  const EKYCForm = ({ path: passedPath }) => {
9
- const queryClient = useQueryClient();
9
+ // const queryClient = useQueryClient();
10
10
  const match = useRouteMatch();
11
11
  const { t } = useTranslation();
12
12
  const location = useLocation();
@@ -14,9 +14,7 @@ const EKYCForm = ({ path: passedPath }) => {
14
14
  const history = useHistory();
15
15
 
16
16
  let config = [];
17
- const [params, setParams, clearParams] = Digit.Hooks.useSessionStorage("EKYC_CREATE", {});
18
- const userInfo = Digit.UserService.getUser();
19
- const tenantId = Digit.ULBService.getCurrentTenantId();
17
+ const [params, setParams] = Digit.Hooks.useSessionStorage("EKYC_CREATE", {});
20
18
 
21
19
  useEffect(() => {
22
20
  if (location.state && Object.keys(location.state).length > 0) {
@@ -31,7 +29,7 @@ const EKYCForm = ({ path: passedPath }) => {
31
29
  if (!routeObj) routeObj = config.find((routeObj) => routeObj.route === currentPath);
32
30
 
33
31
  let nextStep = null;
34
- const currentIndex = config.findIndex(c => c.route === routeObj.route);
32
+ const currentIndex = config.findIndex((c) => c.route === routeObj.route);
35
33
  if (currentIndex > -1 && currentIndex < config.length - 1) {
36
34
  nextStep = config[currentIndex + 1].route;
37
35
  }
@@ -41,7 +39,7 @@ const EKYCForm = ({ path: passedPath }) => {
41
39
  redirectWithHistory = history.replace;
42
40
  }
43
41
 
44
- const base = passedPath || match.path.split('/').slice(0, -1).join('/');
42
+ const base = passedPath || match.path.split("/").slice(0, -1).join("/");
45
43
  if (nextStep === null) {
46
44
  return redirectWithHistory(`${base}/review`, { ...params, edits: params });
47
45
  }
@@ -49,15 +47,17 @@ const EKYCForm = ({ path: passedPath }) => {
49
47
  redirectWithHistory(`${base}/${nextStep}`, { ...params });
50
48
  };
51
49
 
52
- function handleSelect(key, data, skipStep, index, isAddMultiple = false) {
53
- setParams({ ...params, ...{ [key]: { ...params[key], ...data } } });
54
- goNext(skipStep, index, isAddMultiple, key);
50
+ function handleSelect(key, data, skipStep, index, isAddMultiple = false, silent = false) {
51
+ setParams((prev) => ({ ...prev, [key]: { ...params[key], ...data } }));
52
+ if (!silent) {
53
+ goNext(skipStep, index, isAddMultiple, key);
54
+ }
55
55
  }
56
56
 
57
- const onSuccess = () => {
58
- clearParams();
59
- queryClient.invalidateQueries("EKYC_CREATE");
60
- };
57
+ // const onSuccess = () => {
58
+ // clearParams();
59
+ // queryClient.invalidateQueries("EKYC_CREATE");
60
+ // };
61
61
 
62
62
  ekycConfig.forEach((obj) => {
63
63
  config = config.concat(obj.body);
@@ -65,7 +65,7 @@ const EKYCForm = ({ path: passedPath }) => {
65
65
 
66
66
  config.indexRoute = "consumer-details";
67
67
 
68
- const formStepRoutes = config.map(c => c.route);
68
+ const formStepRoutes = config.map((c) => c.route);
69
69
  const isFormStep = formStepRoutes.some((route) => pathname.includes(route));
70
70
 
71
71
  const sectionRefs = useRef({});
@@ -85,10 +85,10 @@ const EKYCForm = ({ path: passedPath }) => {
85
85
  <VerticalTimeline config={config} showFinalStep={true} />
86
86
  <div className="employee-form-section">
87
87
  <Switch>
88
- <Route path={formStepRoutes.map((route) => `${(passedPath || match.path.split('/').slice(0, -1).join('/'))}/${route}`)}>
88
+ <Route path={formStepRoutes.map((route) => `${passedPath || match.path.split("/").slice(0, -1).join("/")}/${route}`)}>
89
89
  <div className="single-page-form-container">
90
90
  {config.map((routeObj, index) => {
91
- const { component, key } = routeObj;
91
+ const { component } = routeObj;
92
92
  const Component = typeof component === "string" ? Digit.ComponentRegistryService.getComponent(component) : component;
93
93
 
94
94
  return (
@@ -98,6 +98,7 @@ const EKYCForm = ({ path: passedPath }) => {
98
98
  onSelect={handleSelect}
99
99
  t={t}
100
100
  formData={params}
101
+ // formData={{ ...params, address: params.addressDetails }}
101
102
  />
102
103
  </div>
103
104
  );
@@ -105,7 +106,7 @@ const EKYCForm = ({ path: passedPath }) => {
105
106
  </div>
106
107
  </Route>
107
108
  <Route>
108
- <Redirect to={`${(passedPath || match.path.split('/').slice(0, -1).join('/'))}/${config.indexRoute}`} />
109
+ <Redirect to={`${passedPath || match.path.split("/").slice(0, -1).join("/")}/${config.indexRoute}`} />
109
110
  </Route>
110
111
  </Switch>
111
112
  </div>