@djb25/digit-ui-module-ekyc 1.0.4 → 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.
@@ -1,4 +1,4 @@
1
- import React, { useMemo, useState, useCallback, useRef, Fragment } from 'react';
1
+ import React, { useMemo, useState, useCallback, useRef, useEffect, Fragment } from 'react';
2
2
  import { Link, useHistory, useRouteMatch, useLocation, Switch } from 'react-router-dom';
3
3
  import { PersonIcon as PersonIcon$1, EmployeeModuleCard, Card, HomeIcon, Table, Header, TextInput, SubmitBar, Loader, DetailsCard, FilterForm, FilterFormField, Dropdown, CardHeader, StatusTable, Row, CardLabel, Modal, RadioButtons, Toast, LocationIcon, PropertyHouse, InfoBannerIcon, ActionBar, LabelFieldPair, AppContainer, ModuleHeader, ArrowLeft, PrivateRoute } from '@djb25/digit-ui-react-components';
4
4
  import { useTranslation } from 'react-i18next';
@@ -107,23 +107,14 @@ const DesktopInbox = ({
107
107
  var _row$original2;
108
108
  return /*#__PURE__*/React.createElement("span", null, ((_row$original2 = row.original) === null || _row$original2 === void 0 ? void 0 : _row$original2.citizenName) || "NA");
109
109
  }
110
- }, {
111
- Header: t("EKYC_MOBILE_NO"),
112
- accessor: "mobileNumber",
113
- Cell: ({
114
- row
115
- }) => {
116
- var _row$original3;
117
- return /*#__PURE__*/React.createElement("span", null, ((_row$original3 = row.original) === null || _row$original3 === void 0 ? void 0 : _row$original3.mobileNumber) || "NA");
118
- }
119
110
  }, {
120
111
  Header: t("EKYC_STATUS"),
121
112
  accessor: "status",
122
113
  Cell: ({
123
114
  row
124
115
  }) => {
125
- var _row$original4;
126
- const status = ((_row$original4 = row.original) === null || _row$original4 === void 0 ? void 0 : _row$original4.status) || "DEFAULT";
116
+ var _row$original3;
117
+ const status = ((_row$original3 = row.original) === null || _row$original3 === void 0 ? void 0 : _row$original3.status) || "DEFAULT";
127
118
  return /*#__PURE__*/React.createElement("span", {
128
119
  className: `ekyc-status-tag ${status}`
129
120
  }, t(`EKYC_STATUS_${status}`));
@@ -360,7 +351,13 @@ const SearchConsumer = ({
360
351
  paddingLeft: "12px",
361
352
  height: "44px"
362
353
  }
363
- }))), /*#__PURE__*/React.createElement("div", {
354
+ })))), /*#__PURE__*/React.createElement("div", {
355
+ style: {
356
+ display: "flex",
357
+ justifyContent: "flex-end",
358
+ marginTop: "20px"
359
+ }
360
+ }, /*#__PURE__*/React.createElement("div", {
364
361
  style: {
365
362
  display: "flex",
366
363
  gap: "12px",
@@ -385,8 +382,7 @@ const SearchConsumer = ({
385
382
  margin: 0,
386
383
  borderRadius: "8px",
387
384
  height: "44px",
388
- padding: "0 32px",
389
- marginTop: "-55px"
385
+ padding: "0 32px"
390
386
  }
391
387
  }))))), children));
392
388
  };
@@ -522,32 +518,6 @@ const Filter = ({
522
518
  })));
523
519
  };
524
520
 
525
- const MOCK_DATA_ITEMS = [{
526
- applicationNumber: "EKYC-2024-001",
527
- citizenName: "Rahul Sharma",
528
- mobileNumber: "9876543210",
529
- status: "COMPLETED"
530
- }, {
531
- applicationNumber: "EKYC-2024-002",
532
- citizenName: "Anjali Devi",
533
- mobileNumber: "9123456789",
534
- status: "PENDING"
535
- }, {
536
- applicationNumber: "EKYC-2024-003",
537
- citizenName: "Amit Kumar",
538
- mobileNumber: "8888888888",
539
- status: "REJECTED"
540
- }, {
541
- applicationNumber: "EKYC-2024-004",
542
- citizenName: "Priya Singh",
543
- mobileNumber: "7777777777",
544
- status: "COMPLETED"
545
- }, {
546
- applicationNumber: "EKYC-2024-005",
547
- citizenName: "Suresh Gupta",
548
- mobileNumber: "6666666666",
549
- status: "PENDING"
550
- }];
551
521
  const Inbox = ({
552
522
  parentRoute,
553
523
  businessService: _businessService = "EKYC",
@@ -555,6 +525,7 @@ const Inbox = ({
555
525
  filterComponent,
556
526
  isInbox
557
527
  }) => {
528
+ var _searchParams$status, _dashboardData$dashbo2;
558
529
  const tenantId = Digit.ULBService.getCurrentTenantId();
559
530
  const {
560
531
  t
@@ -572,25 +543,37 @@ const Inbox = ({
572
543
  const [searchParams, setSearchParams] = useState(_initialStates.searchParams || {
573
544
  status: defaultStatusOption
574
545
  });
575
- const filteredStaticData = useMemo(() => {
576
- return MOCK_DATA_ITEMS.filter(item => {
577
- var _searchParams$status;
578
- let match = true;
579
- const currentStatus = ((_searchParams$status = searchParams.status) === null || _searchParams$status === void 0 ? void 0 : _searchParams$status.value) !== undefined ? searchParams.status.value : searchParams.status;
580
- if (currentStatus && item.status !== currentStatus) {
581
- match = false;
582
- }
583
- return match;
584
- });
585
- }, [searchParams]);
586
- const staticCountData = useMemo(() => {
546
+ const {
547
+ isLoading,
548
+ data: dashboardData,
549
+ isFetching
550
+ } = Digit.Hooks.ekyc.useEkycSurveyorDashboard({}, {
551
+ tenantId,
552
+ offset: pageOffset,
553
+ limit: pageSize,
554
+ status: ((_searchParams$status = searchParams.status) === null || _searchParams$status === void 0 ? void 0 : _searchParams$status.value) || ""
555
+ }, {
556
+ enabled: !!tenantId
557
+ });
558
+ const filteredData = useMemo(() => {
559
+ var _dashboardData$dashbo;
560
+ const items = (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo = dashboardData.dashboardInfo) === null || _dashboardData$dashbo === void 0 ? void 0 : _dashboardData$dashbo.consumerList) || [];
561
+ return items.map(item => ({
562
+ ...item,
563
+ applicationNumber: item.kno || item.applicationNumber,
564
+ citizenName: item.consumerName || item.citizenName
565
+ }));
566
+ }, [dashboardData]);
567
+ const countData = useMemo(() => {
568
+ const info = (dashboardData === null || dashboardData === void 0 ? void 0 : dashboardData.dashboardInfo) || {};
587
569
  return {
588
- total: MOCK_DATA_ITEMS.length,
589
- completed: MOCK_DATA_ITEMS.filter(i => i.status === "COMPLETED").length,
590
- pending: MOCK_DATA_ITEMS.filter(i => i.status === "PENDING").length,
591
- rejected: MOCK_DATA_ITEMS.filter(i => i.status === "REJECTED").length
570
+ total: info.total || 0,
571
+ completed: info.completed || 0,
572
+ pending: info.pending || 0,
573
+ rejected: info.rejected || 0
592
574
  };
593
- }, []);
575
+ }, [dashboardData]);
576
+ const totalRecords = (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo2 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo2 === void 0 ? void 0 : _dashboardData$dashbo2.totalRecords) || (dashboardData === null || dashboardData === void 0 ? void 0 : dashboardData.totalCount) || 0;
594
577
  const handleSearch = useCallback(filterParam => {
595
578
  setSearchParams(prev => ({
596
579
  ...prev,
@@ -633,22 +616,22 @@ const Inbox = ({
633
616
  className: "inbox-main-container"
634
617
  }, Digit.Utils.browser.isMobile() ? /*#__PURE__*/React.createElement(MobileInbox, {
635
618
  data: {
636
- items: filteredStaticData,
637
- totalCount: filteredStaticData.length
619
+ items: filteredData,
620
+ totalCount: totalRecords
638
621
  },
639
- isLoading: false,
622
+ isLoading: isLoading || isFetching,
640
623
  onSearch: handleSearch,
641
624
  searchFields: searchFields,
642
625
  searchParams: searchParams,
643
626
  parentRoute: parentRoute,
644
- countData: staticCountData
627
+ countData: countData
645
628
  }) : /*#__PURE__*/React.createElement(DesktopInbox, {
646
629
  businessService: _businessService,
647
630
  data: {
648
- items: filteredStaticData,
649
- totalCount: filteredStaticData.length
631
+ items: filteredData,
632
+ totalCount: totalRecords
650
633
  },
651
- isLoading: false,
634
+ isLoading: isLoading || isFetching,
652
635
  searchFields: searchFields,
653
636
  onSearch: handleSearch,
654
637
  onSort: handleSort,
@@ -660,8 +643,8 @@ const Inbox = ({
660
643
  parentRoute: parentRoute,
661
644
  searchParams: searchParams,
662
645
  sortParams: sortParams,
663
- totalRecords: filteredStaticData.length,
664
- countData: staticCountData,
646
+ totalRecords: totalRecords,
647
+ countData: countData,
665
648
  filterComponent: "EKYC_INBOX_FILTER"
666
649
  })));
667
650
  };
@@ -885,28 +868,6 @@ const Create = () => {
885
868
  }));
886
869
  };
887
870
 
888
- const FlagIcon = ({
889
- size: _size = 20
890
- }) => /*#__PURE__*/React.createElement("svg", {
891
- width: _size,
892
- height: _size,
893
- viewBox: "0 0 24 24",
894
- fill: "none"
895
- }, /*#__PURE__*/React.createElement("path", {
896
- d: "M14.4 6L13.6 4H5V21H7V14H12.6L13.4 16H20V6H14.4Z",
897
- fill: "#0F6E56"
898
- }));
899
- const IdCardIcon = ({
900
- size: _size2 = 20
901
- }) => /*#__PURE__*/React.createElement("svg", {
902
- width: _size2,
903
- height: _size2,
904
- viewBox: "0 0 24 24",
905
- fill: "none"
906
- }, /*#__PURE__*/React.createElement("path", {
907
- d: "M2 7V17C2 18.1 2.9 19 4 19H20C21.1 19 22 18.1 22 17V7C22 5.9 21.1 5 20 5H4C2.9 5 2 5.9 2 7ZM12 11H14V13H12V11ZM12 7H14V9H12V7ZM16 11H20V13H16V11ZM16 7H20V9H16V7ZM4 7H10V15H4V7ZM20 17H4V16H20V17Z",
908
- fill: "#185FA5"
909
- }));
910
871
  const CameraIcon = ({
911
872
  size: _size3 = 28
912
873
  }) => /*#__PURE__*/React.createElement("svg", {
@@ -1035,53 +996,12 @@ const SectionHead = ({
1035
996
  background: "#EAECF0"
1036
997
  }
1037
998
  }));
1038
- const AdminCard = ({
1039
- bgColor,
1040
- iconBg,
1041
- icon,
1042
- labelColor,
1043
- label,
1044
- value
1045
- }) => /*#__PURE__*/React.createElement("div", {
1046
- style: {
1047
- backgroundColor: bgColor,
1048
- padding: "14px 16px",
1049
- borderRadius: "8px",
1050
- display: "flex",
1051
- alignItems: "center",
1052
- gap: "14px",
1053
- border: "0.5px solid #EAECF0"
1054
- }
1055
- }, /*#__PURE__*/React.createElement("div", {
1056
- style: {
1057
- backgroundColor: iconBg,
1058
- padding: "8px",
1059
- borderRadius: "8px",
1060
- display: "flex",
1061
- flexShrink: 0
1062
- }
1063
- }, icon), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
1064
- style: {
1065
- color: labelColor,
1066
- fontSize: "10px",
1067
- fontWeight: "600",
1068
- textTransform: "uppercase",
1069
- letterSpacing: "0.05em",
1070
- marginBottom: "3px"
1071
- }
1072
- }, label), /*#__PURE__*/React.createElement("div", {
1073
- style: {
1074
- fontSize: "14px",
1075
- fontWeight: "600",
1076
- color: "#101828"
1077
- }
1078
- }, value)));
1079
999
  const AddressDetails = ({
1080
1000
  isSection: _isSection = false,
1081
1001
  onComplete,
1082
1002
  parentState
1083
1003
  }) => {
1084
- var _flowState$connection;
1004
+ var _flowState$connection, _mdmsRes$egovLocatio, _mdmsRes$egovLocatio$, _mdmsRes$egovLocatio2, _mdmsRes$egovLocatio3;
1085
1005
  const {
1086
1006
  t
1087
1007
  } = useTranslation();
@@ -1112,6 +1032,72 @@ const AddressDetails = ({
1112
1032
  const [doorPhoto, setDoorPhoto] = useState(null);
1113
1033
  const [isLocationFetching, setIsLocationFetching] = useState(false);
1114
1034
  const fileInputRef = useRef(null);
1035
+ const tenantId = Digit.ULBService.getCurrentTenantId();
1036
+ const {
1037
+ data: mdmsData,
1038
+ isLoading: isMdmsLoading
1039
+ } = Digit.Hooks.useCommonMDMS(tenantId, "egov-location", ["TenantBoundary"]);
1040
+ const mdmsRes = (mdmsData === null || mdmsData === void 0 ? void 0 : mdmsData.MdmsRes) || mdmsData;
1041
+ const adminHierarchy = (mdmsRes === null || mdmsRes === void 0 ? void 0 : (_mdmsRes$egovLocatio = mdmsRes["egov-location"]) === null || _mdmsRes$egovLocatio === void 0 ? void 0 : (_mdmsRes$egovLocatio$ = _mdmsRes$egovLocatio.TenantBoundary) === null || _mdmsRes$egovLocatio$ === void 0 ? void 0 : _mdmsRes$egovLocatio$.find(h => h.hierarchyType.code === "ADMIN")) || (mdmsRes === null || mdmsRes === void 0 ? void 0 : (_mdmsRes$egovLocatio2 = mdmsRes["egov-location"]) === null || _mdmsRes$egovLocatio2 === void 0 ? void 0 : (_mdmsRes$egovLocatio3 = _mdmsRes$egovLocatio2.TenantBoundary) === null || _mdmsRes$egovLocatio3 === void 0 ? void 0 : _mdmsRes$egovLocatio3[0]);
1042
+ const rootBoundary = adminHierarchy === null || adminHierarchy === void 0 ? void 0 : adminHierarchy.boundary;
1043
+ const getAssemblies = boundaries => {
1044
+ if (!boundaries) return [];
1045
+ let assemblies = [];
1046
+ const targetLabel = "assembly constituency";
1047
+ for (const boundary of boundaries) {
1048
+ var _boundary$children;
1049
+ const label = (boundary.label || boundary.name || "").toLowerCase().replace(/_/g, " ");
1050
+ if (label === targetLabel || label === "assemblyconstituency") {
1051
+ assemblies.push({
1052
+ code: boundary.code,
1053
+ name: boundary.name,
1054
+ children: boundary.children
1055
+ });
1056
+ }
1057
+ if ((_boundary$children = boundary.children) !== null && _boundary$children !== void 0 && _boundary$children.length) {
1058
+ assemblies.push(...getAssemblies(boundary.children));
1059
+ }
1060
+ }
1061
+ return assemblies;
1062
+ };
1063
+ const getBlocks = children => {
1064
+ if (!children) return [];
1065
+ let blocks = [];
1066
+ const targetLabel = "block";
1067
+ for (const child of children) {
1068
+ var _child$children;
1069
+ const label = (child.label || child.name || "").toLowerCase().replace(/_/g, " ");
1070
+ if (label === targetLabel) {
1071
+ blocks.push({
1072
+ code: child.code,
1073
+ name: child.name
1074
+ });
1075
+ }
1076
+ if ((_child$children = child.children) !== null && _child$children !== void 0 && _child$children.length) {
1077
+ blocks.push(...getBlocks(child.children));
1078
+ }
1079
+ }
1080
+ return blocks;
1081
+ };
1082
+ const assemblies = getAssemblies(Array.isArray(rootBoundary) ? rootBoundary : rootBoundary ? [rootBoundary] : []);
1083
+ const [assembly, setAssembly] = useState(addrDetails.assembly ? {
1084
+ name: addrDetails.assembly
1085
+ } : null);
1086
+ const [ward, setWard] = useState(addrDetails.ward ? {
1087
+ name: addrDetails.ward
1088
+ } : null);
1089
+ useEffect(() => {
1090
+ if (mdmsRes && addrDetails.assembly && !(assembly !== null && assembly !== void 0 && assembly.code)) {
1091
+ const foundAssembly = assemblies.find(a => a.name === addrDetails.assembly || a.code === addrDetails.assembly);
1092
+ if (foundAssembly) setAssembly(foundAssembly);
1093
+ }
1094
+ }, [mdmsRes, assemblies]);
1095
+ const blocks = assembly ? getBlocks(assembly.children) : [];
1096
+ useEffect(() => {
1097
+ if (assembly && ward && !blocks.find(b => b.name === ward.name)) {
1098
+ setWard(null);
1099
+ }
1100
+ }, [assembly]);
1115
1101
  const addressOptions = [{
1116
1102
  code: "AADHAAR",
1117
1103
  name: "EKYC_AADHAAR_ADDRESS"
@@ -1134,7 +1120,9 @@ const AddressDetails = ({
1134
1120
  building,
1135
1121
  landmark,
1136
1122
  pincode,
1137
- doorPhoto
1123
+ doorPhoto,
1124
+ assembly: assembly === null || assembly === void 0 ? void 0 : assembly.name,
1125
+ ward: ward === null || ward === void 0 ? void 0 : ward.name
1138
1126
  };
1139
1127
  if (onComplete) {
1140
1128
  onComplete(payload);
@@ -1492,32 +1480,48 @@ const AddressDetails = ({
1492
1480
  }
1493
1481
  }),
1494
1482
  label: t("EKYC_ADMINISTRATIVE_DIVISION") || "Administrative Division"
1495
- }), /*#__PURE__*/React.createElement("div", {
1483
+ }), isMdmsLoading ? /*#__PURE__*/React.createElement(Loader, null) : /*#__PURE__*/React.createElement("div", {
1496
1484
  style: {
1497
1485
  display: "grid",
1498
1486
  gridTemplateColumns: "1fr 1fr",
1499
1487
  gap: "14px",
1500
1488
  marginBottom: "24px"
1501
1489
  }
1502
- }, /*#__PURE__*/React.createElement(AdminCard, {
1503
- bgColor: "#E1F5EE",
1504
- iconBg: "#9FE1CB",
1505
- icon: /*#__PURE__*/React.createElement(FlagIcon, {
1506
- size: 18
1507
- }),
1508
- labelColor: "#0F6E56",
1509
- label: t("EKYC_ASSEMBLY") || "Assembly",
1510
- value: addrDetails.assembly || "AC-12 Chandni Chowk"
1511
- }), /*#__PURE__*/React.createElement(AdminCard, {
1512
- bgColor: "#E6F1FB",
1513
- iconBg: "#B5D4F4",
1514
- icon: /*#__PURE__*/React.createElement(IdCardIcon, {
1515
- size: 18
1516
- }),
1517
- labelColor: "#185FA5",
1518
- label: t("EKYC_WARD") || "Ward",
1519
- value: addrDetails.ward || "WARD-45 Civil Lines"
1520
- })), /*#__PURE__*/React.createElement("hr", {
1490
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
1491
+ style: {
1492
+ fontSize: "11px",
1493
+ fontWeight: "600",
1494
+ color: "#667085",
1495
+ textTransform: "uppercase",
1496
+ letterSpacing: "0.04em",
1497
+ marginBottom: "6px"
1498
+ }
1499
+ }, t("EKYC_ASSEMBLY") || "Assembly Constituency"), /*#__PURE__*/React.createElement(Dropdown, {
1500
+ option: assemblies,
1501
+ optionKey: "name",
1502
+ selected: assembly,
1503
+ select: val => {
1504
+ setAssembly(val);
1505
+ setWard(null);
1506
+ },
1507
+ t: t
1508
+ })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
1509
+ style: {
1510
+ fontSize: "11px",
1511
+ fontWeight: "600",
1512
+ color: "#667085",
1513
+ textTransform: "uppercase",
1514
+ letterSpacing: "0.04em",
1515
+ marginBottom: "6px"
1516
+ }
1517
+ }, t("EKYC_WARD") || "Block"), /*#__PURE__*/React.createElement(Dropdown, {
1518
+ option: blocks,
1519
+ optionKey: "name",
1520
+ selected: ward,
1521
+ select: setWard,
1522
+ disabled: !assembly,
1523
+ t: t
1524
+ }))), /*#__PURE__*/React.createElement("hr", {
1521
1525
  style: {
1522
1526
  margin: "24px 0",
1523
1527
  border: 0,
@@ -2042,9 +2046,12 @@ const RadioToggleRow = ({
2042
2046
  t: t,
2043
2047
  innerStyles: {
2044
2048
  display: "flex",
2045
- gap: "20px"
2049
+ gap: "20px",
2050
+ alignItems: "center"
2046
2051
  },
2047
2052
  style: {
2053
+ display: "flex",
2054
+ gap: "20px",
2048
2055
  marginBottom: 0
2049
2056
  }
2050
2057
  }));
@@ -2176,7 +2183,7 @@ const AadhaarVerification = () => {
2176
2183
  display: "grid",
2177
2184
  gridTemplateColumns: "1fr 1fr",
2178
2185
  gap: "14px",
2179
- marginBottom: "4px"
2186
+ marginBottom: "20px"
2180
2187
  },
2181
2188
  optionalTag: {
2182
2189
  display: "inline-block",
@@ -2320,7 +2327,7 @@ const AadhaarVerification = () => {
2320
2327
  if (val.length <= 12 && /^\d*$/.test(val)) setAadhaarLastFour(val);
2321
2328
  },
2322
2329
  placeholder: t("EKYC_ENTER_LAST_4_DIGIT") || "Enter 12 digits",
2323
- maxLength: 4,
2330
+ maxLength: 12,
2324
2331
  disabled: isAadhaarVerified,
2325
2332
  inputStyle: isAadhaarVerified ? styles.verifiedInput : {}
2326
2333
  }))), !isAadhaarVerified && /*#__PURE__*/React.createElement(SubmitBar, {
@@ -2401,6 +2408,7 @@ const AadhaarVerification = () => {
2401
2408
  selected: nameCorrect,
2402
2409
  onSelect: setNameCorrect,
2403
2410
  options: yesNoOptions,
2411
+ sty: true,
2404
2412
  t: t
2405
2413
  }), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement("div", {
2406
2414
  className: "field"
@@ -2409,6 +2417,9 @@ const AadhaarVerification = () => {
2409
2417
  size: 15,
2410
2418
  color: nameCorrect.code === "YES" ? "#64748b" : "#94a3b8"
2411
2419
  }),
2420
+ style: {
2421
+ marginBottom: "12px"
2422
+ },
2412
2423
  value: userName,
2413
2424
  onChange: e => setUserName(e.target.value),
2414
2425
  placeholder: t("EKYC_ENTER_NAME_PLACEHOLDER") || "Enter full name",
@@ -2426,6 +2437,9 @@ const AadhaarVerification = () => {
2426
2437
  size: 15,
2427
2438
  color: mobileChange.code === "YES" ? "#64748b" : "#94a3b8"
2428
2439
  }),
2440
+ style: {
2441
+ marginBottom: "12px"
2442
+ },
2429
2443
  value: mobileNumber,
2430
2444
  onChange: e => setMobileNumber(e.target.value),
2431
2445
  placeholder: "+91 XXXXX XXXXX",