@djb25/digit-ui-module-ekyc 1.0.20 → 1.0.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djb25/digit-ui-module-ekyc",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "Digit UI Module for Ekyc",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.modern.js",
@@ -9,11 +9,6 @@ import SearchFormFieldsComponents from "./SearchFormFieldsComponent";
9
9
  const AssignEkyc = () => {
10
10
  const tenantId = Digit.ULBService.getCurrentTenantId();
11
11
  const location = useLocation();
12
- const [sortParams, setSortParams] = useState([{ id: "", desc: true }]);
13
- const [pageOffset, setPageOffset] = useState(0);
14
- const [pageSize, setPageSize] = useState(10);
15
- let paginationParms = { limit: pageSize, offset: pageOffset, sortBy: sortParams?.[0]?.id, sortOrder: sortParams?.[0]?.desc ? "DESC" : "ASC" };
16
-
17
12
  const formInitValue = {
18
13
  filterForm: {},
19
14
  searchForm: {},
@@ -26,10 +21,18 @@ const AssignEkyc = () => {
26
21
  };
27
22
 
28
23
  const [formState, dispatch] = useReducer(formReducer, formInitValue);
24
+ const userDetails = Digit.SessionStorage.get("User");
25
+
26
+ let paginationParms = {
27
+ limit: formState?.tableForm?.limit || 10,
28
+ offset: formState?.tableForm?.offset || 0,
29
+ sortBy: formState?.tableForm?.sortBy || "createdTime",
30
+ sortOrder: formState?.tableForm?.sortOrder || "DESC",
31
+ };
29
32
 
30
33
  const { data: dashboardData, isLoading } = Digit.Hooks.fsm.useSurveyorSearch(
31
34
  tenantId,
32
- { ...paginationParms, status: "ACTIVE,DISABLED" },
35
+ { ...paginationParms, status: "ACTIVE,DISABLED", vendorId: userDetails?.info?.uuid },
33
36
  { enabled: !!tenantId, keepPreviousData: true }
34
37
  );
35
38
 
@@ -53,6 +56,13 @@ const AssignEkyc = () => {
53
56
  keepPreviousData: true,
54
57
  }
55
58
  );
59
+ const { isLoading: isDataSearchLoading, data } = Digit.Hooks.ekyc.useEkycAssignmentProgress(
60
+ {},
61
+ {
62
+ enabled: !!tenantId && !!searchDetails.kno, // 🔥 important
63
+ keepPreviousData: true,
64
+ }
65
+ );
56
66
 
57
67
  const sourceData = useMemo(() => {
58
68
  if (isSearchActive) {
@@ -241,42 +251,37 @@ const AssignEkyc = () => {
241
251
  const cards = [
242
252
  {
243
253
  label: "TOTAL_EKYC_APPLICATIONS",
244
- count: 364,
254
+ count: data?.totalKnos || 0,
245
255
  color: "#0B2559",
246
256
  filter: null,
247
257
  active: true,
248
258
  },
249
259
  {
250
- label: "UNASSIGNED_APPLICATIONS",
251
- count: 28,
252
- color: "#F59E0B",
253
- filter: ["UNASSIGNED"],
254
- },
255
- {
256
- label: "ASSIGNED_TO_SURVEYOR",
257
- count: 120,
260
+ label: "TOTAL_ASSIGNMENTS",
261
+ count: data?.totalAssignments || 0,
258
262
  color: "#3B82F6",
259
263
  filter: ["ASSIGNED"],
260
264
  },
261
- {
262
- label: "IN_PROGRESS",
263
- count: 54,
264
- color: "#A855F7",
265
- filter: ["IN_PROGRESS"],
266
- },
267
265
  {
268
266
  label: "EKYC_COMPLETED",
269
- count: 140,
267
+ count: data?.completedKnos || 0,
270
268
  color: "#10B981",
271
269
  filter: ["COMPLETED"],
272
270
  },
273
271
  {
274
- label: "REJECTED_APPLICATIONS",
275
- count: 22,
276
- color: "#EF4444",
277
- filter: ["REJECTED"],
272
+ label: "PENDING_APPLICATIONS",
273
+ count: (data?.totalKnos || 0) - (data?.completedKnos || 0),
274
+ color: "#F59E0B",
275
+ filter: ["PENDING"],
276
+ },
277
+ {
278
+ label: "OVERALL_PROGRESS",
279
+ count: `${data?.overallProgressPercent || 0}%`,
280
+ color: "#A855F7",
281
+ filter: ["IN_PROGRESS"],
278
282
  },
279
283
  ];
284
+
280
285
  return (
281
286
  <div className="app-container">
282
287
  <InboxComposer
@@ -291,6 +296,7 @@ const AssignEkyc = () => {
291
296
  formState,
292
297
  countData: dashboardData?.dashboardInfo,
293
298
  cards,
299
+ isCardLoading: isDataSearchLoading,
294
300
  }}
295
301
  />
296
302
  </div>
@@ -1,38 +1,26 @@
1
1
  import React, { useMemo, useState, useEffect } from "react";
2
- import { Modal, Close, Table } from "@djb25/digit-ui-react-components";
2
+ import { Modal, Close, Table, Toast } from "@djb25/digit-ui-react-components";
3
3
 
4
4
  const AssignEkycModal = ({ surveyor, closeModal }) => {
5
5
  const [selectedKnos, setSelectedKnos] = useState([]);
6
- const [assignmentType, setAssignmentType] = useState("KNO");
6
+ const [isBulkSelection, setIsBulkSelection] = useState(false);
7
7
  const [currentPage, setCurrentPage] = useState(0);
8
8
  const [pageSize, setPageSize] = useState(10);
9
+ const [showToast, setShowToast] = useState(false);
10
+ const [toastData, setToastData] = useState({
11
+ error: false,
12
+ label: "",
13
+ });
9
14
  const [filters, setFilters] = useState({
10
15
  kno: "", // search value
11
- ekycStatus: "",
16
+ pincode: "",
12
17
  zoneName: "",
13
- assembly: "",
14
18
  ward: "",
19
+ assembly: "",
15
20
  mrkey: "",
16
- pincode: "",
21
+ ekycStatus: "",
17
22
  });
18
23
 
19
- const getAssignmentValue = () => {
20
- switch (assignmentType) {
21
- case "MRKEY":
22
- return filters.mrkey;
23
-
24
- case "ASSEMBLY":
25
- return filters.assembly;
26
-
27
- case "WARD":
28
- return filters.ward;
29
-
30
- case "KNO":
31
- default:
32
- return selectedKnos.join(",");
33
- }
34
- };
35
-
36
24
  const [debouncedFilters, setDebouncedFilters] = useState(filters);
37
25
 
38
26
  useEffect(() => {
@@ -47,7 +35,7 @@ const AssignEkycModal = ({ surveyor, closeModal }) => {
47
35
  setCurrentPage(0);
48
36
  }, [debouncedFilters]);
49
37
 
50
- const { data: applicationData, isLoading } = Digit.Hooks.ekyc.useEkycApplicationList(
38
+ const { data: applicationData, isFetching: isLoading } = Digit.Hooks.ekyc.useEkycApplicationList(
51
39
  {
52
40
  ...(debouncedFilters.kno && {
53
41
  kno: debouncedFilters.kno,
@@ -89,27 +77,87 @@ const AssignEkycModal = ({ surveyor, closeModal }) => {
89
77
 
90
78
  const assignmentMutation = Digit.Hooks.ekyc.useEkycAssignmentCreate({
91
79
  onSuccess: (response) => {
92
- console.log("Assignment successful", response);
93
- closeModal();
80
+ if (response?.error) {
81
+ setToastData({
82
+ error: true,
83
+ label: response?.data?.message || "Something went wrong",
84
+ });
85
+
86
+ setShowToast(true);
87
+ return;
88
+ }
89
+
90
+ setToastData({
91
+ error: false,
92
+ label: "Assignment successful",
93
+ });
94
+
95
+ setShowToast(true);
96
+
97
+ // optional delay so user can see the success toast
98
+ setTimeout(() => {
99
+ closeModal();
100
+ }, 1000);
94
101
  },
102
+
95
103
  onError: (error) => {
96
- console.error("Assignment failed", error);
97
- // show toast here
104
+ setToastData({
105
+ error: true,
106
+ label: error?.data?.message || error?.response?.data?.message || "Something went wrong",
107
+ });
108
+
109
+ setShowToast(true);
98
110
  },
99
111
  });
100
112
 
101
113
  const tableData = applicationData?.consumerList || [];
102
114
 
115
+ const getAssignmentPayload = () => {
116
+ if (isBulkSelection) {
117
+ const filterMappings = [
118
+ { key: "ekycStatus", type: "EKYCSTATUS" },
119
+ { key: "zoneName", type: "ZONENAME" },
120
+ { key: "assembly", type: "ASSEMBLY" },
121
+ { key: "ward", type: "WARD" },
122
+ { key: "mrkey", type: "MRKEY" },
123
+ { key: "pincode", type: "PINCODE" },
124
+ ];
125
+
126
+ const appliedFilter = filterMappings.find(({ key }) => debouncedFilters[key]);
127
+
128
+ if (appliedFilter) {
129
+ return {
130
+ assignmentType: appliedFilter.type,
131
+ assignmentValue: debouncedFilters[appliedFilter.key],
132
+ };
133
+ }
134
+ }
135
+
136
+ console.log("=-=-==-=-=-=-", {
137
+ assignmentType: "KNO",
138
+ assignmentValues: selectedKnos,
139
+ });
140
+
141
+ return {
142
+ assignmentType: "KNO",
143
+ assignmentValues: selectedKnos,
144
+ };
145
+ };
103
146
  const handleAssign = () => {
147
+ const { assignmentType, assignmentValue, assignmentValues } = getAssignmentPayload();
148
+
104
149
  assignmentMutation.mutate({
105
150
  tenantId: "dl.djb",
106
- surveyorId: surveyor?.uuid,
107
- assignmentType: "KNO",
108
- assignmentValue: getAssignmentValue(),
151
+ surveyorId: surveyor?.owner?.uuid,
152
+ assignmentType,
153
+ assignmentValue,
154
+ assignmentValues,
109
155
  });
110
156
  };
111
157
 
112
158
  const handleSelectAll = () => {
159
+ setIsBulkSelection(true);
160
+
113
161
  const pageKnos = tableData.map((item) => item.kno);
114
162
 
115
163
  const allSelected = pageKnos.length > 0 && pageKnos.every((kno) => selectedKnos.includes(kno));
@@ -224,13 +272,6 @@ const AssignEkycModal = ({ surveyor, closeModal }) => {
224
272
  <option value="APPROVED">Approved</option>
225
273
  <option value="REJECTED">Rejected</option>
226
274
  </select>
227
-
228
- <select className="form-control" value={assignmentType} onChange={(e) => setAssignmentType(e.target.value)}>
229
- <option value="KNO">KNO</option>
230
- <option value="MRKEY">MR Key</option>
231
- <option value="WARD">Ward</option>
232
- <option value="ASSEMBLY">Assembly</option>
233
- </select>
234
275
  </div>
235
276
 
236
277
  {/* Table */}
@@ -267,6 +308,7 @@ const AssignEkycModal = ({ surveyor, closeModal }) => {
267
308
  }}
268
309
  />
269
310
  </div>
311
+ {showToast && <Toast error={toastData.error} label={toastData.label} onClose={() => setShowToast(false)} />}
270
312
  </Modal>
271
313
  );
272
314
  };
@@ -12,8 +12,8 @@ const SearchFormFieldsComponents = ({ searchFormState, controlSearchForm }) => {
12
12
  {/* K NUMBER */}
13
13
  <span className="mobile-input">
14
14
  <Label className="flex-roww flex-gap-2">
15
- {t("EKYC_K_NUMBER") || "K Number"}
16
- <CustomTooltip message={t("EKYC_K_NUMBER_MESSAGE")} />
15
+ {t("EKYC_MOBILE_NUMBER") || "Mobile Number"}
16
+ <CustomTooltip message={t("EKYC_MOBILE_NUMBER_MESSAGE")} />
17
17
  </Label>
18
18
 
19
19
  <Controller
@@ -29,35 +29,53 @@ const SurveyorDetailsDashboard = () => {
29
29
  return surveyorSearchResponse?.surveyors?.[0] || null;
30
30
  }, [surveyorSearchResponse]);
31
31
 
32
- const knoColumns = React.useMemo(
32
+ const [currentPage, setCurrentPage] = useState(0);
33
+ const [pageSize, setPageSize] = useState(20);
34
+ const queryParams = {
35
+ tenantId: "dl.djb",
36
+ offset: currentPage * pageSize,
37
+ limit: pageSize,
38
+ surveyorId: surveyor?.owner?.uuid,
39
+ };
40
+
41
+ const { isFetching: isDashboardLoading, data: dashboardData = {} } = Digit.Hooks.ekyc.useEkycSurveyorDashboard({}, queryParams, {
42
+ enabled: !!queryParams.tenantId && !!queryParams.surveyorId,
43
+ keepPreviousData: true,
44
+ });
45
+
46
+ const knoColumns = useMemo(
33
47
  () => [
34
48
  {
35
- Header: t("KNO"),
49
+ Header: "KNO",
36
50
  accessor: "kno",
37
51
  },
38
52
  {
39
- Header: t("CONSUMER_NAME"),
40
- accessor: "consumerName",
53
+ Header: "Consumer Name",
54
+ accessor: (row) => `${row.firstName || ""} ${row.middleName || ""} ${row.lastName || ""}`.trim(),
55
+ id: "consumerName",
41
56
  },
42
57
  {
43
- Header: t("MOBILE_NO"),
44
- accessor: "mobileNumber",
58
+ Header: "Zone",
59
+ accessor: "zoneName",
45
60
  },
46
61
  {
47
- Header: t("STATUS"),
48
- accessor: "status",
49
- Cell: ({ value }) => <span className={`status-badge ${value?.toLowerCase() || ""}`}>{value}</span>,
62
+ Header: "Pincode",
63
+ accessor: "pincode",
50
64
  },
51
65
  {
52
- Header: t("ASSIGNED_DATE"),
53
- accessor: "assignedDate",
66
+ Header: "Status",
67
+ accessor: "status",
68
+ Cell: ({ value }) => (
69
+ <span className={`status-badge ${value === "ACTIVE" ? "verified" : value === "PENDING" ? "pending" : "assigned"}`}>{value}</span>
70
+ ),
54
71
  },
55
72
  {
56
- Header: t("COMPLETED_DATE"),
57
- accessor: "completedDate",
73
+ Header: "eKYC Status",
74
+ accessor: "ekycStatus",
75
+ Cell: ({ value }) => value || "-",
58
76
  },
59
77
  ],
60
- [t]
78
+ []
61
79
  );
62
80
 
63
81
  if (isLoading) {
@@ -71,24 +89,6 @@ const SurveyorDetailsDashboard = () => {
71
89
  </Card>
72
90
  );
73
91
  }
74
- const assignedKnos = [
75
- {
76
- kno: "123456789",
77
- consumerName: "Rahul Sharma",
78
- mobileNumber: "9876543210",
79
- status: "Completed",
80
- assignedDate: "01-06-2026",
81
- completedDate: "02-06-2026",
82
- },
83
- {
84
- kno: "123456790",
85
- consumerName: "Amit Kumar",
86
- mobileNumber: "9876543211",
87
- status: "Pending",
88
- assignedDate: "03-06-2026",
89
- completedDate: "-",
90
- },
91
- ];
92
92
 
93
93
  const weeklyData = [
94
94
  { day: "Mon", completed: 4 },
@@ -118,11 +118,19 @@ const SurveyorDetailsDashboard = () => {
118
118
  },
119
119
  ];
120
120
 
121
- const StatCard = ({ title, value, type }) => (
121
+ const StatCard = ({ title, value, type, isLoading }) => (
122
122
  <div className={`stat-card ${type}`}>
123
- <div className="stat-title">{title}</div>
124
-
125
- <div className="stat-value">{value}</div>
123
+ {isLoading ? (
124
+ <React.Fragment>
125
+ <div className="stat-title skeleton skeleton-text"></div>
126
+ <div className="stat-value skeleton skeleton-number"></div>
127
+ </React.Fragment>
128
+ ) : (
129
+ <React.Fragment>
130
+ <div className="stat-title">{title}</div>
131
+ <div className="stat-value">{value}</div>
132
+ </React.Fragment>
133
+ )}
126
134
  </div>
127
135
  );
128
136
 
@@ -158,13 +166,10 @@ const SurveyorDetailsDashboard = () => {
158
166
 
159
167
  {/* Stats */}
160
168
  <div className="stats-wrapper">
161
- <StatCard title={t("TODAYS_EKYC")} value={surveyor?.todayCompleted || 0} type="today" />
162
-
163
- <StatCard title={t("THIS_WEEK")} value={surveyor?.weekCompleted || 0} type="week" />
164
-
165
- <StatCard title={t("THIS_MONTH")} value={surveyor?.monthCompleted || 0} type="month" />
166
-
167
- <StatCard title={t("PENDING_CASES")} value={surveyor?.pendingCases || 0} type="pending" />
169
+ <StatCard title={t("TOTAL_ASSIGNED")} value={dashboardData?.dashboardInfo?.total || 0} type="today" isLoading={isDashboardLoading} />
170
+ <StatCard title={t("COMPLETED")} value={dashboardData?.dashboardInfo?.completed || 0} type="week" isLoading={isDashboardLoading} />
171
+ <StatCard title={t("PENDING")} value={dashboardData?.dashboardInfo?.pending || 0} type="pending" isLoading={isDashboardLoading} />
172
+ <StatCard title={t("SUBMITTED")} value={dashboardData?.dashboardInfo?.submittedCount || 0} type="month" isLoading={isDashboardLoading} />
168
173
  </div>
169
174
 
170
175
  {/* Charts */}
@@ -242,18 +247,40 @@ const SurveyorDetailsDashboard = () => {
242
247
  </div>
243
248
  </div>
244
249
  </div>
245
-
246
- <Table
247
- t={t}
248
- tableTitle={t("ASSIGNED_KNOS")}
249
- data={assignedKnos}
250
- columns={knoColumns}
251
- totalRecords={assignedKnos?.length}
252
- isPaginationRequired={true}
253
- pageSizeLimit={10}
254
- manualPagination={false}
255
- />
256
-
250
+ <Card className="dashboard-card">
251
+ <Table
252
+ t={t}
253
+ tableTitle={t("ASSIGNED_KNOS")}
254
+ tableClass="ekycTable"
255
+ data={dashboardData?.dashboardInfo?.consumerList || []}
256
+ columns={knoColumns}
257
+ isLoading={isDashboardLoading}
258
+ totalRecords={dashboardData?.dashboardInfo?.total}
259
+ currentPage={currentPage}
260
+ pageSizeLimit={pageSize}
261
+ isPaginationRequired={true}
262
+ onNextPage={() => {
263
+ if (currentPage < (dashboardData?.dashboardInfo?.totalPages || 1) - 1) {
264
+ setCurrentPage((prev) => prev + 1);
265
+ }
266
+ }}
267
+ onPrevPage={() => {
268
+ if (currentPage > 0) {
269
+ setCurrentPage((prev) => prev - 1);
270
+ }
271
+ }}
272
+ onFirstPage={() => {
273
+ setCurrentPage(0);
274
+ }}
275
+ onLastPage={() => {
276
+ setCurrentPage(Math.max((dashboardData?.dashboardInfo?.totalPages || 1) - 1, 0));
277
+ }}
278
+ onPageSizeChange={(e) => {
279
+ setPageSize(Number(e.target.value));
280
+ setCurrentPage(0);
281
+ }}
282
+ />
283
+ </Card>
257
284
  {/* Actions */}
258
285
  {(!roles.includes("EKYC_SURVEYOR") || roles.includes("EMPLOYEE")) && (
259
286
  <ActionBar>
@@ -52,7 +52,6 @@ const VendorDetails = () => {
52
52
  rejected: row.rejected,
53
53
  }));
54
54
 
55
- console.log(dashboardData);
56
55
  if (isLoading) <Loader />;
57
56
 
58
57
  return (