@djb25/digit-ui-module-ekyc 1.0.23 → 1.0.25
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 +596 -558
- package/dist/index.modern.js.map +1 -1
- package/package.json +3 -1
- package/src/Module.js +0 -2
- package/src/components/AadhaarVerification.js +17 -54
- package/src/components/AssignEkyc.js +30 -100
- package/src/components/AssignEkycModal.js +21 -4
- package/src/components/EKYCCard.js +6 -8
- package/src/components/SearchFormFieldsComponent.js +4 -4
- package/src/components/SelectEkycZones.js +71 -0
- package/src/components/SurveyorDetailsCard.js +232 -30
- package/src/hook/SupervisorInboxTableConfig.js +2 -53
- package/src/hook/useInboxTableConfig.js +4 -4
- package/src/pages/citizen/Inbox.js +5 -5
- package/src/pages/citizen/index.js +44 -17
- package/src/pages/employee/EKYCForm.js +21 -20
- package/src/pages/employee/Inbox.js +11 -7
- package/src/pages/employee/index.js +42 -13
- package/src/utils/reportDownloader.js +75 -0
- package/src/components/AddressDetails.js +0 -207
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
2
|
import { useTranslation } from "react-i18next";
|
|
3
|
-
import { useQueryClient } from "react-query";
|
|
3
|
+
// import { useQueryClient } from "react-query";
|
|
4
4
|
import { Redirect, Route, Switch, useHistory, useLocation, useRouteMatch } from "react-router-dom";
|
|
5
|
-
import {
|
|
5
|
+
import { VerticalTimeline } from "@djb25/digit-ui-react-components";
|
|
6
6
|
import { ekycConfig } from "../../config/config";
|
|
7
7
|
|
|
8
8
|
const EKYCForm = ({ path: passedPath }) => {
|
|
9
|
-
const queryClient = useQueryClient();
|
|
9
|
+
// const queryClient = useQueryClient();
|
|
10
10
|
const match = useRouteMatch();
|
|
11
11
|
const { t } = useTranslation();
|
|
12
12
|
const location = useLocation();
|
|
@@ -14,9 +14,7 @@ const EKYCForm = ({ path: passedPath }) => {
|
|
|
14
14
|
const history = useHistory();
|
|
15
15
|
|
|
16
16
|
let config = [];
|
|
17
|
-
const [params, setParams
|
|
18
|
-
const userInfo = Digit.UserService.getUser();
|
|
19
|
-
const tenantId = Digit.ULBService.getCurrentTenantId();
|
|
17
|
+
const [params, setParams] = Digit.Hooks.useSessionStorage("EKYC_CREATE", {});
|
|
20
18
|
|
|
21
19
|
useEffect(() => {
|
|
22
20
|
if (location.state && Object.keys(location.state).length > 0) {
|
|
@@ -31,7 +29,7 @@ const EKYCForm = ({ path: passedPath }) => {
|
|
|
31
29
|
if (!routeObj) routeObj = config.find((routeObj) => routeObj.route === currentPath);
|
|
32
30
|
|
|
33
31
|
let nextStep = null;
|
|
34
|
-
const currentIndex = config.findIndex(c => c.route === routeObj.route);
|
|
32
|
+
const currentIndex = config.findIndex((c) => c.route === routeObj.route);
|
|
35
33
|
if (currentIndex > -1 && currentIndex < config.length - 1) {
|
|
36
34
|
nextStep = config[currentIndex + 1].route;
|
|
37
35
|
}
|
|
@@ -41,7 +39,7 @@ const EKYCForm = ({ path: passedPath }) => {
|
|
|
41
39
|
redirectWithHistory = history.replace;
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
const base = passedPath || match.path.split(
|
|
42
|
+
const base = passedPath || match.path.split("/").slice(0, -1).join("/");
|
|
45
43
|
if (nextStep === null) {
|
|
46
44
|
return redirectWithHistory(`${base}/review`, { ...params, edits: params });
|
|
47
45
|
}
|
|
@@ -49,15 +47,17 @@ const EKYCForm = ({ path: passedPath }) => {
|
|
|
49
47
|
redirectWithHistory(`${base}/${nextStep}`, { ...params });
|
|
50
48
|
};
|
|
51
49
|
|
|
52
|
-
function handleSelect(key, data, skipStep, index, isAddMultiple = false) {
|
|
53
|
-
setParams({ ...
|
|
54
|
-
|
|
50
|
+
function handleSelect(key, data, skipStep, index, isAddMultiple = false, silent = false) {
|
|
51
|
+
setParams((prev) => ({ ...prev, [key]: { ...params[key], ...data } }));
|
|
52
|
+
if (!silent) {
|
|
53
|
+
goNext(skipStep, index, isAddMultiple, key);
|
|
54
|
+
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
const onSuccess = () => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
57
|
+
// const onSuccess = () => {
|
|
58
|
+
// clearParams();
|
|
59
|
+
// queryClient.invalidateQueries("EKYC_CREATE");
|
|
60
|
+
// };
|
|
61
61
|
|
|
62
62
|
ekycConfig.forEach((obj) => {
|
|
63
63
|
config = config.concat(obj.body);
|
|
@@ -65,7 +65,7 @@ const EKYCForm = ({ path: passedPath }) => {
|
|
|
65
65
|
|
|
66
66
|
config.indexRoute = "consumer-details";
|
|
67
67
|
|
|
68
|
-
const formStepRoutes = config.map(c => c.route);
|
|
68
|
+
const formStepRoutes = config.map((c) => c.route);
|
|
69
69
|
const isFormStep = formStepRoutes.some((route) => pathname.includes(route));
|
|
70
70
|
|
|
71
71
|
const sectionRefs = useRef({});
|
|
@@ -85,10 +85,10 @@ const EKYCForm = ({ path: passedPath }) => {
|
|
|
85
85
|
<VerticalTimeline config={config} showFinalStep={true} />
|
|
86
86
|
<div className="employee-form-section">
|
|
87
87
|
<Switch>
|
|
88
|
-
<Route path={formStepRoutes.map((route) => `${
|
|
88
|
+
<Route path={formStepRoutes.map((route) => `${passedPath || match.path.split("/").slice(0, -1).join("/")}/${route}`)}>
|
|
89
89
|
<div className="single-page-form-container">
|
|
90
90
|
{config.map((routeObj, index) => {
|
|
91
|
-
const { component
|
|
91
|
+
const { component } = routeObj;
|
|
92
92
|
const Component = typeof component === "string" ? Digit.ComponentRegistryService.getComponent(component) : component;
|
|
93
93
|
|
|
94
94
|
return (
|
|
@@ -98,6 +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
102
|
/>
|
|
102
103
|
</div>
|
|
103
104
|
);
|
|
@@ -105,7 +106,7 @@ const EKYCForm = ({ path: passedPath }) => {
|
|
|
105
106
|
</div>
|
|
106
107
|
</Route>
|
|
107
108
|
<Route>
|
|
108
|
-
<Redirect to={`${
|
|
109
|
+
<Redirect to={`${passedPath || match.path.split("/").slice(0, -1).join("/")}/${config.indexRoute}`} />
|
|
109
110
|
</Route>
|
|
110
111
|
</Switch>
|
|
111
112
|
</div>
|
|
@@ -24,7 +24,11 @@ const Inbox = ({ parentRoute, businessService = "EKYC", initialStates = {}, filt
|
|
|
24
24
|
const [formState, dispatch] = useReducer(formReducer, formInitValue);
|
|
25
25
|
|
|
26
26
|
const filters = useMemo(() => {
|
|
27
|
-
|
|
27
|
+
const searchForm = formState?.searchForm || {};
|
|
28
|
+
return {
|
|
29
|
+
...searchForm,
|
|
30
|
+
...(searchForm.kNumber && { kno: searchForm.kNumber }),
|
|
31
|
+
};
|
|
28
32
|
}, [formState?.searchForm]);
|
|
29
33
|
|
|
30
34
|
const queryParams = useMemo(() => {
|
|
@@ -130,13 +134,13 @@ const Inbox = ({ parentRoute, businessService = "EKYC", initialStates = {}, filt
|
|
|
130
134
|
};
|
|
131
135
|
|
|
132
136
|
const searchFormDefaultValues = {
|
|
133
|
-
|
|
137
|
+
kNumber: "",
|
|
134
138
|
applicationNumber: "",
|
|
135
139
|
consumerNo: "",
|
|
136
140
|
};
|
|
137
141
|
|
|
138
142
|
const onSearchFormReset = (setSearchFormValue) => {
|
|
139
|
-
setSearchFormValue("
|
|
143
|
+
setSearchFormValue("kNumber", null);
|
|
140
144
|
setSearchFormValue("applicationNumber", null);
|
|
141
145
|
setSearchFormValue("consumerNo", null);
|
|
142
146
|
dispatch({ action: "mutateSearchForm", data: searchFormDefaultValues });
|
|
@@ -158,10 +162,10 @@ const Inbox = ({ parentRoute, businessService = "EKYC", initialStates = {}, filt
|
|
|
158
162
|
|
|
159
163
|
const propsForFilterForm = {
|
|
160
164
|
FilterFormFields,
|
|
161
|
-
onFilterFormSubmit: () => {},
|
|
165
|
+
onFilterFormSubmit: () => { },
|
|
162
166
|
filterFormDefaultValues: "",
|
|
163
167
|
resetFilterFormDefaultValues: "",
|
|
164
|
-
onFilterFormReset: () => {},
|
|
168
|
+
onFilterFormReset: () => { },
|
|
165
169
|
};
|
|
166
170
|
|
|
167
171
|
function formReducer(state, payload) {
|
|
@@ -243,9 +247,9 @@ const Inbox = ({ parentRoute, businessService = "EKYC", initialStates = {}, filt
|
|
|
243
247
|
<InboxComposer
|
|
244
248
|
{...{
|
|
245
249
|
isInboxLoading,
|
|
246
|
-
PropsForInboxLinks,
|
|
250
|
+
// PropsForInboxLinks,
|
|
247
251
|
...propsForSearchForm,
|
|
248
|
-
...propsForFilterForm,
|
|
252
|
+
// ...propsForFilterForm,
|
|
249
253
|
// ...propsForMobileSortForm,
|
|
250
254
|
propsForInboxTable,
|
|
251
255
|
// propsForInboxMobileCards,
|
|
@@ -19,20 +19,49 @@ const EmployeeApp = ({ path }) => {
|
|
|
19
19
|
|
|
20
20
|
sessionStorage.removeItem("revalidateddone");
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const getDynamicBreadcrumbs = () => {
|
|
23
23
|
const pathname = location.pathname;
|
|
24
|
-
if (pathname.includes("/dashboard")) return "ES_COMMON_INBOX";
|
|
25
|
-
if (pathname.includes("/create-kyc")) return "EKYC_CREATE_KYC";
|
|
26
|
-
if (pathname.includes("/k-details")) return "EKYC_K_DETAILS";
|
|
27
|
-
if (pathname.includes("/consumer-details")) return "EKYC_CONSUMER_DETAILS";
|
|
28
|
-
if (pathname.includes("/address-details")) return "EKYC_ADDRESS_DETAILS";
|
|
29
|
-
if (pathname.includes("/property-info")) return "EKYC_PROPERTY_INFO";
|
|
30
|
-
if (pathname.includes("/meter-details")) return "EKYC_METER_DETAILS";
|
|
31
|
-
if (pathname.includes("/review")) return "EKYC_REVIEW";
|
|
32
|
-
return "ES_COMMON_INBOX";
|
|
33
|
-
};
|
|
34
24
|
|
|
35
|
-
|
|
25
|
+
// Parent crumb — always present and clickable → redirects to eKYC inbox
|
|
26
|
+
const crumbs = [
|
|
27
|
+
{ icon: HomeIcon, path: "/digit-ui/employee" },
|
|
28
|
+
{ label: t("ACTION_TEST_EKYC"), path: `/digit-ui/employee/module/details` },
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
// Child crumb — only appended when on a sub-page (not inbox/dashboard itself)
|
|
32
|
+
if (pathname.includes("/create-kyc")) {
|
|
33
|
+
crumbs.push({ label: t("EKYC_CREATE_KYC") });
|
|
34
|
+
} else if (pathname.includes("/consumer-details")) {
|
|
35
|
+
crumbs.push({ label: t("EKYC_CONSUMER_DETAILS") });
|
|
36
|
+
} else if (pathname.includes("/address-details")) {
|
|
37
|
+
crumbs.push({ label: t("EKYC_ADDRESS_DETAILS") });
|
|
38
|
+
} else if (pathname.includes("/property-info")) {
|
|
39
|
+
crumbs.push({ label: t("EKYC_PROPERTY_INFO") });
|
|
40
|
+
} else if (pathname.includes("/meter-details")) {
|
|
41
|
+
crumbs.push({ label: t("EKYC_METER_DETAILS") });
|
|
42
|
+
} else if (pathname.includes("/review")) {
|
|
43
|
+
crumbs.push({ label: t("EKYC_INBOX"), path: `/digit-ui/employee/ekyc/inbox` });
|
|
44
|
+
crumbs.push({ label: t("EKYC_REVIEW") });
|
|
45
|
+
} else if (pathname.includes("/assign/surveyor-details")) {
|
|
46
|
+
crumbs.push({ label: t("EKYC_ASSIGN"), path: `/digit-ui/employee/ekyc/assign` });
|
|
47
|
+
crumbs.push({ label: t("EKYC_SURVEYOR_DETAILS") });
|
|
48
|
+
} else if (pathname.includes("/assign")) {
|
|
49
|
+
crumbs.push({ label: t("EKYC_ASSIGN") });
|
|
50
|
+
} else if (pathname.includes("/ceo-dashboard")) {
|
|
51
|
+
crumbs.push({ label: t("CEO_M.F_DOR_FINANCE_VIEW") });
|
|
52
|
+
} else if (pathname.includes("/vendors/")) {
|
|
53
|
+
crumbs.push({ label: t("EKYC_VENDOR_DETAILS") });
|
|
54
|
+
} else if (pathname.includes("/mapping")) {
|
|
55
|
+
crumbs.push({ label: t("EKYC_MAPPING") });
|
|
56
|
+
} else if (pathname.includes("/dashboard")) {
|
|
57
|
+
crumbs.push({ label: t("EKYC_DASHBOARD") });
|
|
58
|
+
} else if (pathname.includes("/inbox")) {
|
|
59
|
+
crumbs.push({ label: t("EKYC_INBOX") });
|
|
60
|
+
}
|
|
61
|
+
// dashboard & inbox → no child crumb (only "eKYC Admin" shown)
|
|
62
|
+
|
|
63
|
+
return crumbs;
|
|
64
|
+
};
|
|
36
65
|
|
|
37
66
|
const formStepRoutes = ["consumer-details", "address-details", "property-info", "meter-details"];
|
|
38
67
|
|
|
@@ -47,7 +76,7 @@ const EmployeeApp = ({ path }) => {
|
|
|
47
76
|
</React.Fragment>
|
|
48
77
|
}
|
|
49
78
|
onLeftClick={() => window.history.back()}
|
|
50
|
-
breadcrumbs={
|
|
79
|
+
breadcrumbs={getDynamicBreadcrumbs()}
|
|
51
80
|
/>
|
|
52
81
|
|
|
53
82
|
<div className="employee-form">
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export const downloadSurveyorPDF = async ({
|
|
2
|
+
rows,
|
|
3
|
+
surveyorName,
|
|
4
|
+
employeeId,
|
|
5
|
+
mobileNumber,
|
|
6
|
+
vendorName,
|
|
7
|
+
supervisorName,
|
|
8
|
+
dashboardInfo,
|
|
9
|
+
t,
|
|
10
|
+
}) => {
|
|
11
|
+
const tenantId = Digit.ULBService.getCurrentTenantId();
|
|
12
|
+
const initData = Digit.SessionStorage.get("initData");
|
|
13
|
+
const tenants = initData?.tenants || [];
|
|
14
|
+
const tenantInfo = tenants.find((tenant) => tenant.code === tenantId);
|
|
15
|
+
|
|
16
|
+
const capitalize = (text) =>
|
|
17
|
+
text && text.substr(0, 1).toUpperCase() + text.substr(1);
|
|
18
|
+
const ulbCamel = (ulb) =>
|
|
19
|
+
ulb &&
|
|
20
|
+
ulb
|
|
21
|
+
.toLowerCase()
|
|
22
|
+
.split(" ")
|
|
23
|
+
.map(capitalize)
|
|
24
|
+
.join(" ");
|
|
25
|
+
|
|
26
|
+
const name = "Delhi Jal Board";
|
|
27
|
+
const email = "contact@delhijalboard.nic.in";
|
|
28
|
+
const phoneNumber = "+91-11-23538416";
|
|
29
|
+
|
|
30
|
+
const details = [
|
|
31
|
+
{
|
|
32
|
+
title: t("SURVEYOR_DETAILS"),
|
|
33
|
+
asSectionHeader: true,
|
|
34
|
+
values: [
|
|
35
|
+
{ title: t("SURVEYOR_NAME"), value: surveyorName },
|
|
36
|
+
{ title: t("EMPLOYEE_ID"), value: employeeId },
|
|
37
|
+
{ title: t("MOBILE_NUMBER"), value: mobileNumber },
|
|
38
|
+
{ title: t("VENDOR_NAME"), value: vendorName },
|
|
39
|
+
{ title: t("SUPERVISOR_NAME"), value: supervisorName }
|
|
40
|
+
].filter((item) => item.value),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
title: t("SUMMARY_STATISTICS"),
|
|
44
|
+
asSectionHeader: true,
|
|
45
|
+
values: [
|
|
46
|
+
{ title: t("TOTAL_ASSIGNED"), value: dashboardInfo?.total || 0 },
|
|
47
|
+
{ title: t("COMPLETED"), value: dashboardInfo?.completed || 0 },
|
|
48
|
+
{ title: t("PENDING"), value: dashboardInfo?.pending || 0 },
|
|
49
|
+
{ title: t("SUBMITTED"), value: dashboardInfo?.submittedCount || 0 },
|
|
50
|
+
].filter((item) => item.value),
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
window.Digit &&
|
|
56
|
+
window.Digit.Utils &&
|
|
57
|
+
window.Digit.Utils.pdf &&
|
|
58
|
+
window.Digit.Utils.pdf.generateSurveyorReport
|
|
59
|
+
) {
|
|
60
|
+
window.Digit.Utils.pdf.generateSurveyorReport({
|
|
61
|
+
tenantId,
|
|
62
|
+
logo: null,
|
|
63
|
+
name,
|
|
64
|
+
email,
|
|
65
|
+
phoneNumber,
|
|
66
|
+
heading: t("EKYC_SURVEYOR_REPORT"),
|
|
67
|
+
details,
|
|
68
|
+
applicationNumber: employeeId,
|
|
69
|
+
rows,
|
|
70
|
+
t,
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
console.error("Digit.Utils.pdf.generateSurveyorReport is not available");
|
|
74
|
+
}
|
|
75
|
+
};
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, Fragment } from "react";
|
|
2
|
-
import { CardLabel, TextInput, Dropdown, UploadFile, Toast, FormStep, Loader } from "@djb25/digit-ui-react-components";
|
|
3
|
-
import { useTranslation } from "react-i18next";
|
|
4
|
-
|
|
5
|
-
const AddressDetails = ({ config, onSelect }) => {
|
|
6
|
-
const { t } = useTranslation();
|
|
7
|
-
|
|
8
|
-
const tenantId = Digit.ULBService.getCurrentTenantId();
|
|
9
|
-
|
|
10
|
-
// 🔹 STATES
|
|
11
|
-
const [houseNo, setHouseNo] = useState("");
|
|
12
|
-
const [street, setStreet] = useState("");
|
|
13
|
-
const [locality, setLocality] = useState("");
|
|
14
|
-
const [landmark, setLandmark] = useState("");
|
|
15
|
-
const [subLocality, setSubLocality] = useState(null);
|
|
16
|
-
|
|
17
|
-
const [pinCode, setPinCode] = useState("");
|
|
18
|
-
const [assembly, setAssembly] = useState(null);
|
|
19
|
-
const [ward, setWard] = useState(null);
|
|
20
|
-
const [zone, setZone] = useState(null);
|
|
21
|
-
|
|
22
|
-
const [latitude, setLatitude] = useState("");
|
|
23
|
-
const [longitude, setLongitude] = useState("");
|
|
24
|
-
|
|
25
|
-
const [addressType, setAddressType] = useState(null);
|
|
26
|
-
|
|
27
|
-
const [doorPhoto, setDoorPhoto] = useState(null);
|
|
28
|
-
const [doorPhotoFileStoreId, setDoorPhotoFileStoreId] = useState(null);
|
|
29
|
-
|
|
30
|
-
const [toast, setToast] = useState(null);
|
|
31
|
-
|
|
32
|
-
// 🔹 MDMS DATA
|
|
33
|
-
const { data: mdmsData, isLoading } = Digit.Hooks.useCommonMDMS(tenantId, "egov-location", ["TenantBoundary"]);
|
|
34
|
-
|
|
35
|
-
const assemblies = mdmsData?.MdmsRes?.["egov-location"]?.TenantBoundary?.[0]?.boundary?.children || [];
|
|
36
|
-
|
|
37
|
-
// 🔹 AUTO GPS
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
let isMounted = true;
|
|
40
|
-
|
|
41
|
-
if (navigator.geolocation) {
|
|
42
|
-
navigator.geolocation.getCurrentPosition(
|
|
43
|
-
(pos) => {
|
|
44
|
-
if (!isMounted) return;
|
|
45
|
-
setLatitude(pos.coords.latitude);
|
|
46
|
-
setLongitude(pos.coords.longitude);
|
|
47
|
-
},
|
|
48
|
-
() => {
|
|
49
|
-
if (!isMounted) return;
|
|
50
|
-
setToast({ type: "error", message: "GPS access denied" });
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return () => {
|
|
56
|
-
isMounted = false;
|
|
57
|
-
};
|
|
58
|
-
}, []);
|
|
59
|
-
|
|
60
|
-
// 🔹 PIN CODE HANDLER
|
|
61
|
-
const handlePincodeChange = (e) => {
|
|
62
|
-
const value = e.target.value;
|
|
63
|
-
if (/^\d{0,6}$/.test(value)) {
|
|
64
|
-
setPinCode(value);
|
|
65
|
-
|
|
66
|
-
if (value.length === 6) {
|
|
67
|
-
fetchLocationByPincode(value);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// 🔹 MOCK PIN API (Replace with real API)
|
|
73
|
-
const fetchLocationByPincode = (pin) => {
|
|
74
|
-
// 🔥 Replace this with backend API
|
|
75
|
-
console.log("Fetching location for PIN:", pin);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// 🔹 FILE UPLOAD
|
|
79
|
-
const selectphoto = async (e) => {
|
|
80
|
-
let isMounted = true;
|
|
81
|
-
|
|
82
|
-
const file = e.target.files[0];
|
|
83
|
-
if (!file) return;
|
|
84
|
-
|
|
85
|
-
if (file.size >= 2000000) {
|
|
86
|
-
setToast({ type: "error", message: "Max size 2MB exceeded" });
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
const res = await Digit.UploadServices.Filestorage("EKYC", file, tenantId);
|
|
92
|
-
|
|
93
|
-
if (!isMounted) return;
|
|
94
|
-
|
|
95
|
-
const fileStoreId = res?.data?.files?.[0]?.fileStoreId;
|
|
96
|
-
|
|
97
|
-
if (fileStoreId) {
|
|
98
|
-
setDoorPhotoFileStoreId(fileStoreId);
|
|
99
|
-
|
|
100
|
-
const reader = new FileReader();
|
|
101
|
-
reader.onloadend = () => {
|
|
102
|
-
if (!isMounted) return;
|
|
103
|
-
setDoorPhoto(reader.result);
|
|
104
|
-
};
|
|
105
|
-
reader.readAsDataURL(file);
|
|
106
|
-
|
|
107
|
-
setToast({ type: "success", message: "Upload successful" });
|
|
108
|
-
}
|
|
109
|
-
} catch {
|
|
110
|
-
if (!isMounted) return;
|
|
111
|
-
setToast({ type: "error", message: "Upload failed" });
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return () => {
|
|
115
|
-
isMounted = false;
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const removePhoto = () => {
|
|
120
|
-
setDoorPhoto(null);
|
|
121
|
-
setDoorPhotoFileStoreId(null);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
// 🔹 VALIDATION
|
|
125
|
-
const isValid = () => {
|
|
126
|
-
return houseNo && street && pinCode.length === 6 && assembly && ward && zone && latitude && longitude && doorPhotoFileStoreId;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// 🔹 SUBMIT
|
|
130
|
-
const onStepSelect = () => {
|
|
131
|
-
if (!isValid()) {
|
|
132
|
-
setToast({ type: "error", message: "Please fill all mandatory fields" });
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const data = {
|
|
137
|
-
houseNo,
|
|
138
|
-
street,
|
|
139
|
-
locality,
|
|
140
|
-
landmark,
|
|
141
|
-
subLocality,
|
|
142
|
-
pinCode,
|
|
143
|
-
assembly: assembly?.name,
|
|
144
|
-
ward: ward?.name,
|
|
145
|
-
zone: zone?.name,
|
|
146
|
-
latitude,
|
|
147
|
-
longitude,
|
|
148
|
-
addressType: addressType?.name,
|
|
149
|
-
doorPhotoFilestoreId: doorPhotoFileStoreId,
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
onSelect(config.key, data);
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
if (isLoading) return <Loader />;
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<Fragment>
|
|
159
|
-
<FormStep t={t} onSelect={onStepSelect} config={config} label={t("ES_COMMON_CONTINUE")}>
|
|
160
|
-
<CardLabel>House No / Flat No *</CardLabel>
|
|
161
|
-
<TextInput value={houseNo} onChange={(e) => setHouseNo(e.target.value)} />
|
|
162
|
-
|
|
163
|
-
<CardLabel>Street / Address Line *</CardLabel>
|
|
164
|
-
<TextInput value={street} onChange={(e) => setStreet(e.target.value)} />
|
|
165
|
-
|
|
166
|
-
<CardLabel>Locality</CardLabel>
|
|
167
|
-
<TextInput value={locality} onChange={(e) => setLocality(e.target.value)} />
|
|
168
|
-
|
|
169
|
-
<CardLabel>Landmark</CardLabel>
|
|
170
|
-
<TextInput value={landmark} onChange={(e) => setLandmark(e.target.value)} />
|
|
171
|
-
|
|
172
|
-
<CardLabel>Sub Locality</CardLabel>
|
|
173
|
-
<Dropdown option={[]} selected={subLocality} select={setSubLocality} />
|
|
174
|
-
|
|
175
|
-
<CardLabel>PIN Code *</CardLabel>
|
|
176
|
-
<TextInput value={pinCode} onChange={handlePincodeChange} maxLength={6} />
|
|
177
|
-
|
|
178
|
-
<CardLabel>Assembly *</CardLabel>
|
|
179
|
-
<Dropdown option={assemblies} selected={assembly} select={setAssembly} />
|
|
180
|
-
|
|
181
|
-
<CardLabel>Ward *</CardLabel>
|
|
182
|
-
<Dropdown option={assembly?.children || []} selected={ward} select={setWard} />
|
|
183
|
-
|
|
184
|
-
<CardLabel>Zone *</CardLabel>
|
|
185
|
-
<Dropdown option={ward?.children || []} selected={zone} select={setZone} />
|
|
186
|
-
|
|
187
|
-
<CardLabel>Latitude</CardLabel>
|
|
188
|
-
<TextInput value={latitude} disabled />
|
|
189
|
-
|
|
190
|
-
<CardLabel>Longitude</CardLabel>
|
|
191
|
-
<TextInput value={longitude} disabled />
|
|
192
|
-
|
|
193
|
-
<CardLabel>Address Type</CardLabel>
|
|
194
|
-
<Dropdown option={[{ name: "Permanent" }, { name: "Correspondence" }, { name: "Other" }]} selected={addressType} select={setAddressType} />
|
|
195
|
-
|
|
196
|
-
<CardLabel>Door Image *</CardLabel>
|
|
197
|
-
<UploadFile onUpload={selectphoto} onDelete={removePhoto} message={doorPhotoFileStoreId ? "Uploaded" : "No file selected"} />
|
|
198
|
-
|
|
199
|
-
{doorPhoto && <img src={doorPhoto} alt="preview" style={{ width: "100%", marginTop: "10px" }} />}
|
|
200
|
-
|
|
201
|
-
{toast && <Toast label={toast.message} error={toast.type === "error"} onClose={() => setToast(null)} />}
|
|
202
|
-
</FormStep>
|
|
203
|
-
</Fragment>
|
|
204
|
-
);
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
export default AddressDetails;
|