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

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.
@@ -0,0 +1,145 @@
1
+ import React from "react";
2
+ import { UploadFile, Dropdown } from "@djb25/digit-ui-react-components";
3
+
4
+ const PropertyInfoConfig = (t, formData = {}, uploadFile, buildingImage, buildingImageId, setBuildingImage, setBuildingImageId) => {
5
+ const propertyType = formData?.propertyType?.name || formData?.propertyType;
6
+ const isHotel = propertyType === "Hotel";
7
+ const isHospitalOrNursing = propertyType === "Hospital" || propertyType === "Nursing Home";
8
+
9
+ const fields = [
10
+ {
11
+ label: t("PID Number"),
12
+ isMandatory: false,
13
+ type: "text",
14
+ populators: {
15
+ name: "pidNumber",
16
+ },
17
+ },
18
+ {
19
+ label: t("Property Type"),
20
+ isMandatory: false,
21
+ type: "custom",
22
+ key: "propertyType",
23
+ populators: {
24
+ name: "propertyType",
25
+ component: (props) => (
26
+ <Dropdown
27
+ option={[
28
+ { name: "Residential" },
29
+ { name: "Commercial" },
30
+ { name: "Hotel" },
31
+ { name: "Hospital" },
32
+ { name: "Nursing Home" },
33
+ ]}
34
+ optionKey="name"
35
+ selected={props.value}
36
+ select={props.onChange}
37
+ />
38
+ ),
39
+ },
40
+ },
41
+ {
42
+ label: t("Sub Property Category"),
43
+ isMandatory: false,
44
+ type: "custom",
45
+ key: "subPropertyCategory",
46
+ populators: {
47
+ name: "subPropertyCategory",
48
+ component: (props) => (
49
+ <Dropdown
50
+ option={[]}
51
+ optionKey="name"
52
+ selected={props.value}
53
+ select={props.onChange}
54
+ />
55
+ ),
56
+ },
57
+ },
58
+ {
59
+ label: t("No. of Floors"),
60
+ isMandatory: true,
61
+ type: "number",
62
+ populators: {
63
+ name: "noOfFloors",
64
+ validation: {
65
+ required: true,
66
+ min: 1,
67
+ },
68
+ },
69
+ },
70
+ {
71
+ label: t("Floor No. of this KNO"),
72
+ isMandatory: false,
73
+ type: "text",
74
+ populators: {
75
+ name: "floorNo",
76
+ },
77
+ },
78
+ {
79
+ label: isHospitalOrNursing ? t("No of Beds") : t("No of Beds"),
80
+ isMandatory: isHospitalOrNursing,
81
+ type: "number",
82
+ populators: {
83
+ name: "noOfBeds",
84
+ validation: isHospitalOrNursing ? { required: true, min: 1 } : {},
85
+ },
86
+ },
87
+ {
88
+ label: isHotel ? t("No. of Rooms") : t("No. of Rooms"),
89
+ isMandatory: isHotel,
90
+ type: "number",
91
+ populators: {
92
+ name: "noOfRooms",
93
+ validation: isHotel ? { required: true, min: 1 } : {},
94
+ },
95
+ },
96
+ {
97
+ label: t("Number of Dwelling Units"),
98
+ isMandatory: false,
99
+ type: "number",
100
+ populators: {
101
+ name: "dwellingUnits",
102
+ },
103
+ },
104
+ {
105
+ label: t("Building Image"),
106
+ isMandatory: true,
107
+ type: "custom",
108
+ key: "buildingImage",
109
+ populators: {
110
+ name: "buildingImage",
111
+ component: (props) => (
112
+ <div>
113
+ <UploadFile
114
+ onUpload={(e) => uploadFile(e, props.onChange)}
115
+ onDelete={() => {
116
+ props.onChange(null);
117
+ setBuildingImage(null);
118
+ setBuildingImageId(null);
119
+ }}
120
+ message={buildingImageId ? t("Uploaded") : t("No file selected")}
121
+ />
122
+ {buildingImage && (
123
+ <div style={{ marginTop: "10px" }}>
124
+ <img
125
+ src={buildingImage}
126
+ alt="preview"
127
+ style={{ maxWidth: "100%", maxHeight: "200px", objectFit: "contain" }}
128
+ />
129
+ </div>
130
+ )}
131
+ </div>
132
+ ),
133
+ },
134
+ },
135
+ ];
136
+
137
+ return [
138
+ {
139
+ head: t("EKYC_PROPERTY_DETAILS"),
140
+ body: fields,
141
+ },
142
+ ];
143
+ };
144
+
145
+ export default PropertyInfoConfig;
@@ -23,6 +23,7 @@ export const ekycConfig = [
23
23
  component: "AddressDetails",
24
24
  key: "addressDetails",
25
25
  doorImage: true,
26
+ showMapActualLocation: false,
26
27
  texts: {
27
28
  header: "EKYC_ADDRESS_DETAILS",
28
29
  submitBarLabel: "COMMON_SAVE_NEXT",
@@ -70,7 +70,7 @@ const useInboxTableConfig = ({
70
70
  Header: t("EKYC_EKYC_STATUS"),
71
71
  accessor: "ekycStatus",
72
72
  Cell: ({ row }) => {
73
- const ekycStatus = row.original?.ekycstatus || "NA";
73
+ const ekycStatus = row.original?.ekycStatus || row.original?.ekycstatus || "NA";
74
74
  return <span className={`ekyc-status-tag ${ekycStatus}`}>{t(`${ekycStatus}`)}</span>;
75
75
  },
76
76
  },
@@ -32,7 +32,15 @@ const Inbox = ({ parentRoute }) => {
32
32
  };
33
33
  }, [tenantId, formState?.tableForm?.offset, formState?.tableForm?.limit, formState?.searchForm]);
34
34
 
35
- const { isLoading, data: dashboardData = {} } = Digit.Hooks.ekyc.useEkycSurveyorDashboard({}, queryParams, {
35
+ const filters = useMemo(() => {
36
+ const searchForm = formState?.searchForm || {};
37
+ return {
38
+ ...searchForm,
39
+ ...(searchForm.kNumber && { kno: searchForm.kNumber }),
40
+ };
41
+ }, [formState?.searchForm]);
42
+
43
+ const { isLoading, data: dashboardData = {} } = Digit.Hooks.ekyc.useEkycApplicationList(filters, queryParams, {
36
44
  enabled: !!tenantId,
37
45
  keepPreviousData: true,
38
46
  });
@@ -64,7 +72,7 @@ const Inbox = ({ parentRoute }) => {
64
72
  return [searchData];
65
73
  }
66
74
 
67
- return dashboardData?.dashboardInfo?.consumerList || [];
75
+ return dashboardData?.consumerList || [];
68
76
  }, [isSearchActive, searchData, dashboardData]);
69
77
 
70
78
  const filteredData = useMemo(() => {
@@ -80,6 +88,7 @@ const Inbox = ({ parentRoute }) => {
80
88
  applicationNumber: item.propertyInfo?.kno || "",
81
89
  citizenName: item.connectionDetails?.consumerName || "",
82
90
  status: item.connectionDetails?.statusflag || "",
91
+ ekycStatus: item.connectionDetails?.ekycStatus || item.connectionDetails?.ekycstatus || item.ekycStatus || item.ekycstatus || "NA",
83
92
  sla: 0,
84
93
  };
85
94
  }
@@ -93,6 +102,7 @@ const Inbox = ({ parentRoute }) => {
93
102
  applicationNumber: item.kno || item.applicationNumber || "",
94
103
  citizenName: item.consumerName || item.citizenName || "",
95
104
  status: item.status || "",
105
+ ekycStatus: item.ekycStatus || item.ekycstatus || "NA",
96
106
  sla: item.sla ?? 0,
97
107
  };
98
108
  });
@@ -126,13 +136,13 @@ const Inbox = ({ parentRoute }) => {
126
136
  };
127
137
 
128
138
  const searchFormDefaultValues = {
129
- mobileNumber: "",
139
+ kNumber: "",
130
140
  applicationNumber: "",
131
141
  consumerNo: "",
132
142
  };
133
143
 
134
144
  const onSearchFormReset = (setSearchFormValue) => {
135
- setSearchFormValue("mobileNumber", null);
145
+ setSearchFormValue("kNumber", null);
136
146
  setSearchFormValue("applicationNumber", null);
137
147
  setSearchFormValue("consumerNo", null);
138
148
  dispatch({ action: "mutateSearchForm", data: searchFormDefaultValues });
@@ -1,38 +1,63 @@
1
- import React, { useState, Fragment } from "react";
2
- import { CardLabel, TextInput, Dropdown, UploadFile, Toast, FormStep } from "@djb25/digit-ui-react-components";
1
+ import React, { useState, Fragment, useEffect } from "react";
2
+ import { CardLabel, TextInput, Dropdown, UploadFile, Toast, FormStep, Loader } from "@djb25/digit-ui-react-components";
3
+ import { useLocation } from "react-router-dom";
4
+
5
+ const ConsumerDetails = ({ config, onSelect, formData }) => {
6
+ const location = useLocation();
7
+ const flowState = location.state || {};
8
+ const tenantId = Digit.ULBService.getCurrentTenantId();
9
+
10
+ const queryParams = new URLSearchParams(location.search);
11
+ const urlKno = queryParams.get("kno");
12
+
13
+ const searchKno = urlKno || flowState?.kNumber || flowState?.kno || formData?.kNumber || formData?.kno || sessionStorage.getItem("EKYC_K_NUMBER") || "";
14
+
15
+ const { isLoading, data: searchData } = Digit.Hooks.ekyc.useSearchConnection(
16
+ { tenantId, details: { kno: searchKno } },
17
+ { enabled: !!searchKno, cacheTime: 0 }
18
+ );
19
+
20
+ const savedData = formData?.consumerDetails || {};
3
21
 
4
- const ConsumerDetails = ({ config, onSelect }) => {
5
22
  // 🔹 STATES
6
- const [kno, setKno] = useState("");
7
- const [consumerType, setConsumerType] = useState(null);
8
- const [occupantType, setOccupantType] = useState(null);
9
- const [categoryType, setCategoryType] = useState(null);
23
+ const [kno, setKno] = useState(savedData.kno || "");
24
+ const [consumerType, setConsumerType] = useState(
25
+ savedData.consumerType ? { name: savedData.consumerType } : null
26
+ );
27
+ const [occupantType, setOccupantType] = useState(
28
+ savedData.occupantType ? { name: savedData.occupantType } : null
29
+ );
30
+ const [categoryType, setCategoryType] = useState(
31
+ savedData.categoryType ? { name: savedData.categoryType } : null
32
+ );
10
33
 
11
- const [firstName, setFirstName] = useState("");
12
- const [middleName, setMiddleName] = useState("");
13
- const [lastName, setLastName] = useState("");
34
+ const [firstName, setFirstName] = useState(savedData.firstName || "");
35
+ const [middleName, setMiddleName] = useState(savedData.middleName || "");
36
+ const [lastName, setLastName] = useState(savedData.lastName || "");
14
37
 
15
- const [gender, setGender] = useState(null);
38
+ const [gender, setGender] = useState(
39
+ savedData.gender ? { name: savedData.gender } : null
40
+ );
16
41
 
17
- const [mobile, setMobile] = useState("");
18
- const [whatsapp, setWhatsapp] = useState("");
19
- const [email, setEmail] = useState("");
20
- const [residents, setResidents] = useState("");
42
+ const [mobile, setMobile] = useState(savedData.mobile || "");
43
+ const [whatsapp, setWhatsapp] = useState(savedData.whatsapp || "");
44
+ const [email, setEmail] = useState(savedData.email || "");
45
+ const [residents, setResidents] = useState(savedData.residents || "");
21
46
 
22
47
  // Tenant
23
48
  const [, setDocumentProof] = useState(null);
24
- const [documentId, setDocumentId] = useState(null);
25
- const [ownerMobile, setOwnerMobile] = useState("");
26
- const [tenantVerification, setTenantVerification] = useState("");
49
+ const [documentId, setDocumentId] = useState(savedData.documentId || null);
50
+ const [ownerMobile, setOwnerMobile] = useState(savedData.ownerMobile || "");
51
+ const [tenantVerification, setTenantVerification] = useState(savedData.tenantVerification || "");
27
52
 
28
53
  // Govt
29
- const [designation, setDesignation] = useState("");
30
- const [department, setDepartment] = useState("");
31
- const [employeeId, setEmployeeId] = useState("");
54
+ const [designation, setDesignation] = useState(savedData.designation || "");
55
+ const [department, setDepartment] = useState(savedData.department || "");
56
+ const [employeeId, setEmployeeId] = useState(savedData.employeeId || "");
32
57
 
33
58
  // Other Entity
34
- const [contactPerson, setContactPerson] = useState("");
35
- const [entityName, setEntityName] = useState("");
59
+ const [contactPerson, setContactPerson] = useState(savedData.contactPerson || "");
60
+ const [entityName, setEntityName] = useState(savedData.entityName || "");
36
61
 
37
62
  // Identity
38
63
 
@@ -45,6 +70,35 @@ const ConsumerDetails = ({ config, onSelect }) => {
45
70
 
46
71
  const genderOptions = [{ name: "Male" }, { name: "Female" }, { name: "Others" }, { name: "Not prefer to say" }];
47
72
 
73
+ // 🔹 PREFILL FROM SEARCH DATA
74
+ useEffect(() => {
75
+ const rawData = searchData || formData?.connectionDetails;
76
+ const details = rawData?.connectionDetails || rawData || {};
77
+
78
+ if (searchKno && !kno) {
79
+ setKno(searchKno);
80
+ }
81
+
82
+ if (details && Object.keys(details).length > 0 && !savedData.firstName) {
83
+ if (details.consumerName) {
84
+ const nameParts = details.consumerName.trim().split(/\s+/);
85
+ if (nameParts.length > 0) setFirstName(nameParts[0]);
86
+ if (nameParts.length > 2) {
87
+ setMiddleName(nameParts.slice(1, -1).join(" "));
88
+ setLastName(nameParts[nameParts.length - 1]);
89
+ } else if (nameParts.length === 2) {
90
+ setLastName(nameParts[1]);
91
+ }
92
+ }
93
+ if (details.phoneNumber) {
94
+ setMobile(details.phoneNumber);
95
+ }
96
+ if (details.email) {
97
+ setEmail(details.email);
98
+ }
99
+ }
100
+ }, [searchData, formData?.connectionDetails, searchKno]);
101
+
48
102
  // 🔹 FILE UPLOAD
49
103
  const uploadFile = async (e, setter, idSetter) => {
50
104
  const file = e.target.files[0];
@@ -74,7 +128,7 @@ const ConsumerDetails = ({ config, onSelect }) => {
74
128
 
75
129
  if (occupantType?.name === "Tenanted" && !documentId && !ownerMobile) return false;
76
130
 
77
- return false;
131
+ return true;
78
132
  };
79
133
 
80
134
  // 🔹 SUBMIT
@@ -110,6 +164,10 @@ const ConsumerDetails = ({ config, onSelect }) => {
110
164
  onSelect(config.key, data);
111
165
  };
112
166
 
167
+ if (isLoading) {
168
+ return <Loader />;
169
+ }
170
+
113
171
  return (
114
172
  <Fragment>
115
173
  <FormStep onSelect={onStepSelect} config={config}>
@@ -98,7 +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
+ // formData={{ ...params, address: params.addressDetails }}
102
102
  />
103
103
  </div>
104
104
  );
@@ -87,6 +87,7 @@ const Inbox = ({ parentRoute, businessService = "EKYC", initialStates = {}, filt
87
87
  applicationNumber: item.propertyInfo?.kno || "",
88
88
  citizenName: item.connectionDetails?.consumerName || "",
89
89
  status: item.connectionDetails?.statusflag || "",
90
+ ekycStatus: item.connectionDetails?.ekycStatus || item.connectionDetails?.ekycstatus || item.ekycStatus || item.ekycstatus || "NA",
90
91
  sla: 0,
91
92
  };
92
93
  }
@@ -101,6 +102,7 @@ const Inbox = ({ parentRoute, businessService = "EKYC", initialStates = {}, filt
101
102
  applicationNumber: item.kno || item.applicationNumber || "",
102
103
  citizenName: fullName || item.consumerName || item.citizenName || "",
103
104
  status: item.status || "",
105
+ ekycStatus: item.ekycStatus || item.ekycstatus || "NA",
104
106
  sla: item.sla ?? 0,
105
107
  };
106
108
  });