@djb25/digit-ui-module-ekyc 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +3594 -4315
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
- package/src/Module.js +37 -31
- package/src/components/ConnectionDetailsView.js +5 -3
- package/src/components/Dashboard.js +43 -0
- package/src/components/DesktopInbox.js +68 -184
- package/src/components/EKYCCard.js +35 -27
- package/src/components/Filter.js +48 -53
- package/src/components/SearchFormFieldsComponent.js +55 -0
- package/src/components/StatusCards.js +7 -3
- package/src/config/config.js +69 -0
- package/src/hook/useInboxTableConfig.js +134 -0
- package/src/pages/citizen/Home.js +41 -0
- package/src/pages/citizen/Inbox.js +255 -0
- package/src/pages/citizen/index.js +44 -65
- package/src/pages/employee/AadhaarVerification.js +473 -609
- package/src/pages/employee/AddressDetails.js +508 -733
- package/src/pages/employee/ConsumerDetails.js +512 -0
- package/src/pages/employee/Create.js +5 -1
- package/src/pages/employee/EKYCForm.js +117 -0
- package/src/pages/employee/Inbox.js +248 -140
- package/src/pages/employee/Mapping.js +640 -6
- package/src/pages/employee/MeterDetails.js +481 -471
- package/src/pages/employee/PropertyInfo.js +472 -562
- package/src/pages/employee/Review.js +268 -540
- package/src/pages/employee/Update.js +9 -0
- package/src/pages/employee/index.js +59 -94
package/src/components/Filter.js
CHANGED
|
@@ -1,60 +1,55 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
import { Dropdown, FilterForm, FilterFormField } from "@djb25/digit-ui-react-components";
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
|
4
4
|
|
|
5
5
|
const Filter = ({ searchParams, onFilterChange, defaultSearchParams, statusMap, moduleCode, ...props }) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
selected={_searchParams?.status || { label: t("EKYC_STATUS_ALL"), value: "" }}
|
|
54
|
-
/>
|
|
55
|
-
</FilterFormField>
|
|
56
|
-
</FilterForm>
|
|
57
|
-
);
|
|
6
|
+
const { t } = useTranslation();
|
|
7
|
+
|
|
8
|
+
const [_searchParams, setSearchParams] = useState(() => ({ ...searchParams }));
|
|
9
|
+
|
|
10
|
+
const applyLocalFilters = () => {
|
|
11
|
+
onFilterChange(_searchParams);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const clearAll = () => {
|
|
15
|
+
setSearchParams({ ...defaultSearchParams });
|
|
16
|
+
onFilterChange({ ...defaultSearchParams });
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const onStatusChange = (value) => {
|
|
20
|
+
const newParams = { ..._searchParams, status: value };
|
|
21
|
+
setSearchParams(newParams);
|
|
22
|
+
onFilterChange(newParams);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<FilterForm
|
|
27
|
+
onSubmit={applyLocalFilters}
|
|
28
|
+
handleSubmit={(fn) => (e) => {
|
|
29
|
+
e && e.preventDefault();
|
|
30
|
+
fn();
|
|
31
|
+
}}
|
|
32
|
+
onResetFilterForm={clearAll}
|
|
33
|
+
id="ekyc-filter-form"
|
|
34
|
+
onMobileExclusiveFilterPopupFormClose={props.onClose}
|
|
35
|
+
>
|
|
36
|
+
<FilterFormField>
|
|
37
|
+
<div className="filter-label" style={{ fontWeight: "normal" }}>
|
|
38
|
+
{t("EKYC_STATUS")}:
|
|
39
|
+
</div>
|
|
40
|
+
<Dropdown
|
|
41
|
+
option={[
|
|
42
|
+
{ label: t("EKYC_STATUS_ALL"), value: "" },
|
|
43
|
+
{ label: t("EKYC_STATUS_ACTIVE"), value: "ACTIVE" },
|
|
44
|
+
{ label: t("EKYC_STATUS_PENDING"), value: "PENDING START" },
|
|
45
|
+
]}
|
|
46
|
+
optionKey="label"
|
|
47
|
+
select={onStatusChange}
|
|
48
|
+
selected={_searchParams?.status || { label: t("EKYC_STATUS_ALL"), value: "" }}
|
|
49
|
+
/>
|
|
50
|
+
</FilterFormField>
|
|
51
|
+
</FilterForm>
|
|
52
|
+
);
|
|
58
53
|
};
|
|
59
54
|
|
|
60
55
|
export default Filter;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Controller } from "react-hook-form";
|
|
3
|
+
import { CardLabelError, TextInput, Tooltip, Label } from "@djb25/digit-ui-react-components";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
|
|
6
|
+
const SearchFormFieldsComponents = ({ searchFormState, controlSearchForm }) => {
|
|
7
|
+
const { t } = useTranslation();
|
|
8
|
+
const { errors } = searchFormState;
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<React.Fragment>
|
|
12
|
+
{/* K NUMBER */}
|
|
13
|
+
<span className="mobile-input">
|
|
14
|
+
<Label className="flex-roww flex-gap-2">
|
|
15
|
+
{t("EKYC_K_NUMBER") || "K Number"}
|
|
16
|
+
<Tooltip message={t("EKYC_K_NUMBER_MESSAGE")} />
|
|
17
|
+
</Label>
|
|
18
|
+
|
|
19
|
+
<Controller
|
|
20
|
+
name="kNumber"
|
|
21
|
+
control={controlSearchForm}
|
|
22
|
+
defaultValue=""
|
|
23
|
+
rules={{
|
|
24
|
+
pattern: {
|
|
25
|
+
value: /^[a-zA-Z0-9-_/]*$/,
|
|
26
|
+
message: t("ERR_INVALID_APPLICATION_NO"),
|
|
27
|
+
},
|
|
28
|
+
}}
|
|
29
|
+
render={({ onChange, value }) => <TextInput value={value || ""} onChange={(e) => onChange(e.target.value)} />}
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
{errors?.kNumber && <CardLabelError>{errors.kNumber.message}</CardLabelError>}
|
|
33
|
+
</span>
|
|
34
|
+
|
|
35
|
+
{/* K NAME */}
|
|
36
|
+
{/* <span className="mobile-input">
|
|
37
|
+
<Label className="flex-roww flex-gap-2">
|
|
38
|
+
{t("EKYC_K_NAME") || "K Name"}
|
|
39
|
+
<Tooltip message={t("EKYC_K_NAME_MESSAGE")} />
|
|
40
|
+
</Label>
|
|
41
|
+
|
|
42
|
+
<Controller
|
|
43
|
+
name="kName"
|
|
44
|
+
control={controlSearchForm}
|
|
45
|
+
defaultValue=""
|
|
46
|
+
render={({ onChange, value }) => <TextInput value={value || ""} onChange={(e) => onChange(e.target.value)} />}
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
{errors?.kName && <CardLabelError>{errors.kName.message}</CardLabelError>}
|
|
50
|
+
</span> */}
|
|
51
|
+
</React.Fragment>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default SearchFormFieldsComponents;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from "react";
|
|
2
2
|
import { useTranslation } from "react-i18next";
|
|
3
|
-
import
|
|
3
|
+
import * as Chartjs from "chart.js/auto";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const getChartConstructor = () => {
|
|
6
|
+
const C = Chartjs.Chart || Chartjs.default || Chartjs;
|
|
7
|
+
return C;
|
|
8
|
+
};
|
|
6
9
|
|
|
7
10
|
const StatusCards = ({ countData }) => {
|
|
8
11
|
const { t } = useTranslation();
|
|
@@ -27,7 +30,8 @@ const StatusCards = ({ countData }) => {
|
|
|
27
30
|
if (chartRef1.current) {
|
|
28
31
|
if (chartInstance1.current) chartInstance1.current.destroy();
|
|
29
32
|
const ctx1 = chartRef1.current.getContext("2d");
|
|
30
|
-
|
|
33
|
+
const ChartConstructor = getChartConstructor();
|
|
34
|
+
chartInstance1.current = new ChartConstructor(ctx1, {
|
|
31
35
|
type: "doughnut",
|
|
32
36
|
data: {
|
|
33
37
|
labels: [t("EKYC_ACTIVE"), t("EKYC_PENDING"), t("EKYC_COMPLETED")],
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import AadhaarVerification from "../pages/employee/AadhaarVerification";
|
|
2
|
+
|
|
3
|
+
export const ekycConfig = [
|
|
4
|
+
{
|
|
5
|
+
body: [
|
|
6
|
+
{
|
|
7
|
+
route: "consumer-details",
|
|
8
|
+
component: AadhaarVerification,
|
|
9
|
+
key: "aadhaarVerification",
|
|
10
|
+
texts: {
|
|
11
|
+
header: "EKYC_CONSUMER_CONNECTION",
|
|
12
|
+
submitBarLabel: "COMMON_SAVE_NEXT",
|
|
13
|
+
},
|
|
14
|
+
timeLine: [
|
|
15
|
+
{
|
|
16
|
+
currentStep: 1,
|
|
17
|
+
actions: "EKYC_CONSUMER_CONNECTION",
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
route: "address-details",
|
|
23
|
+
component: "AddressDetails",
|
|
24
|
+
key: "addressDetails",
|
|
25
|
+
doorImage: true,
|
|
26
|
+
texts: {
|
|
27
|
+
header: "EKYC_ADDRESS_DETAILS",
|
|
28
|
+
submitBarLabel: "COMMON_SAVE_NEXT",
|
|
29
|
+
},
|
|
30
|
+
timeLine: [
|
|
31
|
+
{
|
|
32
|
+
currentStep: 2,
|
|
33
|
+
actions: "EKYC_ADDRESS_DETAILS",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
route: "property-info",
|
|
39
|
+
component: "PropertyInfo",
|
|
40
|
+
key: "propertyDetails",
|
|
41
|
+
texts: {
|
|
42
|
+
header: "EKYC_PROPERTY_INFO",
|
|
43
|
+
submitBarLabel: "COMMON_SAVE_NEXT",
|
|
44
|
+
},
|
|
45
|
+
timeLine: [
|
|
46
|
+
{
|
|
47
|
+
currentStep: 3,
|
|
48
|
+
actions: "EKYC_PROPERTY_INFO",
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
route: "meter-details",
|
|
54
|
+
component: "MeterDetails",
|
|
55
|
+
key: "meterDetails",
|
|
56
|
+
texts: {
|
|
57
|
+
header: "EKYC_METER_DETAILS",
|
|
58
|
+
submitBarLabel: "COMMON_SAVE_NEXT",
|
|
59
|
+
},
|
|
60
|
+
timeLine: [
|
|
61
|
+
{
|
|
62
|
+
currentStep: 4,
|
|
63
|
+
actions: "EKYC_METER_DETAILS",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
];
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { useHistory } from "react-router-dom";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
|
|
5
|
+
const useInboxTableConfig = ({
|
|
6
|
+
parentRoute,
|
|
7
|
+
onPageSizeChange,
|
|
8
|
+
formState,
|
|
9
|
+
totalCount,
|
|
10
|
+
table,
|
|
11
|
+
dispatch,
|
|
12
|
+
checkPathName,
|
|
13
|
+
onSortingByData,
|
|
14
|
+
tenantId,
|
|
15
|
+
inboxStyles = {},
|
|
16
|
+
tableStyle = {},
|
|
17
|
+
}) => {
|
|
18
|
+
const { t } = useTranslation();
|
|
19
|
+
const history = useHistory();
|
|
20
|
+
const [selectedKno, setSelectedKno] = useState("");
|
|
21
|
+
const { data: reviewData, getReview } = Digit.Hooks.ekyc.useEkycAPI("review", tenantId);
|
|
22
|
+
const handleReview = (kno) => {
|
|
23
|
+
setSelectedKno(kno);
|
|
24
|
+
getReview({ kno });
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const limit = formState?.tableForm?.limit || 10;
|
|
28
|
+
const offset = formState?.tableForm?.offset || 0;
|
|
29
|
+
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
if (reviewData) {
|
|
32
|
+
history.push("/digit-ui/employee/ekyc/review", { kNumber: selectedKno, aadhaarData: reviewData?.aadhaarData, reviewData });
|
|
33
|
+
}
|
|
34
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
+
}, [reviewData]);
|
|
36
|
+
|
|
37
|
+
const tableColumnConfig = [
|
|
38
|
+
{
|
|
39
|
+
Header: t("EKYC_APPLICATION_NO"),
|
|
40
|
+
accessor: "applicationNumber",
|
|
41
|
+
disableSortBy: true,
|
|
42
|
+
Cell: ({ row }) => {
|
|
43
|
+
const kno = row.original?.kno || row.original?.applicationNumber || "NA";
|
|
44
|
+
return (
|
|
45
|
+
<span
|
|
46
|
+
className="ekyc-application-link"
|
|
47
|
+
style={{ color: "#add8f7", cursor: "pointer", fontWeight: "bold" }}
|
|
48
|
+
onClick={() => handleReview(kno)}
|
|
49
|
+
>
|
|
50
|
+
{kno}
|
|
51
|
+
</span>
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
Header: t("EKYC_CITIZEN_NAME"),
|
|
57
|
+
accessor: "citizenName",
|
|
58
|
+
Cell: ({ row }) => <span>{row.original?.citizenName || "NA"}</span>,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
Header: t("EKYC_STATUS"),
|
|
62
|
+
accessor: "actionStatus",
|
|
63
|
+
Cell: ({ row }) => {
|
|
64
|
+
const status = row.original?.status || "DEFAULT";
|
|
65
|
+
return <span className={`ekyc-status-tag ${status}`}>{t(`${status}`)}</span>;
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
Header: t("EKYC_ACTION"),
|
|
70
|
+
accessor: "status",
|
|
71
|
+
Cell: ({ row }) => {
|
|
72
|
+
const kno = row.original?.kno || row.original?.applicationNumber || "NA";
|
|
73
|
+
return (
|
|
74
|
+
<span
|
|
75
|
+
className="ekyc-application-link"
|
|
76
|
+
style={{ color: "#add8f7", cursor: "pointer", fontWeight: "bold" }}
|
|
77
|
+
onClick={() => handleReview(kno)}
|
|
78
|
+
>
|
|
79
|
+
{t("EKYC_REVIEW")}
|
|
80
|
+
</span>
|
|
81
|
+
);
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
getCellProps: (cellInfo) => {
|
|
88
|
+
return {
|
|
89
|
+
style: {
|
|
90
|
+
padding: "8px",
|
|
91
|
+
fontSize: "12px",
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
disableSort: false,
|
|
96
|
+
autoSort: false,
|
|
97
|
+
manualPagination: true,
|
|
98
|
+
initSortId: "applicationDate",
|
|
99
|
+
onPageSizeChange: onPageSizeChange,
|
|
100
|
+
currentPage: Math.floor(offset / limit),
|
|
101
|
+
onNextPage: () =>
|
|
102
|
+
dispatch({
|
|
103
|
+
action: "mutateTableForm",
|
|
104
|
+
data: { ...formState.tableForm, offset: parseInt(formState.tableForm?.offset) + parseInt(formState.tableForm?.limit) },
|
|
105
|
+
checkPathName,
|
|
106
|
+
}),
|
|
107
|
+
onPrevPage: () =>
|
|
108
|
+
dispatch({
|
|
109
|
+
action: "mutateTableForm",
|
|
110
|
+
data: { ...formState.tableForm, offset: parseInt(formState.tableForm?.offset) - parseInt(formState.tableForm?.limit) },
|
|
111
|
+
checkPathName,
|
|
112
|
+
}),
|
|
113
|
+
pageSizeLimit: limit,
|
|
114
|
+
onSort: onSortingByData,
|
|
115
|
+
// sortParams: [{id: getValues("sortBy"), desc: getValues("sortOrder") === "DESC" ? true : false}],
|
|
116
|
+
totalRecords: totalCount,
|
|
117
|
+
onSearch: formState?.searchForm?.message,
|
|
118
|
+
onLastPage: () =>
|
|
119
|
+
dispatch({
|
|
120
|
+
action: "mutateTableForm",
|
|
121
|
+
data: { ...formState.tableForm, offset: Math.ceil(totalCount / 10) * 10 - parseInt(formState.tableForm?.limit) },
|
|
122
|
+
checkPathName,
|
|
123
|
+
}),
|
|
124
|
+
onFirstPage: () => dispatch({ action: "mutateTableForm", data: { ...formState.tableForm, offset: 0 }, checkPathName }),
|
|
125
|
+
// globalSearch: {searchForItemsInTable},
|
|
126
|
+
// searchQueryForTable,
|
|
127
|
+
data: table,
|
|
128
|
+
columns: tableColumnConfig,
|
|
129
|
+
inboxStyles: { ...inboxStyles },
|
|
130
|
+
tableStyle: { ...tableStyle },
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export default useInboxTableConfig;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { ModuleLinksView } from "@djb25/digit-ui-react-components";
|
|
4
|
+
const Home = () => {
|
|
5
|
+
const { t } = useTranslation();
|
|
6
|
+
const propsForModuleCard = {
|
|
7
|
+
moduleName: t("ACTION_TEST_EKYC"),
|
|
8
|
+
kpis: [
|
|
9
|
+
{
|
|
10
|
+
count: "-",
|
|
11
|
+
label: t("TOTAL_EKYC"),
|
|
12
|
+
link: `/digit-ui/citizen/ekyc/dashboard`,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
links: [
|
|
16
|
+
{
|
|
17
|
+
label: t("EKYC_DASHBOARD"),
|
|
18
|
+
link: `/digit-ui/citizen/ekyc/dashboard`,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: t("EKYC_INBOX"),
|
|
22
|
+
link: `/digit-ui/citizen/ekyc/inbox`,
|
|
23
|
+
},
|
|
24
|
+
// {
|
|
25
|
+
// label: t("EKYC_CREATE_KYC"),
|
|
26
|
+
// link: `/digit-ui/citizen/ekyc/create-kyc`
|
|
27
|
+
// },
|
|
28
|
+
// {
|
|
29
|
+
// label: t("EKYC_UPDATE_KYC"),
|
|
30
|
+
// link: `/digit-ui/citizen/ekyc/update-kyc`
|
|
31
|
+
// },
|
|
32
|
+
{
|
|
33
|
+
label: t("EKYC_MAPPING"),
|
|
34
|
+
link: `/digit-ui/citizen/ekyc/mapping`,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
return <ModuleLinksView links={propsForModuleCard.links} />;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default Home;
|
|
@@ -0,0 +1,255 @@
|
|
|
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 }) => {
|
|
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 queryParams = useMemo(() => {
|
|
27
|
+
return {
|
|
28
|
+
tenantId,
|
|
29
|
+
offset: formState?.tableForm?.offset || 0,
|
|
30
|
+
limit: formState?.tableForm?.limit || 10,
|
|
31
|
+
search: formState?.searchForm || {},
|
|
32
|
+
};
|
|
33
|
+
}, [tenantId, formState?.tableForm?.offset, formState?.tableForm?.limit, formState?.searchForm]);
|
|
34
|
+
|
|
35
|
+
const { isLoading, data: dashboardData = {} } = Digit.Hooks.ekyc.useEkycSurveyorDashboard({}, queryParams, {
|
|
36
|
+
enabled: !!tenantId,
|
|
37
|
+
keepPreviousData: true,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const searchDetails = useMemo(
|
|
41
|
+
() => ({
|
|
42
|
+
kno: formState?.searchForm?.kNumber || "",
|
|
43
|
+
name: formState?.searchForm?.kName || "",
|
|
44
|
+
}),
|
|
45
|
+
[formState?.searchForm?.kNumber, formState?.searchForm?.kName]
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const isSearchActive = !!(searchDetails.kno || searchDetails.name);
|
|
49
|
+
|
|
50
|
+
const { isLoading: isSearchLoading, data: searchData } = Digit.Hooks.ekyc.useSearchConnection(
|
|
51
|
+
{
|
|
52
|
+
tenantId,
|
|
53
|
+
details: searchDetails,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
enabled: !!tenantId && !!searchDetails.kno, // 🔥 important
|
|
57
|
+
keepPreviousData: true,
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const sourceData = useMemo(() => {
|
|
62
|
+
if (isSearchActive) {
|
|
63
|
+
if (!searchData) return [];
|
|
64
|
+
return [searchData];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return dashboardData?.dashboardInfo?.consumerList || [];
|
|
68
|
+
}, [isSearchActive, searchData, dashboardData]);
|
|
69
|
+
|
|
70
|
+
const filteredData = useMemo(() => {
|
|
71
|
+
return (sourceData || []).map((item) => {
|
|
72
|
+
// ✅ detect search response
|
|
73
|
+
const isSearchItem = !!item.connectionDetails;
|
|
74
|
+
|
|
75
|
+
if (isSearchItem) {
|
|
76
|
+
return {
|
|
77
|
+
applicationNo: item.propertyInfo?.kno || "",
|
|
78
|
+
connectionNo: item.propertyInfo?.kno || "",
|
|
79
|
+
owner: item.connectionDetails?.consumerName || "",
|
|
80
|
+
applicationNumber: item.propertyInfo?.kno || "",
|
|
81
|
+
citizenName: item.connectionDetails?.consumerName || "",
|
|
82
|
+
status: item.connectionDetails?.statusflag || "",
|
|
83
|
+
sla: 0,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ✅ dashboard mapping
|
|
88
|
+
return {
|
|
89
|
+
...item,
|
|
90
|
+
applicationNo: item.kno || item.applicationNumber || "",
|
|
91
|
+
connectionNo: item.connectionNo || "",
|
|
92
|
+
owner: item.consumerName || item.citizenName || "",
|
|
93
|
+
applicationNumber: item.kno || item.applicationNumber || "",
|
|
94
|
+
citizenName: item.consumerName || item.citizenName || "",
|
|
95
|
+
status: item.status || "",
|
|
96
|
+
sla: item.sla ?? 0,
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}, [sourceData]);
|
|
100
|
+
|
|
101
|
+
const totalRecords = dashboardData?.dashboardInfo?.totalRecords || dashboardData?.totalCount || 0;
|
|
102
|
+
|
|
103
|
+
const checkPathName = location.pathname.includes("ekyc/inbox");
|
|
104
|
+
const PropsForInboxLinks = {
|
|
105
|
+
headerText: checkPathName ? "MODULE_WATER" : "MODULE_SW",
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const SearchFormFields = useCallback(
|
|
109
|
+
({ registerRef, searchFormState, controlSearchForm }) => (
|
|
110
|
+
<SearchFormFieldsComponents {...{ registerRef, searchFormState, controlSearchForm }} className="search" />
|
|
111
|
+
),
|
|
112
|
+
[]
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const tableOrderFormDefaultValues = {
|
|
116
|
+
sortBy: "createdTime",
|
|
117
|
+
limit: window.Digit.Utils.browser.isMobile() ? 50 : 10,
|
|
118
|
+
offset: 0,
|
|
119
|
+
sortOrder: "DESC",
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const onSearchFormSubmit = (data) => {
|
|
123
|
+
data.hasOwnProperty("") && delete data?.[""];
|
|
124
|
+
dispatch({ action: "mutateTableForm", data: { ...tableOrderFormDefaultValues }, checkPathName });
|
|
125
|
+
dispatch({ action: "mutateSearchForm", data, checkPathName });
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const searchFormDefaultValues = {
|
|
129
|
+
mobileNumber: "",
|
|
130
|
+
applicationNumber: "",
|
|
131
|
+
consumerNo: "",
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const onSearchFormReset = (setSearchFormValue) => {
|
|
135
|
+
setSearchFormValue("mobileNumber", null);
|
|
136
|
+
setSearchFormValue("applicationNumber", null);
|
|
137
|
+
setSearchFormValue("consumerNo", null);
|
|
138
|
+
dispatch({ action: "mutateSearchForm", data: searchFormDefaultValues });
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const propsForSearchForm = {
|
|
142
|
+
SearchFormFields,
|
|
143
|
+
onSearchFormSubmit,
|
|
144
|
+
searchFormDefaultValues: formState?.searchForm,
|
|
145
|
+
resetSearchFormDefaultValues: searchFormDefaultValues,
|
|
146
|
+
onSearchFormReset,
|
|
147
|
+
className: "search-form-wns-inbox",
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const FilterFormFields = useCallback(
|
|
151
|
+
({ registerRef, controlFilterForm, setFilterFormValue, getFilterFormValue }) => <React.Fragment></React.Fragment>,
|
|
152
|
+
[]
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
const propsForFilterForm = {
|
|
156
|
+
FilterFormFields,
|
|
157
|
+
onFilterFormSubmit: () => {},
|
|
158
|
+
filterFormDefaultValues: "",
|
|
159
|
+
resetFilterFormDefaultValues: "",
|
|
160
|
+
onFilterFormReset: () => {},
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
function formReducer(state, payload) {
|
|
164
|
+
const storageKey = payload.checkPathName ? "EKYC.INBOX" : "EKYC.SW.INBOX";
|
|
165
|
+
|
|
166
|
+
// ✅ safety for SLA
|
|
167
|
+
switch (payload.action) {
|
|
168
|
+
case "mutateSearchForm":
|
|
169
|
+
Digit.SessionStorage.set(storageKey, { ...state, searchForm: payload.data });
|
|
170
|
+
return { ...state, searchForm: payload.data };
|
|
171
|
+
|
|
172
|
+
case "mutateFilterForm":
|
|
173
|
+
Digit.SessionStorage.set(storageKey, { ...state, filterForm: payload.data });
|
|
174
|
+
return { ...state, filterForm: payload.data };
|
|
175
|
+
|
|
176
|
+
case "mutateTableForm":
|
|
177
|
+
Digit.SessionStorage.set(storageKey, { ...state, tableForm: payload.data });
|
|
178
|
+
return { ...state, tableForm: payload.data };
|
|
179
|
+
|
|
180
|
+
default:
|
|
181
|
+
return state; // ✅ IMPORTANT
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const onPageSizeChange = (e) => {
|
|
186
|
+
const newLimit = Number(e.target.value);
|
|
187
|
+
|
|
188
|
+
dispatch({
|
|
189
|
+
action: "mutateTableForm",
|
|
190
|
+
data: {
|
|
191
|
+
...formState.tableForm,
|
|
192
|
+
limit: newLimit,
|
|
193
|
+
offset: 0, // reset page
|
|
194
|
+
},
|
|
195
|
+
checkPathName,
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const onSortingByData = (e) => {
|
|
200
|
+
if (e.length > 0) {
|
|
201
|
+
const [{ id, desc }] = e;
|
|
202
|
+
const sortOrder = desc ? "DESC" : "ASC";
|
|
203
|
+
const sortBy = id;
|
|
204
|
+
|
|
205
|
+
if (!(formState.tableForm.sortBy === sortBy && formState.tableForm.sortOrder === sortOrder)) {
|
|
206
|
+
dispatch({
|
|
207
|
+
action: "mutateTableForm",
|
|
208
|
+
data: {
|
|
209
|
+
...formState.tableForm,
|
|
210
|
+
sortBy: id,
|
|
211
|
+
sortOrder: desc ? "DESC" : "ASC",
|
|
212
|
+
},
|
|
213
|
+
checkPathName,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const propsForInboxTable = useInboxTableConfig({
|
|
220
|
+
...{
|
|
221
|
+
parentRoute,
|
|
222
|
+
onPageSizeChange,
|
|
223
|
+
formState,
|
|
224
|
+
totalCount: totalRecords,
|
|
225
|
+
table: filteredData,
|
|
226
|
+
dispatch,
|
|
227
|
+
onSortingByData,
|
|
228
|
+
tenantId,
|
|
229
|
+
checkPathName,
|
|
230
|
+
inboxStyles: { overflowX: "scroll", overflowY: "hidden" },
|
|
231
|
+
tableStyle: { width: "70%" },
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
const isInboxLoading = isLoading || isSearchLoading;
|
|
236
|
+
|
|
237
|
+
return (
|
|
238
|
+
<div className="app-container">
|
|
239
|
+
<InboxComposer
|
|
240
|
+
{...{
|
|
241
|
+
isInboxLoading,
|
|
242
|
+
PropsForInboxLinks,
|
|
243
|
+
...propsForSearchForm,
|
|
244
|
+
...propsForFilterForm,
|
|
245
|
+
// ...propsForMobileSortForm,
|
|
246
|
+
propsForInboxTable,
|
|
247
|
+
// propsForInboxMobileCards,
|
|
248
|
+
formState,
|
|
249
|
+
}}
|
|
250
|
+
/>
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export default Inbox;
|