@djb25/digit-ui-module-ekyc 1.0.3 → 1.0.5

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.
@@ -17,25 +17,13 @@ const Create = () => {
17
17
 
18
18
  const tenantId = Digit.ULBService.getCurrentTenantId();
19
19
 
20
- const { isLoading: isSearching, data: connectionDetails, error, revalidate } = Digit.Hooks.ekyc.useGetConnection({
20
+ const { isLoading: isSearching, data: connectionDetails, error, revalidate } = Digit.Hooks.ekyc.useSearchConnection({
21
21
  tenantId,
22
- details: { kno: searchParams.kNumber }
22
+ details: { kno: searchParams.kNumber, name: searchParams.kName }
23
23
  }, {
24
- enabled: searchPerformed && !!searchParams.kNumber
25
- });
26
-
27
- const { mutate: validateUser, isLoading: isValidating } = Digit.Hooks.ekyc.useValidateUser(tenantId, {
28
- onSuccess: (data) => {
29
- if (data?.responseInfo?.status === "successful") {
30
- // Keep the flow: first validate, then search details is implied by the new UI
31
- } else {
32
- setShowToast({ error: true, label: data?.message || t("EKYC_VALIDATION_FAILED") });
33
- setSearchPerformed(false);
34
- sessionStorage.removeItem("EKYC_CREATE_SEARCH_PERFORMED");
35
- }
36
- },
24
+ enabled: searchPerformed && !!searchParams.kNumber && !!searchParams.kName,
37
25
  onError: (error) => {
38
- setShowToast({ error: true, label: error?.response?.data?.Errors?.[0]?.message || t("EKYC_VALIDATION_ERROR_PLEASE_ENTER_THE_CORRECT_CREDENTIALS") });
26
+ setShowToast({ error: true, label: error?.response?.data?.Errors?.[0]?.message || t("EKYC_SEARCH_ERROR_PLEASE_ENTER_THE_CORRECT_CREDENTIALS") });
39
27
  setSearchPerformed(false);
40
28
  sessionStorage.removeItem("EKYC_CREATE_SEARCH_PERFORMED");
41
29
  }
@@ -59,8 +47,6 @@ const Create = () => {
59
47
  setSearchPerformed(true);
60
48
  sessionStorage.setItem("EKYC_CREATE_SEARCH_PARAMS", JSON.stringify(params));
61
49
  sessionStorage.setItem("EKYC_CREATE_SEARCH_PERFORMED", "true");
62
- // We validate first as per original logic, then the hook useGetConnection will fetch details
63
- validateUser({ kno: params.kNumber, name: params.kName });
64
50
  };
65
51
 
66
52
  const closeToast = () => {
@@ -77,7 +63,7 @@ const Create = () => {
77
63
  kNumber={searchParams.kNumber}
78
64
  kName={searchParams.kName}
79
65
  connectionDetails={connectionDetails}
80
- isLoading={isSearching || isValidating}
66
+ isLoading={isSearching}
81
67
  />
82
68
  )}
83
69
 
@@ -4,13 +4,7 @@ import DesktopInbox from "../../components/DesktopInbox";
4
4
  import MobileInbox from "../../components/MobileInbox";
5
5
  import Filter from "../../components/Filter";
6
6
 
7
- const MOCK_DATA_ITEMS = [
8
- { applicationNumber: "EKYC-2024-001", citizenName: "Rahul Sharma", mobileNumber: "9876543210", status: "COMPLETED" },
9
- { applicationNumber: "EKYC-2024-002", citizenName: "Anjali Devi", mobileNumber: "9123456789", status: "PENDING" },
10
- { applicationNumber: "EKYC-2024-003", citizenName: "Amit Kumar", mobileNumber: "8888888888", status: "REJECTED" },
11
- { applicationNumber: "EKYC-2024-004", citizenName: "Priya Singh", mobileNumber: "7777777777", status: "COMPLETED" },
12
- { applicationNumber: "EKYC-2024-005", citizenName: "Suresh Gupta", mobileNumber: "6666666666", status: "PENDING" },
13
- ];
7
+ // Mock data removed in favor of API integration
14
8
 
15
9
  const Inbox = ({
16
10
  parentRoute,
@@ -33,28 +27,40 @@ const Inbox = ({
33
27
  // Maintain the full search objects for the Search component
34
28
  const [searchParams, setSearchParams] = useState(initialStates.searchParams || { status: defaultStatusOption });
35
29
 
36
- // 2. Local Filtering Logic for Static Data
37
- const filteredStaticData = useMemo(() => {
38
- return MOCK_DATA_ITEMS.filter((item) => {
39
- let match = true;
40
- // Extract the string value from the status object if it exists
41
- const currentStatus = searchParams.status?.value !== undefined ? searchParams.status.value : searchParams.status;
42
-
43
- if (currentStatus && item.status !== currentStatus) {
44
- match = false;
45
- }
46
- return match;
47
- });
48
- }, [searchParams]);
49
-
50
- const staticCountData = useMemo(() => {
30
+ // 2. API Data Fetching
31
+ const { isLoading, data: dashboardData, isFetching } = Digit.Hooks.ekyc.useEkycSurveyorDashboard(
32
+ {},
33
+ {
34
+ tenantId,
35
+ offset: pageOffset,
36
+ limit: pageSize,
37
+ status: searchParams.status?.value || ""
38
+ },
39
+ {
40
+ enabled: !!tenantId,
41
+ }
42
+ );
43
+
44
+ const filteredData = useMemo(() => {
45
+ const items = dashboardData?.dashboardInfo?.consumerList || [];
46
+ return items.map(item => ({
47
+ ...item,
48
+ applicationNumber: item.kno || item.applicationNumber,
49
+ citizenName: item.consumerName || item.citizenName,
50
+ }));
51
+ }, [dashboardData]);
52
+
53
+ const countData = useMemo(() => {
54
+ const info = dashboardData?.dashboardInfo || {};
51
55
  return {
52
- total: MOCK_DATA_ITEMS.length,
53
- completed: MOCK_DATA_ITEMS.filter(i => i.status === "COMPLETED").length,
54
- pending: MOCK_DATA_ITEMS.filter(i => i.status === "PENDING").length,
55
- rejected: MOCK_DATA_ITEMS.filter(i => i.status === "REJECTED").length
56
+ total: info.total || 0,
57
+ completed: info.completed || 0,
58
+ pending: info.pending || 0,
59
+ rejected: info.rejected || 0
56
60
  };
57
- }, []);
61
+ }, [dashboardData]);
62
+
63
+ const totalRecords = dashboardData?.dashboardInfo?.totalRecords || dashboardData?.totalCount || 0;
58
64
 
59
65
  // 3. Handlers
60
66
  const handleSearch = useCallback((filterParam) => {
@@ -98,19 +104,19 @@ const Inbox = ({
98
104
  <div className="inbox-main-container">
99
105
  {Digit.Utils.browser.isMobile() ? (
100
106
  <MobileInbox
101
- data={{ items: filteredStaticData, totalCount: filteredStaticData.length }}
102
- isLoading={false}
107
+ data={{ items: filteredData, totalCount: totalRecords }}
108
+ isLoading={isLoading || isFetching}
103
109
  onSearch={handleSearch}
104
110
  searchFields={searchFields}
105
111
  searchParams={searchParams}
106
112
  parentRoute={parentRoute}
107
- countData={staticCountData}
113
+ countData={countData}
108
114
  />
109
115
  ) : (
110
116
  <DesktopInbox
111
117
  businessService={businessService}
112
- data={{ items: filteredStaticData, totalCount: filteredStaticData.length }}
113
- isLoading={false}
118
+ data={{ items: filteredData, totalCount: totalRecords }}
119
+ isLoading={isLoading || isFetching}
114
120
  searchFields={searchFields}
115
121
  onSearch={handleSearch}
116
122
  onSort={handleSort}
@@ -122,8 +128,8 @@ const Inbox = ({
122
128
  parentRoute={parentRoute}
123
129
  searchParams={searchParams}
124
130
  sortParams={sortParams}
125
- totalRecords={filteredStaticData.length}
126
- countData={staticCountData}
131
+ totalRecords={totalRecords}
132
+ countData={countData}
127
133
  filterComponent="EKYC_INBOX_FILTER"
128
134
  />
129
135
  )}