@djb25/digit-ui-module-ekyc 1.0.30 → 1.0.32
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 +8911 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +3295 -2039
- package/dist/index.modern.js.map +1 -1
- package/package.json +4 -1
- package/dist/index.css +0 -54
- package/src/Module.js +0 -78
- package/src/components/AadhaarVerification.js +0 -315
- package/src/components/AssignEkyc.js +0 -236
- package/src/components/AssignEkycModal.js +0 -446
- package/src/components/CeoDashboard.js +0 -264
- package/src/components/CeoDashboard.jsx +0 -334
- package/src/components/ConnectionDetailsView.js +0 -241
- package/src/components/Dashboard.js +0 -43
- package/src/components/DesktopInbox.js +0 -176
- package/src/components/EKYCCard.js +0 -53
- package/src/components/Filter.js +0 -55
- package/src/components/MeterDetails.js +0 -336
- package/src/components/MobileInbox.js +0 -73
- package/src/components/PropertyInfo.js +0 -264
- package/src/components/Review.js +0 -696
- package/src/components/SearchConsumer.js +0 -142
- package/src/components/SearchFormFieldsComponent.js +0 -67
- package/src/components/SelectEkycZones.js +0 -71
- package/src/components/StatusCards.js +0 -148
- package/src/components/SurveyorDetailsCard.js +0 -512
- package/src/components/VendorDetails.jsx +0 -230
- package/src/components/analytics/charts/ClusterHeatmap.js +0 -88
- package/src/components/analytics/charts/ExecutiveBarChart.jsx +0 -30
- package/src/components/analytics/charts/ExecutiveLineChart.jsx +0 -159
- package/src/components/analytics/charts/ExecutivePieChart.jsx +0 -24
- package/src/components/analytics/charts/TaskStatusChart.js +0 -90
- package/src/components/analytics/components/AnalyticsTable.js +0 -106
- package/src/components/analytics/components/DashboardLayout.js +0 -52
- package/src/components/analytics/components/EmptyState.js +0 -27
- package/src/components/analytics/components/ErrorBoundary.js +0 -27
- package/src/components/analytics/components/FilterBar.js +0 -73
- package/src/components/analytics/components/NotificationPanel.js +0 -77
- package/src/components/analytics/components/SLAWidget.js +0 -56
- package/src/components/analytics/components/SkeletonLoader.js +0 -53
- package/src/components/analytics/components/SummaryCard.js +0 -74
- package/src/components/analytics/components/WorkflowTimeline.js +0 -55
- package/src/components/analytics/utils/exportUtils.js +0 -64
- package/src/components/analytics/utils/filterSerializer.js +0 -50
- package/src/components/mockData.js +0 -772
- package/src/config/AadhaarVerificationConfig.js +0 -367
- package/src/config/MeterDetailsConfig.js +0 -297
- package/src/config/PropertyInfoConfig.js +0 -145
- package/src/config/config.js +0 -70
- package/src/hook/SupervisorInboxTableConfig.js +0 -80
- package/src/hook/useInboxTableConfig.js +0 -131
- package/src/pages/citizen/Home.js +0 -54
- package/src/pages/citizen/Inbox.js +0 -265
- package/src/pages/citizen/index.js +0 -199
- package/src/pages/employee/ConsumerDetails.js +0 -299
- package/src/pages/employee/Create.js +0 -94
- package/src/pages/employee/EKYCForm.js +0 -118
- package/src/pages/employee/Inbox.js +0 -266
- package/src/pages/employee/Mapping.js +0 -358
- package/src/pages/employee/Update.js +0 -9
- package/src/pages/employee/index.js +0 -184
- package/src/utils/index.js +0 -46
- package/src/utils/reportDownloader.js +0 -90
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useCallback, useReducer } from "react";
|
|
2
|
-
import { useLocation } from "react-router-dom";
|
|
3
|
-
import { InboxComposer } from "@djb25/digit-ui-react-components";
|
|
4
|
-
import useInboxTableConfig from "../../hook/useInboxTableConfig";
|
|
5
|
-
import SearchFormFieldsComponents from "../../components/SearchFormFieldsComponent";
|
|
6
|
-
|
|
7
|
-
// Mock data removed in favor of API integration
|
|
8
|
-
|
|
9
|
-
const Inbox = ({ parentRoute, businessService = "EKYC", initialStates = {}, filterComponent, isInbox }) => {
|
|
10
|
-
const tenantId = Digit.ULBService.getCurrentTenantId();
|
|
11
|
-
const location = useLocation();
|
|
12
|
-
|
|
13
|
-
const formInitValue = {
|
|
14
|
-
filterForm: {},
|
|
15
|
-
searchForm: {},
|
|
16
|
-
tableForm: {
|
|
17
|
-
limit: 10,
|
|
18
|
-
offset: 0,
|
|
19
|
-
sortBy: "createdTime",
|
|
20
|
-
sortOrder: "DESC",
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const [formState, dispatch] = useReducer(formReducer, formInitValue);
|
|
25
|
-
|
|
26
|
-
const filters = useMemo(() => {
|
|
27
|
-
const searchForm = formState?.searchForm || {};
|
|
28
|
-
return {
|
|
29
|
-
...searchForm,
|
|
30
|
-
...(searchForm.kNumber && { kno: searchForm.kNumber }),
|
|
31
|
-
};
|
|
32
|
-
}, [formState?.searchForm]);
|
|
33
|
-
|
|
34
|
-
const queryParams = useMemo(() => {
|
|
35
|
-
return {
|
|
36
|
-
tenantId,
|
|
37
|
-
offset: formState?.tableForm?.offset || 0,
|
|
38
|
-
limit: formState?.tableForm?.limit || 10,
|
|
39
|
-
};
|
|
40
|
-
}, [tenantId, formState?.tableForm?.offset, formState?.tableForm?.limit]);
|
|
41
|
-
|
|
42
|
-
const { isLoading: isListLoading, data: listData = {} } = Digit.Hooks.ekyc.useEkycApplicationList(filters, queryParams, {
|
|
43
|
-
enabled: !!tenantId,
|
|
44
|
-
keepPreviousData: true,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const searchDetails = useMemo(
|
|
48
|
-
() => ({
|
|
49
|
-
kno: formState?.searchForm?.kNumber || "",
|
|
50
|
-
name: formState?.searchForm?.kName || "",
|
|
51
|
-
}),
|
|
52
|
-
[formState?.searchForm?.kNumber, formState?.searchForm?.kName]
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const isSearchActive = !!(searchDetails.kno || searchDetails.name);
|
|
56
|
-
|
|
57
|
-
const { isLoading: isSearchLoading, data: searchData } = Digit.Hooks.ekyc.useSearchConnection(
|
|
58
|
-
{
|
|
59
|
-
tenantId,
|
|
60
|
-
details: searchDetails,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
enabled: !!tenantId && !!searchDetails.kno, // 🔥 important
|
|
64
|
-
keepPreviousData: true,
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
const sourceData = useMemo(() => {
|
|
69
|
-
if (isSearchActive) {
|
|
70
|
-
if (!searchData) return [];
|
|
71
|
-
return [searchData];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return listData?.consumerList || [];
|
|
75
|
-
}, [isSearchActive, searchData, listData]);
|
|
76
|
-
|
|
77
|
-
const filteredData = useMemo(() => {
|
|
78
|
-
return (sourceData || []).map((item) => {
|
|
79
|
-
// ✅ detect search response
|
|
80
|
-
const isSearchItem = !!item.connectionDetails;
|
|
81
|
-
|
|
82
|
-
if (isSearchItem) {
|
|
83
|
-
return {
|
|
84
|
-
applicationNo: item.propertyInfo?.kno || "",
|
|
85
|
-
connectionNo: item.propertyInfo?.kno || "",
|
|
86
|
-
owner: item.connectionDetails?.consumerName || "",
|
|
87
|
-
applicationNumber: item.propertyInfo?.kno || "",
|
|
88
|
-
citizenName: item.connectionDetails?.consumerName || "",
|
|
89
|
-
status: item.connectionDetails?.statusflag || "",
|
|
90
|
-
ekycStatus: (item.connectionDetails?.ekycStatus || item.connectionDetails?.ekycstatus || item.ekycStatus || item.ekycstatus || "NA").toUpperCase(),
|
|
91
|
-
sla: 0,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// ✅ dashboard mapping
|
|
96
|
-
const fullName = [item.firstName, item.middleName, item.lastName].filter(Boolean).join(" ");
|
|
97
|
-
return {
|
|
98
|
-
...item,
|
|
99
|
-
applicationNo: item.kno || item.applicationNumber || "",
|
|
100
|
-
connectionNo: item.kno || "",
|
|
101
|
-
owner: fullName || item.consumerName || item.citizenName || "",
|
|
102
|
-
applicationNumber: item.kno || item.applicationNumber || "",
|
|
103
|
-
citizenName: fullName || item.consumerName || item.citizenName || "",
|
|
104
|
-
status: item.status || "",
|
|
105
|
-
ekycStatus: (item.ekycStatus || item.ekycstatus || "NA").toUpperCase(),
|
|
106
|
-
sla: item.sla ?? 0,
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
}, [sourceData]);
|
|
110
|
-
|
|
111
|
-
const totalRecords = listData?.totalCount || 0;
|
|
112
|
-
|
|
113
|
-
const checkPathName = location.pathname.includes("ekyc/inbox");
|
|
114
|
-
const PropsForInboxLinks = {
|
|
115
|
-
headerText: checkPathName ? "EKYC_MODULE" : "MODULE_SW",
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const SearchFormFields = useCallback(
|
|
119
|
-
({ registerRef, searchFormState, controlSearchForm }) => (
|
|
120
|
-
<SearchFormFieldsComponents {...{ registerRef, searchFormState, controlSearchForm }} searchType="kno" className="search" />
|
|
121
|
-
),
|
|
122
|
-
[]
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
const tableOrderFormDefaultValues = {
|
|
126
|
-
sortBy: "createdTime",
|
|
127
|
-
limit: window.Digit.Utils.browser.isMobile() ? 50 : 10,
|
|
128
|
-
offset: 0,
|
|
129
|
-
sortOrder: "DESC",
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const onSearchFormSubmit = (data) => {
|
|
133
|
-
data.hasOwnProperty("") && delete data?.[""];
|
|
134
|
-
dispatch({ action: "mutateTableForm", data: { ...tableOrderFormDefaultValues }, checkPathName });
|
|
135
|
-
dispatch({ action: "mutateSearchForm", data, checkPathName });
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const searchFormDefaultValues = {
|
|
139
|
-
kNumber: "",
|
|
140
|
-
applicationNumber: "",
|
|
141
|
-
consumerNo: "",
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const onSearchFormReset = (setSearchFormValue) => {
|
|
145
|
-
setSearchFormValue("kNumber", null);
|
|
146
|
-
setSearchFormValue("applicationNumber", null);
|
|
147
|
-
setSearchFormValue("consumerNo", null);
|
|
148
|
-
dispatch({ action: "mutateSearchForm", data: searchFormDefaultValues });
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const propsForSearchForm = {
|
|
152
|
-
SearchFormFields,
|
|
153
|
-
onSearchFormSubmit,
|
|
154
|
-
searchFormDefaultValues: formState?.searchForm,
|
|
155
|
-
resetSearchFormDefaultValues: searchFormDefaultValues,
|
|
156
|
-
onSearchFormReset,
|
|
157
|
-
className: "search-form-wns-inbox",
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const FilterFormFields = useCallback(
|
|
161
|
-
({ registerRef, controlFilterForm, setFilterFormValue, getFilterFormValue }) => <React.Fragment></React.Fragment>,
|
|
162
|
-
[]
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
const propsForFilterForm = {
|
|
166
|
-
FilterFormFields,
|
|
167
|
-
onFilterFormSubmit: () => { },
|
|
168
|
-
filterFormDefaultValues: "",
|
|
169
|
-
resetFilterFormDefaultValues: "",
|
|
170
|
-
onFilterFormReset: () => { },
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
function formReducer(state, payload) {
|
|
174
|
-
const storageKey = payload.checkPathName ? "EKYC.INBOX" : "EKYC.SW.INBOX";
|
|
175
|
-
|
|
176
|
-
// ✅ safety for SLA
|
|
177
|
-
switch (payload.action) {
|
|
178
|
-
case "mutateSearchForm":
|
|
179
|
-
Digit.SessionStorage.set(storageKey, { ...state, searchForm: payload.data });
|
|
180
|
-
return { ...state, searchForm: payload.data };
|
|
181
|
-
|
|
182
|
-
case "mutateFilterForm":
|
|
183
|
-
Digit.SessionStorage.set(storageKey, { ...state, filterForm: payload.data });
|
|
184
|
-
return { ...state, filterForm: payload.data };
|
|
185
|
-
|
|
186
|
-
case "mutateTableForm":
|
|
187
|
-
Digit.SessionStorage.set(storageKey, { ...state, tableForm: payload.data });
|
|
188
|
-
return { ...state, tableForm: payload.data };
|
|
189
|
-
|
|
190
|
-
default:
|
|
191
|
-
return state; // ✅ IMPORTANT
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const onPageSizeChange = (e) => {
|
|
196
|
-
const newLimit = Number(e.target.value);
|
|
197
|
-
|
|
198
|
-
dispatch({
|
|
199
|
-
action: "mutateTableForm",
|
|
200
|
-
data: {
|
|
201
|
-
...formState.tableForm,
|
|
202
|
-
limit: newLimit,
|
|
203
|
-
offset: 0, // reset page
|
|
204
|
-
},
|
|
205
|
-
checkPathName,
|
|
206
|
-
});
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
const onSortingByData = (e) => {
|
|
210
|
-
if (e.length > 0) {
|
|
211
|
-
const [{ id, desc }] = e;
|
|
212
|
-
const sortOrder = desc ? "DESC" : "ASC";
|
|
213
|
-
const sortBy = id;
|
|
214
|
-
|
|
215
|
-
if (!(formState.tableForm.sortBy === sortBy && formState.tableForm.sortOrder === sortOrder)) {
|
|
216
|
-
dispatch({
|
|
217
|
-
action: "mutateTableForm",
|
|
218
|
-
data: {
|
|
219
|
-
...formState.tableForm,
|
|
220
|
-
sortBy: id,
|
|
221
|
-
sortOrder: desc ? "DESC" : "ASC",
|
|
222
|
-
},
|
|
223
|
-
checkPathName,
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
const propsForInboxTable = useInboxTableConfig({
|
|
230
|
-
...{
|
|
231
|
-
parentRoute,
|
|
232
|
-
onPageSizeChange,
|
|
233
|
-
formState,
|
|
234
|
-
totalCount: totalRecords,
|
|
235
|
-
table: filteredData,
|
|
236
|
-
dispatch,
|
|
237
|
-
onSortingByData,
|
|
238
|
-
tenantId,
|
|
239
|
-
checkPathName,
|
|
240
|
-
inboxStyles: { overflowX: "scroll", overflowY: "hidden" },
|
|
241
|
-
tableStyle: { width: "70%" },
|
|
242
|
-
},
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
const isInboxLoading = isListLoading || isSearchLoading;
|
|
246
|
-
|
|
247
|
-
return (
|
|
248
|
-
<div className="app-container">
|
|
249
|
-
<InboxComposer
|
|
250
|
-
{...{
|
|
251
|
-
isInboxLoading,
|
|
252
|
-
// PropsForInboxLinks,
|
|
253
|
-
...propsForSearchForm,
|
|
254
|
-
// ...propsForFilterForm,
|
|
255
|
-
// ...propsForMobileSortForm,
|
|
256
|
-
propsForInboxTable,
|
|
257
|
-
// propsForInboxMobileCards,
|
|
258
|
-
formState,
|
|
259
|
-
countData: listData,
|
|
260
|
-
}}
|
|
261
|
-
/>
|
|
262
|
-
</div>
|
|
263
|
-
);
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
export default Inbox;
|
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
import React, { useState, useMemo } from "react";
|
|
2
|
-
import {
|
|
3
|
-
Header,
|
|
4
|
-
Card,
|
|
5
|
-
CardHeader,
|
|
6
|
-
CardText,
|
|
7
|
-
CardLabel,
|
|
8
|
-
Dropdown,
|
|
9
|
-
SubmitBar,
|
|
10
|
-
ActionBar,
|
|
11
|
-
Table,
|
|
12
|
-
Toast,
|
|
13
|
-
LabelFieldPair,
|
|
14
|
-
Modal,
|
|
15
|
-
DeleteIcon,
|
|
16
|
-
EditIcon,
|
|
17
|
-
} from "@djb25/digit-ui-react-components";
|
|
18
|
-
import { useTranslation } from "react-i18next";
|
|
19
|
-
|
|
20
|
-
// ─── Static Mock Data ─────────────────────────────────────────────────────────
|
|
21
|
-
|
|
22
|
-
const MOCK_SURVEYORS = [
|
|
23
|
-
{ name: "Amit Kumar", id: "SVR001", role: "Surveyor" },
|
|
24
|
-
{ name: "Sanjay Singh", id: "SVR002", role: "Surveyor" },
|
|
25
|
-
{ name: "Rahul Sharma", id: "SVR003", role: "Surveyor" },
|
|
26
|
-
{ name: "Priya Verma", id: "SVR004", role: "Surveyor" },
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
const MOCK_MRDS = [
|
|
30
|
-
{ name: "MRD - 01 (Central Zone)", code: "MRD01", zone: "Central" },
|
|
31
|
-
{ name: "MRD - 02 (North Zone)", code: "MRD02", zone: "North" },
|
|
32
|
-
{ name: "MRD - 03 (South Zone)", code: "MRD03", zone: "South" },
|
|
33
|
-
{ name: "MRD - 04 (West Zone)", code: "MRD04", zone: "West" },
|
|
34
|
-
{ name: "MRD - 05 (East Zone)", code: "MRD05", zone: "East" },
|
|
35
|
-
{ name: "MRD - 06 (Rohini)", code: "MRD06", zone: "Rohini" },
|
|
36
|
-
{ name: "MRD - 07 (Dwarka)", code: "MRD07", zone: "Dwarka" },
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
// ─── Main Component ───────────────────────────────────────────────────────────
|
|
40
|
-
|
|
41
|
-
const Mapping = () => {
|
|
42
|
-
const { t } = useTranslation();
|
|
43
|
-
|
|
44
|
-
// Form state
|
|
45
|
-
const [selectedSurveyor, setSelectedSurveyor] = useState(null);
|
|
46
|
-
const [selectedMRD, setSelectedMRD] = useState(null);
|
|
47
|
-
|
|
48
|
-
// Mappings list
|
|
49
|
-
const [mappings, setMappings] = useState([]);
|
|
50
|
-
|
|
51
|
-
// Edit state: stores the id of the row being edited + its draft values
|
|
52
|
-
const [editingId, setEditingId] = useState(null);
|
|
53
|
-
const [editSurveyor, setEditSurveyor] = useState(null);
|
|
54
|
-
const [editMRD, setEditMRD] = useState(null);
|
|
55
|
-
|
|
56
|
-
// Delete confirm modal
|
|
57
|
-
const [deleteTarget, setDeleteTarget] = useState(null);
|
|
58
|
-
|
|
59
|
-
const [toast, setToast] = useState(null);
|
|
60
|
-
|
|
61
|
-
// ── Handlers ──────────────────────────────────────────────────────────────
|
|
62
|
-
|
|
63
|
-
const handleAddMapping = () => {
|
|
64
|
-
if (!selectedSurveyor || !selectedMRD) {
|
|
65
|
-
setToast({ type: "error", message: t("EKYC_SELECT_BOTH_ERROR") || "Please select both Surveyor and MRD" });
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const exists = mappings.some(
|
|
69
|
-
m => m.surveyorId === selectedSurveyor.id && m.mrdCode === selectedMRD.code
|
|
70
|
-
);
|
|
71
|
-
if (exists) {
|
|
72
|
-
setToast({ type: "warning", message: t("EKYC_MAPPING_EXISTS") || "This mapping already exists" });
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
setMappings(prev => [...prev, {
|
|
76
|
-
id: Date.now(),
|
|
77
|
-
surveyorName: selectedSurveyor.name,
|
|
78
|
-
surveyorId: selectedSurveyor.id,
|
|
79
|
-
mrdName: selectedMRD.name,
|
|
80
|
-
mrdCode: selectedMRD.code,
|
|
81
|
-
zone: selectedMRD.zone,
|
|
82
|
-
}]);
|
|
83
|
-
setSelectedMRD(null);
|
|
84
|
-
setSelectedSurveyor(null);
|
|
85
|
-
setToast({ type: "success", message: t("EKYC_MAPPING_ADDED") || "Mapping added successfully" });
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const handleEditStart = (row) => {
|
|
89
|
-
setEditingId(row.id);
|
|
90
|
-
setEditSurveyor(MOCK_SURVEYORS.find(s => s.id === row.surveyorId) || null);
|
|
91
|
-
setEditMRD(MOCK_MRDS.find(m => m.code === row.mrdCode) || null);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const handleEditSave = (id) => {
|
|
95
|
-
if (!editSurveyor || !editMRD) {
|
|
96
|
-
setToast({ type: "error", message: t("EKYC_SELECT_BOTH_ERROR") || "Please select both Surveyor and MRD to save" });
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
// Check duplicate (excluding self)
|
|
100
|
-
const duplicate = mappings.some(
|
|
101
|
-
m => m.id !== id && m.surveyorId === editSurveyor.id && m.mrdCode === editMRD.code
|
|
102
|
-
);
|
|
103
|
-
if (duplicate) {
|
|
104
|
-
setToast({ type: "warning", message: t("EKYC_MAPPING_EXISTS") || "This mapping already exists" });
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
setMappings(prev => prev.map(m => m.id !== id ? m : {
|
|
108
|
-
...m,
|
|
109
|
-
surveyorName: editSurveyor.name,
|
|
110
|
-
surveyorId: editSurveyor.id,
|
|
111
|
-
mrdName: editMRD.name,
|
|
112
|
-
mrdCode: editMRD.code,
|
|
113
|
-
zone: editMRD.zone,
|
|
114
|
-
}));
|
|
115
|
-
setEditingId(null);
|
|
116
|
-
setToast({ type: "success", message: t("EKYC_MAPPING_UPDATED") || "Mapping updated successfully" });
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const handleEditCancel = () => {
|
|
120
|
-
setEditingId(null);
|
|
121
|
-
setEditSurveyor(null);
|
|
122
|
-
setEditMRD(null);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const handleDeleteConfirm = () => {
|
|
126
|
-
setMappings(prev => prev.filter(m => m.id !== deleteTarget.id));
|
|
127
|
-
setDeleteTarget(null);
|
|
128
|
-
setToast({ type: "success", message: t("EKYC_MAPPING_REMOVED") || "Mapping removed" });
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const handleSaveMappings = () => {
|
|
132
|
-
if (mappings.length === 0) {
|
|
133
|
-
setToast({ type: "error", message: t("EKYC_NO_MAPPINGS_TO_SAVE") || "No mappings to save" });
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
// TODO: replace with real API call
|
|
137
|
-
setToast({ type: "success", message: t("EKYC_MAPPINGS_SAVED_SUCCESS") || "Surveyor mappings saved successfully!" });
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
// ── Table columns ─────────────────────────────────────────────────────────
|
|
141
|
-
|
|
142
|
-
const columns = useMemo(() => [
|
|
143
|
-
{
|
|
144
|
-
Header: t("EKYC_SURVEYOR_NAME") || "Surveyor",
|
|
145
|
-
accessor: "surveyorName",
|
|
146
|
-
Cell: ({ row }) => {
|
|
147
|
-
const isEditing = editingId === row.original.id;
|
|
148
|
-
if (isEditing) {
|
|
149
|
-
return (
|
|
150
|
-
<Dropdown
|
|
151
|
-
selected={editSurveyor}
|
|
152
|
-
select={setEditSurveyor}
|
|
153
|
-
option={MOCK_SURVEYORS}
|
|
154
|
-
optionKey="name"
|
|
155
|
-
t={t}
|
|
156
|
-
placeholder={t("EKYC_SELECT_SURVEYOR_PLACEHOLDER") || "Choose surveyor..."}
|
|
157
|
-
/>
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
return (
|
|
161
|
-
<div>
|
|
162
|
-
<span className="link">{row.original.surveyorName}</span>
|
|
163
|
-
<div style={{ fontSize: "12px", color: "#666" }}>{row.original.surveyorId}</div>
|
|
164
|
-
</div>
|
|
165
|
-
);
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
Header: t("EKYC_MRD_ASSIGNED") || "MRD Assigned",
|
|
170
|
-
accessor: "mrdName",
|
|
171
|
-
Cell: ({ row }) => {
|
|
172
|
-
const isEditing = editingId === row.original.id;
|
|
173
|
-
if (isEditing) {
|
|
174
|
-
return (
|
|
175
|
-
<Dropdown
|
|
176
|
-
selected={editMRD}
|
|
177
|
-
select={setEditMRD}
|
|
178
|
-
option={MOCK_MRDS}
|
|
179
|
-
optionKey="name"
|
|
180
|
-
t={t}
|
|
181
|
-
placeholder={t("EKYC_SELECT_MRD_PLACEHOLDER") || "Choose MRD..."}
|
|
182
|
-
/>
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
return (
|
|
186
|
-
<div>
|
|
187
|
-
<span>{row.original.mrdName}</span>
|
|
188
|
-
<div style={{ fontSize: "12px", color: "#666" }}>{row.original.zone}</div>
|
|
189
|
-
</div>
|
|
190
|
-
);
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
Header: t("ES_COMMON_ACTION") || "Actions",
|
|
195
|
-
Cell: ({ row }) => {
|
|
196
|
-
const isEditing = editingId === row.original.id;
|
|
197
|
-
if (isEditing) {
|
|
198
|
-
return (
|
|
199
|
-
<div style={{ display: "flex", gap: "10px" }}>
|
|
200
|
-
<span
|
|
201
|
-
style={{ cursor: "pointer", color: "#f47738", fontWeight: "bold" }}
|
|
202
|
-
onClick={() => handleEditSave(row.original.id)}
|
|
203
|
-
>
|
|
204
|
-
{t("ES_COMMON_SAVE")}
|
|
205
|
-
</span>
|
|
206
|
-
<span
|
|
207
|
-
style={{ cursor: "pointer", color: "#505A5F", fontWeight: "bold" }}
|
|
208
|
-
onClick={handleEditCancel}
|
|
209
|
-
>
|
|
210
|
-
{t("ES_COMMON_CANCEL")}
|
|
211
|
-
</span>
|
|
212
|
-
</div>
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
return (
|
|
216
|
-
<div style={{ display: "flex", gap: "16px" }}>
|
|
217
|
-
<span onClick={() => handleEditStart(row.original)} style={{ cursor: "pointer" }}>
|
|
218
|
-
<EditIcon className="icon" fill="#f47738" />
|
|
219
|
-
</span>
|
|
220
|
-
<span onClick={() => setDeleteTarget(row.original)} style={{ cursor: "pointer" }}>
|
|
221
|
-
<DeleteIcon className="icon" fill="#f47738" />
|
|
222
|
-
</span>
|
|
223
|
-
</div>
|
|
224
|
-
);
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
], [editingId, editSurveyor, editMRD, mappings, t]);
|
|
228
|
-
|
|
229
|
-
// ── Render ────────────────────────────────────────────────────────────────
|
|
230
|
-
|
|
231
|
-
return (
|
|
232
|
-
<React.Fragment>
|
|
233
|
-
<div className="side-panel-item">
|
|
234
|
-
<Card className="employeeCard filter inboxLinks" style={{ marginTop: "16px" }}>
|
|
235
|
-
<div className="complaint-links-container">
|
|
236
|
-
<div className="header" style={{ marginBottom: "0px" }}>
|
|
237
|
-
<span className="logo">
|
|
238
|
-
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
239
|
-
<path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20" stroke="white" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
|
|
240
|
-
<path d="M6.5 2H20V22H6.5A2.5 2.5 0 0 1 4 19.5V4.5A2.5 2.5 0 0 1 6.5 2Z" stroke="white" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
|
|
241
|
-
</svg>
|
|
242
|
-
</span>
|
|
243
|
-
<span className="text">{t("EKYC_SURVEYOR_MAPPING") || "Surveyor Mapping"}</span>
|
|
244
|
-
</div>
|
|
245
|
-
</div>
|
|
246
|
-
</Card>
|
|
247
|
-
</div>
|
|
248
|
-
|
|
249
|
-
<Card>
|
|
250
|
-
<CardHeader>{t("EKYC_NEW_MAPPING") || "New Mapping"}</CardHeader>
|
|
251
|
-
<CardText>
|
|
252
|
-
{t("EKYC_MAPPING_SUBHEADER") || "Assign Meter Reading Dairies to surveyors to manage their data access."}
|
|
253
|
-
</CardText>
|
|
254
|
-
|
|
255
|
-
<LabelFieldPair>
|
|
256
|
-
<CardLabel>{t("EKYC_SELECT_SURVEYOR") || "Select Surveyor"} *</CardLabel>
|
|
257
|
-
<div className="">
|
|
258
|
-
<Dropdown
|
|
259
|
-
selected={selectedSurveyor}
|
|
260
|
-
select={setSelectedSurveyor}
|
|
261
|
-
option={MOCK_SURVEYORS}
|
|
262
|
-
optionKey="name"
|
|
263
|
-
t={t}
|
|
264
|
-
placeholder={t("EKYC_SELECT_SURVEYOR_PLACEHOLDER") || "Choose a surveyor..."}
|
|
265
|
-
/>
|
|
266
|
-
</div>
|
|
267
|
-
</LabelFieldPair>
|
|
268
|
-
|
|
269
|
-
<LabelFieldPair>
|
|
270
|
-
<CardLabel>{t("EKYC_SELECT_MRD") || "Select MRD"} *</CardLabel>
|
|
271
|
-
<div className="field">
|
|
272
|
-
<Dropdown
|
|
273
|
-
selected={selectedMRD}
|
|
274
|
-
select={setSelectedMRD}
|
|
275
|
-
option={MOCK_MRDS}
|
|
276
|
-
optionKey="name"
|
|
277
|
-
t={t}
|
|
278
|
-
placeholder={t("EKYC_SELECT_MRD_PLACEHOLDER") || "Choose an MRD..."}
|
|
279
|
-
/>
|
|
280
|
-
</div>
|
|
281
|
-
</LabelFieldPair>
|
|
282
|
-
|
|
283
|
-
<div style={{ display: "flex", justifyContent: "flex-end", marginTop: "24px" }}>
|
|
284
|
-
<SubmitBar
|
|
285
|
-
label={t("EKYC_ADD_TO_LIST") || "Add to Mapping List"}
|
|
286
|
-
onSubmit={handleAddMapping}
|
|
287
|
-
disabled={!selectedSurveyor || !selectedMRD}
|
|
288
|
-
/>
|
|
289
|
-
</div>
|
|
290
|
-
</Card>
|
|
291
|
-
|
|
292
|
-
{mappings.length > 0 && (
|
|
293
|
-
<Card>
|
|
294
|
-
<CardHeader>
|
|
295
|
-
{t("EKYC_MAPPING_SUMMARY") || "Mapping Summary"} ({mappings.length})
|
|
296
|
-
</CardHeader>
|
|
297
|
-
<Table
|
|
298
|
-
t={t}
|
|
299
|
-
data={mappings}
|
|
300
|
-
columns={columns}
|
|
301
|
-
getCellProps={(cellInfo) => {
|
|
302
|
-
return {
|
|
303
|
-
style: {
|
|
304
|
-
padding: "10px",
|
|
305
|
-
fontSize: "16px",
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
|
-
}}
|
|
309
|
-
tableClassName="table digit-table"
|
|
310
|
-
/>
|
|
311
|
-
</Card>
|
|
312
|
-
)}
|
|
313
|
-
|
|
314
|
-
{mappings.length > 0 && (
|
|
315
|
-
<ActionBar>
|
|
316
|
-
<SubmitBar
|
|
317
|
-
label={t("EKYC_SAVE_MAPPINGS") || "Save Mappings"}
|
|
318
|
-
onSubmit={handleSaveMappings}
|
|
319
|
-
/>
|
|
320
|
-
</ActionBar>
|
|
321
|
-
)}
|
|
322
|
-
|
|
323
|
-
{deleteTarget && (
|
|
324
|
-
<Modal
|
|
325
|
-
headerBarMain={t("EKYC_REMOVE_MAPPING") || "Remove Mapping"}
|
|
326
|
-
headerBarEnd={
|
|
327
|
-
<span onClick={() => setDeleteTarget(null)} style={{ cursor: "pointer", padding: "8px" }}>
|
|
328
|
-
X
|
|
329
|
-
</span>
|
|
330
|
-
}
|
|
331
|
-
actionSaveLabel={t("ES_COMMON_REMOVE")}
|
|
332
|
-
actionSaveOnSubmit={handleDeleteConfirm}
|
|
333
|
-
actionCancelLabel={t("ES_COMMON_CANCEL")}
|
|
334
|
-
actionCancelOnSubmit={() => setDeleteTarget(null)}
|
|
335
|
-
style={{ borderRadius: "12px" }}
|
|
336
|
-
>
|
|
337
|
-
<CardText style={{ marginTop: "16px", marginBottom: "16px" }}>
|
|
338
|
-
{t("EKYC_REMOVE_MAPPING_CONFIRM_MSG") || "Are you sure you want to remove the mapping between "}
|
|
339
|
-
<strong>{deleteTarget?.surveyorName}</strong> and <strong>{deleteTarget?.mrdName}</strong>?
|
|
340
|
-
</CardText>
|
|
341
|
-
</Modal>
|
|
342
|
-
)}
|
|
343
|
-
|
|
344
|
-
{toast && (
|
|
345
|
-
<Toast
|
|
346
|
-
label={toast.message}
|
|
347
|
-
error={toast.type === "error"}
|
|
348
|
-
warning={toast.type === "warning"}
|
|
349
|
-
info={toast.type === "info"}
|
|
350
|
-
isDsc={true}
|
|
351
|
-
onClose={() => setToast(null)}
|
|
352
|
-
/>
|
|
353
|
-
)}
|
|
354
|
-
</React.Fragment>
|
|
355
|
-
);
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
export default Mapping;
|