@djb25/digit-ui-module-ekyc 1.0.40 → 1.0.42

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,16 +1,18 @@
1
- import React, { useRef, useEffect, useMemo, useState, createContext, isValidElement, cloneElement, createElement, useContext, useCallback, useReducer, Fragment } from 'react';
1
+ import React, { useRef, useEffect, useMemo, useState, createContext, useContext, isValidElement, cloneElement, createElement, useCallback, useReducer, Fragment } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import { useHistory, Link, useLocation, useParams, useRouteMatch, Switch, Route, Redirect } from 'react-router-dom';
4
- import { PersonIcon, EmployeeModuleCard, Loader, Card, InboxLinks, Table, HomeIcon, TextInput, Header, SubmitBar, DetailsCard, FilterForm, FilterFormField, Dropdown, Label, CustomTooltip, CardLabelError, InboxComposer, EditIcon, DeleteIcon, CardHeader, CardText, LabelFieldPair, CardLabel, ActionBar, Modal, Toast, RadioButtons, CardSubHeader, StatusTable, Row, GenericFileIcon, CheckBox, Menu, LinkButton, UploadFile, FormComposer, VerticalTimeline, Close, AppContainer, ModuleHeader, ArrowLeft, PrivateRoute, LayoutWrapper, CitizenHomeCard, DocumentIcon, BackButton } from '@djb25/digit-ui-react-components';
4
+ import { PersonIcon, EmployeeModuleCard, Loader, Card, InboxLinks, Table, HomeIcon, TextInput, Header, SubmitBar, DetailsCard, FilterForm, FilterFormField, Dropdown, Label, CustomTooltip, CardLabelError, SearchField, RadioButtons, InboxComposer, EditIcon, DeleteIcon, CardHeader, CardText, LabelFieldPair, CardLabel, ActionBar, Modal, Toast, CardSubHeader, StatusTable, Row, GenericFileIcon, CheckBox, Menu, LinkButton, UploadFile, FormComposer, VerticalTimeline, Close, AppContainer, ModuleHeader, ArrowLeft, PrivateRoute, LayoutWrapper, CitizenHomeCard, DocumentIcon, BackButton } from '@djb25/digit-ui-react-components';
5
5
  import * as Chartjs from 'chart.js/auto';
6
6
  import Chartjs__default, { Chart } from 'chart.js/auto';
7
7
  import { FaUsers, FaCheckCircle, FaClock, FaExclamationTriangle, FaUserTie, FaChartLine, FaSearch, FaArrowRight, FaMapMarkedAlt } from 'react-icons/fa';
8
8
  import { ResponsiveContainer, LineChart, CartesianGrid, XAxis, YAxis, Tooltip, Legend, Line, BarChart, Bar, PieChart, Pie, Cell } from 'recharts';
9
9
 
10
10
  const EKYCCard = () => {
11
+ var _Digit$SessionStorage, _Digit$SessionStorage2, _Digit$SessionStorage3;
11
12
  const _useTranslation = useTranslation(),
12
13
  t = _useTranslation.t;
13
14
  const tenantId = Digit.ULBService.getCurrentTenantId();
15
+ const roles = ((_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : (_Digit$SessionStorage2 = _Digit$SessionStorage.info) === null || _Digit$SessionStorage2 === void 0 ? void 0 : (_Digit$SessionStorage3 = _Digit$SessionStorage2.roles) === null || _Digit$SessionStorage3 === void 0 ? void 0 : _Digit$SessionStorage3.map(r => r.code)) || [];
14
16
  const _Digit$Hooks$ekyc$use = Digit.Hooks.ekyc.useEkycApplicationList({}, {
15
17
  tenantId,
16
18
  offset: 0,
@@ -39,10 +41,10 @@ const EKYCCard = () => {
39
41
  count: totalCount,
40
42
  label: t("EKYC_INBOX"),
41
43
  link: "/digit-ui/employee/ekyc/inbox"
42
- }, {
44
+ }, ...(!roles.includes("EMPLOYEE") ? [{
43
45
  label: t("EKYC_ASSIGN"),
44
46
  link: "/digit-ui/employee/ekyc/assign"
45
- }]
47
+ }] : [])]
46
48
  };
47
49
  return /*#__PURE__*/React.createElement(EmployeeModuleCard, propsForModuleCard);
48
50
  };
@@ -327,7 +329,7 @@ const DesktopInbox = _ref => {
327
329
  Cell: _ref4 => {
328
330
  var _row$original4;
329
331
  let row = _ref4.row;
330
- const status = ((_row$original4 = row.original) === null || _row$original4 === void 0 ? void 0 : _row$original4.status) || "DEFAULT";
332
+ const status = (((_row$original4 = row.original) === null || _row$original4 === void 0 ? void 0 : _row$original4.status) || "DEFAULT").toUpperCase();
331
333
  return /*#__PURE__*/React.createElement("span", {
332
334
  className: "ekyc-status-tag " + status
333
335
  }, t("" + status));
@@ -1939,12 +1941,6 @@ const VendorDetailsCard = () => {
1939
1941
  color: "#0B2559",
1940
1942
  type: "today",
1941
1943
  icon: /*#__PURE__*/React.createElement(FaUsers, null)
1942
- }, {
1943
- label: "TOTAL_ASSIGNMENTS",
1944
- count: totalKnos,
1945
- color: "#3B82F6",
1946
- type: "week",
1947
- icon: /*#__PURE__*/React.createElement(FaMapMarkedAlt, null)
1948
1944
  }, {
1949
1945
  label: "EKYC_COMPLETED",
1950
1946
  count: completedKnos,
@@ -2053,20 +2049,20 @@ const VendorDetailsCard = () => {
2053
2049
  Header: t("SUPERVISOR_NAME") || "Supervisor Name",
2054
2050
  accessor: row => (row === null || row === void 0 ? void 0 : row.name) || "N/A",
2055
2051
  Cell: _ref => {
2056
- var _row$original;
2052
+ var _Digit$SessionStorage2, _Digit$SessionStorage3, _Digit$SessionStorage4, _row$original;
2057
2053
  let row = _ref.row;
2054
+ const userType = ((_Digit$SessionStorage2 = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage2 === void 0 ? void 0 : (_Digit$SessionStorage3 = _Digit$SessionStorage2.info) === null || _Digit$SessionStorage3 === void 0 ? void 0 : (_Digit$SessionStorage4 = _Digit$SessionStorage3.type) === null || _Digit$SessionStorage4 === void 0 ? void 0 : _Digit$SessionStorage4.toLowerCase()) || "citizen";
2055
+ const targetPath = "/digit-ui/" + userType + "/ekyc/supervisor-dashboard/" + row.original.id;
2058
2056
  return /*#__PURE__*/React.createElement("a", {
2059
- href: "/digit-ui/employee/ekyc/assign/surveyor-details/" + row.original.id,
2057
+ href: targetPath,
2060
2058
  style: {
2061
2059
  color: "#1D70B8",
2062
2060
  fontWeight: "600",
2063
2061
  textDecoration: "none"
2064
2062
  },
2065
2063
  onClick: e => {
2066
- var _Digit$SessionStorage2, _Digit$SessionStorage3, _Digit$SessionStorage4;
2067
- const userType = ((_Digit$SessionStorage2 = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage2 === void 0 ? void 0 : (_Digit$SessionStorage3 = _Digit$SessionStorage2.info) === null || _Digit$SessionStorage3 === void 0 ? void 0 : (_Digit$SessionStorage4 = _Digit$SessionStorage3.type) === null || _Digit$SessionStorage4 === void 0 ? void 0 : _Digit$SessionStorage4.toLowerCase()) || "citizen";
2068
2064
  e.preventDefault();
2069
- history.push("/digit-ui/" + userType + "/ekyc/assign/surveyor-details/" + row.original.id);
2065
+ history.push(targetPath);
2070
2066
  }
2071
2067
  }, ((_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original.name) || "N/A");
2072
2068
  }
@@ -2446,17 +2442,31 @@ const useInboxTableConfig = _ref => {
2446
2442
  Cell: _ref4 => {
2447
2443
  var _row$original4;
2448
2444
  let row = _ref4.row;
2449
- const status = ((_row$original4 = row.original) === null || _row$original4 === void 0 ? void 0 : _row$original4.status) || "DEFAULT";
2445
+ const status = (((_row$original4 = row.original) === null || _row$original4 === void 0 ? void 0 : _row$original4.status) || "DEFAULT").toUpperCase();
2450
2446
  return /*#__PURE__*/React.createElement("span", {
2451
2447
  className: "ekyc-status-tag " + status
2452
2448
  }, t("" + status));
2453
2449
  }
2450
+ }, {
2451
+ Header: t("SUBMITTED_AT") || "Submitted At",
2452
+ accessor: "submittedAt",
2453
+ Cell: _ref5 => {
2454
+ let value = _ref5.value;
2455
+ return value ? Digit.DateUtils.ConvertEpochToDate(value) : "-";
2456
+ }
2457
+ }, {
2458
+ Header: t("ASSIGNED_AT") || "Assigned At",
2459
+ accessor: "assignedAt",
2460
+ Cell: _ref6 => {
2461
+ let value = _ref6.value;
2462
+ return value ? Digit.DateUtils.ConvertEpochToDate(value) : "-";
2463
+ }
2454
2464
  }, {
2455
2465
  Header: t("EKYC_EKYC_STATUS"),
2456
2466
  accessor: "ekycStatus",
2457
- Cell: _ref5 => {
2467
+ Cell: _ref7 => {
2458
2468
  var _row$original5, _row$original6;
2459
- let row = _ref5.row;
2469
+ let row = _ref7.row;
2460
2470
  const ekycStatus = (((_row$original5 = row.original) === null || _row$original5 === void 0 ? void 0 : _row$original5.ekycStatus) || ((_row$original6 = row.original) === null || _row$original6 === void 0 ? void 0 : _row$original6.ekycstatus) || "NA").toUpperCase();
2461
2471
  return /*#__PURE__*/React.createElement("span", {
2462
2472
  className: "ekyc-status-tag " + ekycStatus
@@ -2806,6 +2816,92 @@ const SearchFormFieldsComponents = _ref => {
2806
2816
  }), (errors === null || errors === void 0 ? void 0 : errors.kNumber) && /*#__PURE__*/React.createElement(CardLabelError, null, errors.kNumber.message)));
2807
2817
  };
2808
2818
 
2819
+ const useInboxMobileCardsData = _ref => {
2820
+ var _Digit$SessionStorage, _Digit$SessionStorage2, _Digit$SessionStorage3;
2821
+ let table = _ref.table,
2822
+ tenantId = _ref.tenantId;
2823
+ const _useTranslation = useTranslation(),
2824
+ t = _useTranslation.t;
2825
+ const history = useHistory();
2826
+ const _useState = useState(""),
2827
+ selectedKno = _useState[0],
2828
+ setSelectedKno = _useState[1];
2829
+ const _Digit$Hooks$ekyc$use = Digit.Hooks.ekyc.useEkycAPI("review", tenantId),
2830
+ reviewData = _Digit$Hooks$ekyc$use.data,
2831
+ getReview = _Digit$Hooks$ekyc$use.getReview;
2832
+ const userType = ((_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : (_Digit$SessionStorage2 = _Digit$SessionStorage.info) === null || _Digit$SessionStorage2 === void 0 ? void 0 : (_Digit$SessionStorage3 = _Digit$SessionStorage2.type) === null || _Digit$SessionStorage3 === void 0 ? void 0 : _Digit$SessionStorage3.toLowerCase()) || "citizen";
2833
+ React.useEffect(() => {
2834
+ if (reviewData) {
2835
+ history.push("/digit-ui/" + userType + "/ekyc/review/" + selectedKno, {
2836
+ aadhaarData: reviewData === null || reviewData === void 0 ? void 0 : reviewData.aadhaarData,
2837
+ reviewData
2838
+ });
2839
+ }
2840
+ }, [reviewData]);
2841
+ const handleReview = kno => {
2842
+ setSelectedKno(kno);
2843
+ getReview({
2844
+ kno
2845
+ });
2846
+ };
2847
+ const dataForMobileInboxCards = table === null || table === void 0 ? void 0 : table.map(item => {
2848
+ const kno = item.kno || item.applicationNumber || "NA";
2849
+ const status = (item.status || "DEFAULT").toUpperCase();
2850
+ const ekycStatus = (item.ekycStatus || item.ekycstatus || "NA").toUpperCase();
2851
+ return {
2852
+ [t("EKYC_APPLICATION_NO")]: /*#__PURE__*/React.createElement("span", {
2853
+ className: "link",
2854
+ onClick: () => handleReview(kno)
2855
+ }, kno),
2856
+ [t("EKYC_CITIZEN_NAME")]: item.citizenName || "NA",
2857
+ [t("EKYC_STATUS")]: /*#__PURE__*/React.createElement("span", {
2858
+ className: "ekyc-status-tag " + status
2859
+ }, t("" + status)),
2860
+ [t("SUBMITTED_AT")]: item.submittedAt ? Digit.DateUtils.ConvertEpochToDate(item.submittedAt) : "-",
2861
+ [t("ASSIGNED_AT")]: item.assignedAt ? Digit.DateUtils.ConvertEpochToDate(item.assignedAt) : "-",
2862
+ [t("EKYC_EKYC_STATUS")]: /*#__PURE__*/React.createElement("span", {
2863
+ className: "ekyc-status-tag " + ekycStatus
2864
+ }, t("" + ekycStatus))
2865
+ };
2866
+ });
2867
+ const MobileSortFormValues = () => {
2868
+ const sortOrderOptions = [{
2869
+ code: "DESC",
2870
+ i18nKey: "ES_INBOX_DATE_LATEST_FIRST"
2871
+ }, {
2872
+ code: "ASC",
2873
+ i18nKey: "ES_INBOX_DATE_LATEST_LAST"
2874
+ }];
2875
+ const _useFormContext = useFormContext(),
2876
+ controlSortForm = _useFormContext.control;
2877
+ return /*#__PURE__*/React.createElement(SearchField, null, /*#__PURE__*/React.createElement(Controller, {
2878
+ name: "sortOrder",
2879
+ control: controlSortForm,
2880
+ render: _ref2 => {
2881
+ let onChange = _ref2.onChange,
2882
+ value = _ref2.value;
2883
+ return /*#__PURE__*/React.createElement(RadioButtons, {
2884
+ onSelect: e => {
2885
+ onChange(e.code);
2886
+ },
2887
+ selectedOption: sortOrderOptions.filter(option => option.code === value)[0],
2888
+ optionsKey: "i18nKey",
2889
+ name: "sortOrder",
2890
+ options: sortOrderOptions
2891
+ });
2892
+ }
2893
+ }));
2894
+ };
2895
+ return {
2896
+ data: dataForMobileInboxCards,
2897
+ isTwoDynamicPrefix: true,
2898
+ getRedirectionLink: () => {},
2899
+ handleClickEnabled: false,
2900
+ serviceRequestIdKey: "applicationNo",
2901
+ MobileSortFormValues
2902
+ };
2903
+ };
2904
+
2809
2905
  const Inbox = _ref => {
2810
2906
  var _formState$tableForm3, _formState$tableForm4, _formState$searchForm3, _formState$searchForm4;
2811
2907
  let parentRoute = _ref.parentRoute;
@@ -3029,13 +3125,39 @@ const Inbox = _ref => {
3029
3125
  width: "70%"
3030
3126
  }
3031
3127
  }));
3128
+ const onMobileSortOrderData = data => {
3129
+ const sortOrder = data.sortOrder;
3130
+ dispatch({
3131
+ action: "mutateTableForm",
3132
+ data: _extends({}, formState.tableForm, {
3133
+ sortOrder
3134
+ })
3135
+ });
3136
+ };
3137
+ const onSortFormReset = setSortFormValue => {
3138
+ setSortFormValue("sortOrder", "DESC");
3139
+ dispatch({
3140
+ action: "mutateTableForm",
3141
+ data: tableOrderFormDefaultValues
3142
+ });
3143
+ };
3144
+ const propsForMobileSortForm = {
3145
+ onMobileSortOrderData,
3146
+ sortFormDefaultValues: formState === null || formState === void 0 ? void 0 : formState.tableForm,
3147
+ onSortFormReset
3148
+ };
3149
+ const propsForInboxMobileCards = useInboxMobileCardsData({
3150
+ table: filteredData,
3151
+ tenantId
3152
+ });
3032
3153
  const isInboxLoading = isListLoading || isSearchLoading;
3033
3154
  return /*#__PURE__*/React.createElement("div", {
3034
3155
  className: "app-container"
3035
3156
  }, /*#__PURE__*/React.createElement(InboxComposer, _extends({
3036
3157
  isInboxLoading
3037
- }, propsForSearchForm, {
3158
+ }, propsForSearchForm, propsForMobileSortForm, {
3038
3159
  propsForInboxTable,
3160
+ propsForInboxMobileCards,
3039
3161
  formState,
3040
3162
  countData: listData
3041
3163
  })));
@@ -5387,759 +5509,916 @@ const EKYCForm = _ref => {
5387
5509
  }))))));
5388
5510
  };
5389
5511
 
5390
- const AssignEkycModal = _ref => {
5391
- let surveyor = _ref.surveyor,
5392
- closeModal = _ref.closeModal,
5393
- refetchDashboard = _ref.refetchDashboard;
5512
+ function formReducer(state, payload) {
5513
+ const storageKey = "EKYC.SW.INBOX";
5514
+ switch (payload.action) {
5515
+ case "mutateSearchForm":
5516
+ Digit.SessionStorage.set(storageKey, _extends({}, state, {
5517
+ searchForm: payload.data
5518
+ }));
5519
+ return _extends({}, state, {
5520
+ searchForm: payload.data
5521
+ });
5522
+ case "mutateFilterForm":
5523
+ Digit.SessionStorage.set(storageKey, _extends({}, state, {
5524
+ filterForm: payload.data
5525
+ }));
5526
+ return _extends({}, state, {
5527
+ filterForm: payload.data
5528
+ });
5529
+ case "mutateTableForm":
5530
+ Digit.SessionStorage.set(storageKey, _extends({}, state, {
5531
+ tableForm: payload.data
5532
+ }));
5533
+ return _extends({}, state, {
5534
+ tableForm: payload.data
5535
+ });
5536
+ default:
5537
+ return state;
5538
+ }
5539
+ }
5540
+ const formInitValue = {
5541
+ filterForm: {},
5542
+ searchForm: {},
5543
+ tableForm: {
5544
+ limit: 10,
5545
+ offset: 0,
5546
+ sortBy: "createdTime",
5547
+ sortOrder: "DESC"
5548
+ }
5549
+ };
5550
+ const tableColumnConfig = (t, handleReview) => [{
5551
+ Header: t("SURVEYOR_NAME"),
5552
+ accessor: "surveyorName",
5553
+ Cell: _ref => {
5554
+ var _row$original, _row$original2, _row$original3;
5555
+ let row = _ref.row;
5556
+ const id = (_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original.id;
5557
+ return /*#__PURE__*/React.createElement("span", {
5558
+ className: "link",
5559
+ onClick: () => handleReview(id)
5560
+ }, ((_row$original2 = row.original) === null || _row$original2 === void 0 ? void 0 : _row$original2.surveyorName) || ((_row$original3 = row.original) === null || _row$original3 === void 0 ? void 0 : _row$original3.name) || "NA");
5561
+ }
5562
+ }, {
5563
+ Header: t("MOBILE_NUMBER"),
5564
+ accessor: "mobileNo",
5565
+ Cell: _ref2 => {
5566
+ var _row$original4, _row$original5, _row$original5$owner;
5567
+ let row = _ref2.row;
5568
+ return /*#__PURE__*/React.createElement("span", null, ((_row$original4 = row.original) === null || _row$original4 === void 0 ? void 0 : _row$original4.mobileNo) || ((_row$original5 = row.original) === null || _row$original5 === void 0 ? void 0 : (_row$original5$owner = _row$original5.owner) === null || _row$original5$owner === void 0 ? void 0 : _row$original5$owner.mobileNumber) || "NA");
5569
+ }
5570
+ }, {
5571
+ Header: t("STATUS"),
5572
+ accessor: "status",
5573
+ Cell: _ref3 => {
5574
+ var _row$original6;
5575
+ let row = _ref3.row;
5576
+ const status = ((_row$original6 = row.original) === null || _row$original6 === void 0 ? void 0 : _row$original6.status) || "DEFAULT";
5577
+ return /*#__PURE__*/React.createElement("span", {
5578
+ className: "ekyc-status-tag " + status
5579
+ }, t(status));
5580
+ }
5581
+ }, {
5582
+ Header: t("SERVICE_TYPE"),
5583
+ accessor: "serviceType",
5584
+ Cell: _ref4 => {
5585
+ var _row$original7;
5586
+ let row = _ref4.row;
5587
+ return /*#__PURE__*/React.createElement("span", null, ((_row$original7 = row.original) === null || _row$original7 === void 0 ? void 0 : _row$original7.serviceType) || "NA");
5588
+ }
5589
+ }];
5590
+
5591
+ const SupervisorInboxTableConfig = _ref => {
5592
+ var _Digit$SessionStorage, _Digit$SessionStorage2, _Digit$SessionStorage3, _formState$tableForm, _formState$tableForm2;
5593
+ let onPageSizeChange = _ref.onPageSizeChange,
5594
+ formState = _ref.formState,
5595
+ totalCount = _ref.totalCount,
5596
+ table = _ref.table,
5597
+ dispatch = _ref.dispatch,
5598
+ onSortingByData = _ref.onSortingByData,
5599
+ _ref$inboxStyles = _ref.inboxStyles,
5600
+ inboxStyles = _ref$inboxStyles === void 0 ? {} : _ref$inboxStyles,
5601
+ _ref$tableStyle = _ref.tableStyle,
5602
+ tableStyle = _ref$tableStyle === void 0 ? {} : _ref$tableStyle;
5394
5603
  const _useTranslation = useTranslation(),
5395
5604
  t = _useTranslation.t;
5396
- const _useState = useState([]),
5397
- selectedKnos = _useState[0],
5398
- setSelectedKnos = _useState[1];
5399
- const _useState2 = useState(false),
5400
- isBulkSelection = _useState2[0],
5401
- setIsBulkSelection = _useState2[1];
5402
- const _useState3 = useState(0),
5403
- currentPage = _useState3[0],
5404
- setCurrentPage = _useState3[1];
5405
- const _useState4 = useState(10),
5406
- pageSize = _useState4[0],
5407
- setPageSize = _useState4[1];
5408
- const _useState5 = useState(false),
5409
- showToast = _useState5[0],
5410
- setShowToast = _useState5[1];
5411
- const _useState6 = useState({
5412
- error: false,
5413
- label: ""
5605
+ const history = useHistory();
5606
+ const userType = ((_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : (_Digit$SessionStorage2 = _Digit$SessionStorage.info) === null || _Digit$SessionStorage2 === void 0 ? void 0 : (_Digit$SessionStorage3 = _Digit$SessionStorage2.type) === null || _Digit$SessionStorage3 === void 0 ? void 0 : _Digit$SessionStorage3.toLowerCase()) || "citizen";
5607
+ const handleReview = id => {
5608
+ history.push("/digit-ui/" + userType + "/ekyc/assign/surveyor-details/" + id);
5609
+ };
5610
+ const limit = (formState === null || formState === void 0 ? void 0 : (_formState$tableForm = formState.tableForm) === null || _formState$tableForm === void 0 ? void 0 : _formState$tableForm.limit) || 10;
5611
+ const offset = (formState === null || formState === void 0 ? void 0 : (_formState$tableForm2 = formState.tableForm) === null || _formState$tableForm2 === void 0 ? void 0 : _formState$tableForm2.offset) || 0;
5612
+ return {
5613
+ disableSort: false,
5614
+ autoSort: false,
5615
+ manualPagination: true,
5616
+ currentPage: Math.floor(offset / limit),
5617
+ onPageSizeChange,
5618
+ onNextPage: () => dispatch({
5619
+ action: "mutateTableForm",
5620
+ data: _extends({}, formState.tableForm, {
5621
+ offset: Number(offset) + Number(limit)
5622
+ })
5414
5623
  }),
5415
- toastData = _useState6[0],
5416
- setToastData = _useState6[1];
5417
- const _useState7 = useState({
5418
- kno: "",
5419
- pincode: "",
5420
- zoneCode: "",
5421
- zoneName: "",
5422
- ward: "",
5423
- assembly: "",
5424
- mrkey: "",
5425
- ekycStatus: ""
5624
+ onPrevPage: () => dispatch({
5625
+ action: "mutateTableForm",
5626
+ data: _extends({}, formState.tableForm, {
5627
+ offset: Number(offset) - Number(limit)
5628
+ })
5426
5629
  }),
5427
- filters = _useState7[0],
5428
- setFilters = _useState7[1];
5429
- const _useState8 = useState(filters),
5430
- debouncedFilters = _useState8[0],
5431
- setDebouncedFilters = _useState8[1];
5432
- const _Digit$Hooks$ws$useWS = Digit.Hooks.ws.useWSConfigMDMS.ZROLocation("dl.djb"),
5433
- zroLocationsData = _Digit$Hooks$ws$useWS.data,
5434
- isZroLoading = _Digit$Hooks$ws$useWS.isLoading;
5435
- const mappedZROLocation = useMemo(() => {
5436
- return (zroLocationsData || []).map(item => ({
5437
- code: item.code,
5438
- name: item.name
5439
- }));
5440
- }, [zroLocationsData]);
5441
- const _Digit$Hooks$useCommo = Digit.Hooks.useCommonMDMS("dl.djb", "egov-location", ["TenantBoundary"]),
5442
- egovLocationData = _Digit$Hooks$useCommo.data;
5443
- const boundaryData = useMemo(() => {
5444
- var _egovLocationData$ego;
5445
- const tenantBoundary = (egovLocationData === null || egovLocationData === void 0 ? void 0 : (_egovLocationData$ego = egovLocationData["egov-location"]) === null || _egovLocationData$ego === void 0 ? void 0 : _egovLocationData$ego.TenantBoundary) || [];
5446
- const revenueData = tenantBoundary.find(item => {
5447
- var _item$hierarchyType;
5448
- return (item === null || item === void 0 ? void 0 : (_item$hierarchyType = item.hierarchyType) === null || _item$hierarchyType === void 0 ? void 0 : _item$hierarchyType.code) === "REVENUE";
5449
- });
5450
- const boundary = (revenueData === null || revenueData === void 0 ? void 0 : revenueData.boundary) || [];
5451
- return Array.isArray(boundary) ? boundary : [boundary];
5452
- }, [egovLocationData]);
5453
- const _useMemo = useMemo(() => {
5454
- const assemblies = new Map();
5455
- const wards = new Map();
5456
- const boundaries = Array.isArray(boundaryData) ? boundaryData : boundaryData ? [boundaryData] : [];
5457
- const traverse = node => {
5458
- if (!node) return;
5459
- if (node.label === "Ward" || node.label === "WARD" || node.label === "Block" || node.label === "BLOCK") {
5460
- const code = node.code || node.localname || node.name;
5461
- const name = node.name || node.localname || code;
5462
- if (code) wards.set(code, {
5463
- code,
5464
- name: name
5465
- });
5466
- }
5467
- if (node.label === "Assembly Constituency" || node.label === "ASSEMBLY_CONSTITUENCY") {
5468
- const code = node.code || node.localname || node.name;
5469
- const name = node.name || node.localname || code;
5470
- if (code) assemblies.set(code, {
5471
- code,
5472
- name: name
5473
- });
5474
- }
5475
- if (node.children && node.children.length > 0) {
5476
- node.children.forEach(traverse);
5477
- }
5478
- };
5479
- boundaries.forEach(traverse);
5480
- return {
5481
- assemblyOptions: Array.from(assemblies.values()).sort((a, b) => a.name.localeCompare(b.name)),
5482
- wardOptions: Array.from(wards.values()).sort((a, b) => a.name.localeCompare(b.name))
5483
- };
5484
- }, [boundaryData]),
5485
- assemblyOptions = _useMemo.assemblyOptions,
5486
- wardOptions = _useMemo.wardOptions;
5487
- const structuredLocalityData = useMemo(() => {
5488
- let localities = [];
5489
- const boundaries = Array.isArray(boundaryData) ? boundaryData : boundaryData ? [boundaryData] : [];
5490
- const extractLocalities = node => {
5491
- if (!node) return;
5492
- if (node.label === "Locality" || node.label === "LOCALITY") {
5493
- localities.push(_extends({}, node, {
5494
- name: node.localname || node.name || node.code
5495
- }));
5496
- }
5497
- if (node.children && node.children.length > 0) {
5498
- node.children.forEach(child => extractLocalities(child));
5499
- }
5500
- };
5501
- boundaries.forEach(rootNode => extractLocalities(rootNode));
5502
- return localities;
5503
- }, [boundaryData]);
5504
- const fetchedPincodes = useMemo(() => {
5505
- const pinSet = new Set();
5506
- structuredLocalityData.forEach(loc => {
5507
- if (loc.pincode) {
5508
- const pins = Array.isArray(loc.pincode) ? loc.pincode : [loc.pincode];
5509
- pins.forEach(p => {
5510
- if (p) {
5511
- const sanitizedPin = p.toString().split(".")[0];
5512
- pinSet.add(sanitizedPin);
5513
- }
5514
- });
5515
- }
5516
- });
5517
- return Array.from(pinSet).sort();
5518
- }, [structuredLocalityData]);
5519
- useEffect(() => {
5520
- const timer = setTimeout(() => {
5521
- setDebouncedFilters(filters);
5522
- }, 500);
5523
- return () => clearTimeout(timer);
5524
- }, [filters]);
5525
- useEffect(() => {
5526
- setCurrentPage(0);
5527
- }, [debouncedFilters, filters.kno]);
5528
- const _Digit$Hooks$ekyc$use = Digit.Hooks.ekyc.useEkycApplicationList(_extends({
5529
- unassignedOnly: true
5530
- }, filters.kno && {
5531
- kno: filters.kno
5532
- }, debouncedFilters.ekycStatus && {
5533
- ekycStatus: debouncedFilters.ekycStatus
5534
- }, debouncedFilters.zoneName && {
5535
- zoneName: debouncedFilters.zoneName
5536
- }, debouncedFilters.assembly && {
5537
- assembly: debouncedFilters.assembly
5538
- }, debouncedFilters.ward && {
5539
- ward: debouncedFilters.ward
5540
- }, debouncedFilters.mrkey && {
5541
- mrkey: debouncedFilters.mrkey
5542
- }, debouncedFilters.pincode && {
5543
- pincode: debouncedFilters.pincode
5544
- }), {
5545
- tenantId: "dl.djb",
5546
- offset: currentPage * pageSize,
5547
- limit: pageSize
5548
- }, {
5549
- keepPreviousData: true
5630
+ onLastPage: () => dispatch({
5631
+ action: "mutateTableForm",
5632
+ data: _extends({}, formState.tableForm, {
5633
+ offset: Math.ceil(totalCount / limit) * limit - Number(limit)
5634
+ })
5550
5635
  }),
5551
- applicationData = _Digit$Hooks$ekyc$use.data,
5552
- isLoading = _Digit$Hooks$ekyc$use.isFetching;
5553
- const handleAssignmentError = (errMsg, variables) => {
5554
- const isAlreadyAssigned = errMsg.toLowerCase().includes("already assigned") || errMsg.toLowerCase().includes("already assign") || errMsg.toLowerCase().includes("active assignment") || errMsg.toLowerCase().includes("mrkey") || errMsg.toLowerCase().includes("mr key") || errMsg.toLowerCase().includes("kno") || errMsg.toLowerCase().includes("already exists");
5555
- if (isAlreadyAssigned) {
5556
- const isMrKeyType = (variables === null || variables === void 0 ? void 0 : variables.assignmentType) === "MRKEY";
5557
- if (isMrKeyType) {
5558
- setToastData({
5559
- error: true,
5560
- label: t("EKYC_MR_KEY_ALREADY_ASSIGNED_WITH_ANOTHER_SURVEYOR") || "mr key is already assign with another surveyor"
5561
- });
5562
- } else {
5563
- setToastData({
5564
- error: true,
5565
- label: t("EKYC_KNO_ALREADY_ASSIGNED_WITH_ANOTHER_SURVEYOR") || "kno is already assign with another surveyor"
5566
- });
5567
- }
5568
- } else {
5569
- setToastData({
5570
- error: true,
5571
- label: t(errMsg) || errMsg || t("EKYC_SOMETHING_WENT_WRONG") || "Something went wrong"
5572
- });
5573
- }
5574
- setShowToast(true);
5636
+ onFirstPage: () => dispatch({
5637
+ action: "mutateTableForm",
5638
+ data: _extends({}, formState.tableForm, {
5639
+ offset: 0
5640
+ })
5641
+ }),
5642
+ totalRecords: totalCount,
5643
+ onSort: onSortingByData,
5644
+ data: table,
5645
+ columns: tableColumnConfig(t, handleReview),
5646
+ inboxStyles: _extends({}, inboxStyles),
5647
+ tableStyle: _extends({}, tableStyle)
5575
5648
  };
5576
- const assignmentMutation = Digit.Hooks.ekyc.useEkycAssignmentCreate({
5577
- onSuccess: (response, variables) => {
5578
- if (response !== null && response !== void 0 && response.error) {
5579
- var _response$data;
5580
- const errMsg = (response === null || response === void 0 ? void 0 : (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.message) || "";
5581
- handleAssignmentError(errMsg, variables);
5582
- return;
5583
- }
5584
- if (response !== null && response !== void 0 && response.skipped && response.skipped.length > 0) {
5585
- var _response$skipped$;
5586
- const reason = ((_response$skipped$ = response.skipped[0]) === null || _response$skipped$ === void 0 ? void 0 : _response$skipped$.reason) || "";
5587
- handleAssignmentError(reason, variables);
5588
- return;
5589
- }
5590
- setToastData({
5591
- error: false,
5592
- label: t("EKYC_ASSIGNMENT_SUCCESSFUL") || "Assignment successful"
5593
- });
5594
- setShowToast(true);
5595
- setTimeout(function () {
5596
- try {
5597
- return Promise.resolve(refetchDashboard()).then(function () {
5598
- closeModal();
5599
- });
5600
- } catch (e) {
5601
- return Promise.reject(e);
5602
- }
5603
- }, 1000);
5604
- },
5605
- onError: (error, variables) => {
5606
- var _error$data, _error$response, _error$response$data;
5607
- const errMsg = (error === null || error === void 0 ? void 0 : (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.message) || (error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.message) || "";
5608
- handleAssignmentError(errMsg, variables);
5609
- }
5610
- });
5611
- const tableData = (applicationData === null || applicationData === void 0 ? void 0 : applicationData.consumerList) || [];
5612
- const getAssignmentPayload = () => {
5613
- if (isBulkSelection) {
5614
- const filterMappings = [{
5615
- key: "ekycStatus",
5616
- type: "EKYCSTATUS"
5617
- }, {
5618
- key: "zoneName",
5619
- type: "ZONENAME"
5620
- }, {
5621
- key: "assembly",
5622
- type: "ASSEMBLY"
5623
- }, {
5624
- key: "ward",
5625
- type: "WARD"
5626
- }, {
5627
- key: "mrkey",
5628
- type: "MRKEY"
5629
- }, {
5630
- key: "pincode",
5631
- type: "PINCODE"
5632
- }];
5633
- const appliedFilter = filterMappings.find(_ref2 => {
5634
- let key = _ref2.key;
5635
- return debouncedFilters[key];
5636
- });
5637
- if (appliedFilter) {
5638
- return {
5639
- assignmentType: appliedFilter.type,
5640
- assignmentValue: debouncedFilters[appliedFilter.key]
5641
- };
5642
- }
5643
- }
5649
+ };
5650
+
5651
+ const useSupervisorInboxMobileCardsData = _ref => {
5652
+ var _Digit$SessionStorage, _Digit$SessionStorage2, _Digit$SessionStorage3;
5653
+ let table = _ref.table;
5654
+ const _useTranslation = useTranslation(),
5655
+ t = _useTranslation.t;
5656
+ const history = useHistory();
5657
+ const userType = ((_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : (_Digit$SessionStorage2 = _Digit$SessionStorage.info) === null || _Digit$SessionStorage2 === void 0 ? void 0 : (_Digit$SessionStorage3 = _Digit$SessionStorage2.type) === null || _Digit$SessionStorage3 === void 0 ? void 0 : _Digit$SessionStorage3.toLowerCase()) || "citizen";
5658
+ const handleReview = id => {
5659
+ history.push("/digit-ui/" + userType + "/ekyc/assign/surveyor-details/" + id);
5660
+ };
5661
+ const dataForMobileInboxCards = table === null || table === void 0 ? void 0 : table.map(item => {
5662
+ var _item$owner;
5663
+ const id = item.id;
5664
+ const status = item.status || "DEFAULT";
5644
5665
  return {
5645
- assignmentType: "KNO",
5646
- assignmentValue: selectedKnos
5666
+ [t("SURVEYOR_NAME")]: /*#__PURE__*/React.createElement("span", {
5667
+ className: "link",
5668
+ onClick: () => handleReview(id)
5669
+ }, item.surveyorName || item.name || "NA"),
5670
+ [t("MOBILE_NUMBER")]: item.mobileNo || ((_item$owner = item.owner) === null || _item$owner === void 0 ? void 0 : _item$owner.mobileNumber) || "NA",
5671
+ [t("STATUS")]: /*#__PURE__*/React.createElement("span", {
5672
+ className: "ekyc-status-tag " + status
5673
+ }, t(status)),
5674
+ [t("SERVICE_TYPE")]: item.serviceType || "NA"
5647
5675
  };
5676
+ });
5677
+ const MobileSortFormValues = () => {
5678
+ const sortOrderOptions = [{
5679
+ code: "DESC",
5680
+ i18nKey: "ES_INBOX_DATE_LATEST_FIRST"
5681
+ }, {
5682
+ code: "ASC",
5683
+ i18nKey: "ES_INBOX_DATE_LATEST_LAST"
5684
+ }];
5685
+ const _useFormContext = useFormContext(),
5686
+ controlSortForm = _useFormContext.control;
5687
+ return /*#__PURE__*/React.createElement(SearchField, null, /*#__PURE__*/React.createElement(Controller, {
5688
+ name: "sortOrder",
5689
+ control: controlSortForm,
5690
+ render: _ref2 => {
5691
+ let onChange = _ref2.onChange,
5692
+ value = _ref2.value;
5693
+ return /*#__PURE__*/React.createElement(RadioButtons, {
5694
+ onSelect: e => {
5695
+ onChange(e.code);
5696
+ },
5697
+ selectedOption: sortOrderOptions.filter(option => option.code === value)[0],
5698
+ optionsKey: "i18nKey",
5699
+ name: "sortOrder",
5700
+ options: sortOrderOptions
5701
+ });
5702
+ }
5703
+ }));
5648
5704
  };
5649
- const handleAssign = () => {
5650
- var _surveyor$owner;
5651
- const _getAssignmentPayload = getAssignmentPayload(),
5652
- assignmentType = _getAssignmentPayload.assignmentType,
5653
- assignmentValue = _getAssignmentPayload.assignmentValue;
5654
- assignmentMutation.mutate({
5655
- tenantId: "dl.djb",
5656
- surveyorId: surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner = surveyor.owner) === null || _surveyor$owner === void 0 ? void 0 : _surveyor$owner.uuid,
5657
- assignmentType,
5658
- assignmentValue
5659
- });
5705
+ return {
5706
+ data: dataForMobileInboxCards,
5707
+ isTwoDynamicPrefix: true,
5708
+ getRedirectionLink: () => {},
5709
+ handleClickEnabled: false,
5710
+ serviceRequestIdKey: "id",
5711
+ MobileSortFormValues
5660
5712
  };
5661
- const handleSelectAll = () => {
5662
- setIsBulkSelection(true);
5663
- const pageKnos = tableData.map(item => item.kno);
5664
- const allSelected = pageKnos.length > 0 && pageKnos.every(kno => selectedKnos.includes(kno));
5665
- setSelectedKnos(prev => allSelected ? prev.filter(kno => !pageKnos.includes(kno)) : [...new Set([...prev, ...pageKnos])]);
5713
+ };
5714
+
5715
+ const AssignEkyc = () => {
5716
+ var _formState$tableForm, _formState$tableForm2, _formState$tableForm3, _formState$tableForm4, _formState$searchForm, _dashboardData$dashbo;
5717
+ let tenantId = Digit.ULBService.getCurrentTenantId();
5718
+ if (!tenantId || tenantId === "dl") {
5719
+ tenantId = "dl.djb";
5720
+ }
5721
+ const _useReducer = useReducer(formReducer, formInitValue),
5722
+ formState = _useReducer[0],
5723
+ dispatch = _useReducer[1];
5724
+ let paginationParms = {
5725
+ limit: (formState === null || formState === void 0 ? void 0 : (_formState$tableForm = formState.tableForm) === null || _formState$tableForm === void 0 ? void 0 : _formState$tableForm.limit) || 10,
5726
+ offset: (formState === null || formState === void 0 ? void 0 : (_formState$tableForm2 = formState.tableForm) === null || _formState$tableForm2 === void 0 ? void 0 : _formState$tableForm2.offset) || 0,
5727
+ sortBy: (formState === null || formState === void 0 ? void 0 : (_formState$tableForm3 = formState.tableForm) === null || _formState$tableForm3 === void 0 ? void 0 : _formState$tableForm3.sortBy) || "createdTime",
5728
+ sortOrder: (formState === null || formState === void 0 ? void 0 : (_formState$tableForm4 = formState.tableForm) === null || _formState$tableForm4 === void 0 ? void 0 : _formState$tableForm4.sortOrder) || "DESC"
5666
5729
  };
5667
- const handleFilterChange = (key, value) => {
5668
- setFilters(prev => _extends({}, prev, {
5669
- [key]: value
5670
- }));
5671
- };
5672
- const columns = useMemo(() => [{
5673
- Header: () => /*#__PURE__*/React.createElement("input", {
5674
- type: "checkbox",
5675
- checked: tableData.length > 0 && tableData.every(item => selectedKnos.includes(item.kno)),
5676
- onChange: handleSelectAll
5730
+ const mobileNumber = (formState === null || formState === void 0 ? void 0 : (_formState$searchForm = formState.searchForm) === null || _formState$searchForm === void 0 ? void 0 : _formState$searchForm.mobileNumber) || "";
5731
+ const isSearchActive = !!mobileNumber;
5732
+ const filters = _extends({}, paginationParms, {
5733
+ status: "ACTIVE,DISABLED"
5734
+ });
5735
+ if (isSearchActive) {
5736
+ filters.mobileNumber = mobileNumber;
5737
+ }
5738
+ const _Digit$Hooks$fsm$useS = Digit.Hooks.fsm.useSurveyorSearch(tenantId, filters, {
5739
+ enabled: !!tenantId,
5740
+ keepPreviousData: true
5677
5741
  }),
5678
- id: "selection",
5679
- Cell: _ref3 => {
5680
- let row = _ref3.row;
5681
- const kno = row.original.kno;
5682
- return /*#__PURE__*/React.createElement("input", {
5683
- type: "checkbox",
5684
- checked: selectedKnos.includes(kno),
5685
- onChange: () => handleSelect(kno)
5742
+ dashboardData = _Digit$Hooks$fsm$useS.data,
5743
+ isLoading = _Digit$Hooks$fsm$useS.isLoading;
5744
+ const _Digit$Hooks$ekyc$use = Digit.Hooks.ekyc.useEkycAssignmentProgress({
5745
+ enabled: !!tenantId,
5746
+ keepPreviousData: true
5747
+ }),
5748
+ isDataSearchLoading = _Digit$Hooks$ekyc$use.isLoading;
5749
+ const sourceData = useMemo(() => {
5750
+ return (dashboardData === null || dashboardData === void 0 ? void 0 : dashboardData.surveyors) || [];
5751
+ }, [dashboardData]);
5752
+ const filteredData = useMemo(() => {
5753
+ return (sourceData || []).map(item => {
5754
+ var _owner$roles, _owner$roles$map, _item$additionalDetai, _item$auditDetails, _item$auditDetails2;
5755
+ const owner = (item === null || item === void 0 ? void 0 : item.owner) || {};
5756
+ const roleCodes = (owner === null || owner === void 0 ? void 0 : (_owner$roles = owner.roles) === null || _owner$roles === void 0 ? void 0 : (_owner$roles$map = _owner$roles.map(role => role.code)) === null || _owner$roles$map === void 0 ? void 0 : _owner$roles$map.join(", ")) || "";
5757
+ return _extends({}, item, {
5758
+ id: (item === null || item === void 0 ? void 0 : item.id) || "",
5759
+ surveyorName: (item === null || item === void 0 ? void 0 : item.name) || (owner === null || owner === void 0 ? void 0 : owner.name) || "",
5760
+ mobileNo: (item === null || item === void 0 ? void 0 : item.mobileNo) || (owner === null || owner === void 0 ? void 0 : owner.mobileNumber) || "",
5761
+ email: (owner === null || owner === void 0 ? void 0 : owner.emailId) || "",
5762
+ vendorId: (item === null || item === void 0 ? void 0 : item.vendorId) || "",
5763
+ tenantId: (item === null || item === void 0 ? void 0 : item.tenantId) || "",
5764
+ supervisorId: (item === null || item === void 0 ? void 0 : item.supervisorId) || "",
5765
+ status: (item === null || item === void 0 ? void 0 : item.status) || "",
5766
+ roleCodes,
5767
+ userName: (owner === null || owner === void 0 ? void 0 : owner.userName) || "",
5768
+ gender: (owner === null || owner === void 0 ? void 0 : owner.gender) || "",
5769
+ serviceType: (item === null || item === void 0 ? void 0 : (_item$additionalDetai = item.additionalDetails) === null || _item$additionalDetai === void 0 ? void 0 : _item$additionalDetai.serviceType) || "",
5770
+ createdTime: (item === null || item === void 0 ? void 0 : (_item$auditDetails = item.auditDetails) === null || _item$auditDetails === void 0 ? void 0 : _item$auditDetails.createdTime) || 0,
5771
+ lastModifiedTime: (item === null || item === void 0 ? void 0 : (_item$auditDetails2 = item.auditDetails) === null || _item$auditDetails2 === void 0 ? void 0 : _item$auditDetails2.lastModifiedTime) || 0
5686
5772
  });
5773
+ });
5774
+ }, [sourceData]);
5775
+ const totalRecords = (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo = dashboardData.dashboardInfo) === null || _dashboardData$dashbo === void 0 ? void 0 : _dashboardData$dashbo.totalRecords) || (dashboardData === null || dashboardData === void 0 ? void 0 : dashboardData.totalCount) || 0;
5776
+ const SearchFormFields = useCallback(_ref => {
5777
+ let registerRef = _ref.registerRef,
5778
+ searchFormState = _ref.searchFormState,
5779
+ controlSearchForm = _ref.controlSearchForm;
5780
+ return /*#__PURE__*/React.createElement(SearchFormFieldsComponents, {
5781
+ registerRef,
5782
+ searchFormState,
5783
+ controlSearchForm,
5784
+ searchType: "mobile",
5785
+ className: "search"
5786
+ });
5787
+ }, []);
5788
+ const tableOrderFormDefaultValues = {
5789
+ sortBy: "createdTime",
5790
+ limit: window.Digit.Utils.browser.isMobile() ? 50 : 10,
5791
+ offset: 0,
5792
+ sortOrder: "DESC"
5793
+ };
5794
+ const onSearchFormSubmit = data => {
5795
+ data.hasOwnProperty("") && (data === null || data === void 0 ? true : delete data[""]);
5796
+ dispatch({
5797
+ action: "mutateTableForm",
5798
+ data: _extends({}, tableOrderFormDefaultValues)
5799
+ });
5800
+ dispatch({
5801
+ action: "mutateSearchForm",
5802
+ data
5803
+ });
5804
+ };
5805
+ const searchFormDefaultValues = {
5806
+ mobileNumber: "",
5807
+ applicationNumber: "",
5808
+ consumerNo: ""
5809
+ };
5810
+ const onSearchFormReset = setSearchFormValue => {
5811
+ setSearchFormValue("mobileNumber", null);
5812
+ setSearchFormValue("applicationNumber", null);
5813
+ setSearchFormValue("consumerNo", null);
5814
+ dispatch({
5815
+ action: "mutateSearchForm",
5816
+ data: searchFormDefaultValues
5817
+ });
5818
+ };
5819
+ const propsForSearchForm = {
5820
+ SearchFormFields,
5821
+ onSearchFormSubmit,
5822
+ searchFormDefaultValues: formState === null || formState === void 0 ? void 0 : formState.searchForm,
5823
+ resetSearchFormDefaultValues: searchFormDefaultValues,
5824
+ onSearchFormReset,
5825
+ className: "search-form-wns-inbox"
5826
+ };
5827
+ const onPageSizeChange = e => {
5828
+ const newLimit = Number(e.target.value);
5829
+ dispatch({
5830
+ action: "mutateTableForm",
5831
+ data: _extends({}, formState.tableForm, {
5832
+ limit: newLimit,
5833
+ offset: 0
5834
+ })
5835
+ });
5836
+ };
5837
+ const onSortingByData = e => {
5838
+ if (e.length > 0) {
5839
+ const _e$ = e[0],
5840
+ id = _e$.id,
5841
+ desc = _e$.desc;
5842
+ const sortOrder = desc ? "DESC" : "ASC";
5843
+ const sortBy = id;
5844
+ if (!(formState.tableForm.sortBy === sortBy && formState.tableForm.sortOrder === sortOrder)) {
5845
+ dispatch({
5846
+ action: "mutateTableForm",
5847
+ data: _extends({}, formState.tableForm, {
5848
+ sortBy: id,
5849
+ sortOrder: desc ? "DESC" : "ASC"
5850
+ })
5851
+ });
5852
+ }
5687
5853
  }
5688
- }, {
5689
- Header: "KNO",
5690
- accessor: "kno"
5691
- }, {
5692
- Header: "Consumer Name",
5693
- accessor: row => ((row.firstName || "") + " " + (row.middleName || "") + " " + (row.lastName || "")).trim(),
5694
- id: "consumerName"
5695
- }, {
5696
- Header: "Zone",
5697
- accessor: "zoneName"
5698
- }, {
5699
- Header: "Pincode",
5700
- accessor: "pincode"
5701
- }, {
5702
- Header: "Status",
5703
- accessor: "status",
5704
- Cell: _ref4 => {
5705
- let value = _ref4.value;
5706
- return /*#__PURE__*/React.createElement("span", {
5707
- className: "status-badge " + (value === "ACTIVE" ? "verified" : value === "PENDING" ? "pending" : "assigned")
5708
- }, value);
5709
- }
5710
- }, {
5711
- Header: "eKYC Status",
5712
- accessor: "ekycStatus",
5713
- Cell: _ref5 => {
5714
- let value = _ref5.value;
5715
- return value || "-";
5854
+ };
5855
+ const propsForInboxTable = SupervisorInboxTableConfig(_extends({}, {
5856
+ onPageSizeChange,
5857
+ formState,
5858
+ totalCount: totalRecords,
5859
+ table: filteredData,
5860
+ dispatch,
5861
+ onSortingByData,
5862
+ tenantId,
5863
+ inboxStyles: {
5864
+ overflowX: "scroll",
5865
+ overflowY: "hidden"
5866
+ },
5867
+ tableStyle: {
5868
+ width: "70%"
5716
5869
  }
5717
- }], [selectedKnos, tableData]);
5718
- const handleSelect = kno => {
5719
- setSelectedKnos(prev => prev.includes(kno) ? prev.filter(item => item !== kno) : [...prev, kno]);
5870
+ }));
5871
+ const isInboxLoading = isLoading;
5872
+ const onMobileSortOrderData = data => {
5873
+ const sortOrder = data.sortOrder;
5874
+ dispatch({
5875
+ action: "mutateTableForm",
5876
+ data: _extends({}, formState.tableForm, {
5877
+ sortOrder
5878
+ })
5879
+ });
5720
5880
  };
5721
- return /*#__PURE__*/React.createElement(Modal, {
5722
- headerBarMain: "Assign KNOs to " + (surveyor === null || surveyor === void 0 ? void 0 : surveyor.name),
5723
- headerBarEnd: /*#__PURE__*/React.createElement(Close, {
5724
- onClick: closeModal
5881
+ const onSortFormReset = setSortFormValue => {
5882
+ setSortFormValue("sortOrder", "DESC");
5883
+ dispatch({
5884
+ action: "mutateTableForm",
5885
+ data: tableOrderFormDefaultValues
5886
+ });
5887
+ };
5888
+ const propsForMobileSortForm = {
5889
+ onMobileSortOrderData,
5890
+ sortFormDefaultValues: formState === null || formState === void 0 ? void 0 : formState.tableForm,
5891
+ onSortFormReset
5892
+ };
5893
+ const propsForInboxMobileCards = useSupervisorInboxMobileCardsData({
5894
+ table: filteredData
5895
+ });
5896
+ return /*#__PURE__*/React.createElement("div", {
5897
+ className: "app-container"
5898
+ }, /*#__PURE__*/React.createElement(InboxComposer, _extends({
5899
+ isInboxLoading
5900
+ }, propsForSearchForm, propsForMobileSortForm, {
5901
+ propsForInboxTable,
5902
+ propsForInboxMobileCards,
5903
+ formState,
5904
+ countData: dashboardData === null || dashboardData === void 0 ? void 0 : dashboardData.dashboardInfo,
5905
+ isCardLoading: isDataSearchLoading
5906
+ })));
5907
+ };
5908
+
5909
+ const AdminDashboard = () => {
5910
+ var _Digit$SessionStorage, _loggedInUser$roles, _fullName$charAt;
5911
+ const _useTranslation = useTranslation(),
5912
+ t = _useTranslation.t;
5913
+ const history = useHistory();
5914
+ let tenantId = Digit.ULBService.getCurrentTenantId();
5915
+ if (!tenantId || tenantId === "dl") {
5916
+ tenantId = "dl.djb";
5917
+ }
5918
+ const loggedInUser = (_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : _Digit$SessionStorage.info;
5919
+ const _Digit$Hooks$fsm$useD = Digit.Hooks.fsm.useDsoSearch(tenantId, {
5920
+ status: "ACTIVE"
5921
+ }, {
5922
+ enabled: !!tenantId
5725
5923
  }),
5726
- actionCancelLabel: "Cancel",
5727
- actionCancelOnSubmit: closeModal,
5728
- actionSaveLabel: "Assign " + selectedKnos.length + " KNOs",
5729
- actionSaveOnSubmit: handleAssign,
5730
- isDisabled: !(selectedKnos !== null && selectedKnos !== void 0 && selectedKnos.length)
5731
- }, /*#__PURE__*/React.createElement("div", {
5732
- className: "assign-knos-modal"
5733
- }, /*#__PURE__*/React.createElement("div", {
5734
- className: "filters-grid"
5735
- }, /*#__PURE__*/React.createElement("input", {
5736
- className: "form-control",
5737
- placeholder: "KNO",
5738
- value: filters.kno,
5739
- onChange: e => handleFilterChange("kno", e.target.value)
5740
- }), /*#__PURE__*/React.createElement("select", {
5741
- className: "form-control",
5742
- value: filters.pincode,
5743
- onChange: e => handleFilterChange("pincode", e.target.value)
5744
- }, /*#__PURE__*/React.createElement("option", {
5745
- value: ""
5746
- }, "Select Pincode"), fetchedPincodes.map(pin => /*#__PURE__*/React.createElement("option", {
5747
- key: pin,
5748
- value: pin
5749
- }, pin))), /*#__PURE__*/React.createElement("select", {
5750
- className: "form-control",
5751
- value: filters.zoneName,
5752
- onChange: e => {
5753
- const val = e.target.value;
5754
- setFilters(prev => _extends({}, prev, {
5755
- zoneCode: val,
5756
- zoneName: val
5757
- }));
5758
- },
5759
- disabled: isZroLoading
5760
- }, /*#__PURE__*/React.createElement("option", {
5761
- value: ""
5762
- }, isZroLoading ? "Loading ZRO Locations..." : "Select ZRO Location"), mappedZROLocation.map(loc => /*#__PURE__*/React.createElement("option", {
5763
- key: loc.code,
5764
- value: loc.name
5765
- }, loc.name))), /*#__PURE__*/React.createElement("select", {
5766
- className: "form-control",
5767
- value: filters.ward,
5768
- onChange: e => handleFilterChange("ward", e.target.value)
5769
- }, /*#__PURE__*/React.createElement("option", {
5770
- value: ""
5771
- }, "Select Ward"), wardOptions.map(ward => /*#__PURE__*/React.createElement("option", {
5772
- key: ward.code,
5773
- value: ward.name
5774
- }, ward.name))), /*#__PURE__*/React.createElement("select", {
5775
- className: "form-control",
5776
- value: filters.assembly,
5777
- onChange: e => handleFilterChange("assembly", e.target.value)
5778
- }, /*#__PURE__*/React.createElement("option", {
5779
- value: ""
5780
- }, "Select Assembly"), assemblyOptions.map(assembly => /*#__PURE__*/React.createElement("option", {
5781
- key: assembly.code,
5782
- value: assembly.name
5783
- }, assembly.name))), /*#__PURE__*/React.createElement("input", {
5784
- className: "form-control",
5785
- placeholder: "MR Key",
5786
- value: filters.mrkey,
5787
- onChange: e => handleFilterChange("mrkey", e.target.value)
5788
- }), selectedKnos.length > 0 && /*#__PURE__*/React.createElement("button", {
5789
- className: "clear-selected-btn",
5790
- type: "button",
5791
- onClick: () => setSelectedKnos([])
5792
- }, t("EKYC_CLEAR_SELECTION") || "Clear Selected (" + selectedKnos.length + ")")), /*#__PURE__*/React.createElement(Table, {
5793
- tableTitle: "eKYC Applications",
5794
- tableClass: "ekycTable",
5795
- data: tableData,
5796
- columns: columns,
5797
- isLoading: isLoading,
5798
- totalRecords: (applicationData === null || applicationData === void 0 ? void 0 : applicationData.totalCount) || 0,
5799
- currentPage: currentPage,
5800
- pageSizeLimit: pageSize,
5801
- manualPagination: true,
5802
- isPaginationRequired: true,
5803
- onNextPage: () => {
5804
- if (currentPage < ((applicationData === null || applicationData === void 0 ? void 0 : applicationData.totalPages) || 1) - 1) {
5805
- setCurrentPage(prev => prev + 1);
5806
- }
5807
- },
5808
- onPrevPage: () => {
5809
- if (currentPage > 0) {
5810
- setCurrentPage(prev => prev - 1);
5811
- }
5812
- },
5813
- onFirstPage: () => {
5814
- setCurrentPage(0);
5815
- },
5816
- onLastPage: () => {
5817
- setCurrentPage(Math.max(((applicationData === null || applicationData === void 0 ? void 0 : applicationData.totalPages) || 1) - 1, 0));
5818
- },
5819
- onPageSizeChange: e => {
5820
- setPageSize(Number(e.target.value));
5821
- setCurrentPage(0);
5924
+ vendorSearchResponse = _Digit$Hooks$fsm$useD.data,
5925
+ isVendorSearchLoading = _Digit$Hooks$fsm$useD.isLoading;
5926
+ const _Digit$Hooks$ekyc$use = Digit.Hooks.ekyc.useEkycAssignmentProgress({
5927
+ enabled: !!tenantId,
5928
+ keepPreviousData: true
5929
+ }),
5930
+ progressData = _Digit$Hooks$ekyc$use.data,
5931
+ isProgressLoading = _Digit$Hooks$ekyc$use.isLoading;
5932
+ const vendorsList = useMemo(() => {
5933
+ if (vendorSearchResponse && vendorSearchResponse.length > 0) {
5934
+ return vendorSearchResponse.map(v => {
5935
+ var _progressData$supervi, _dso$owner, _v$owner, _dso$owner2;
5936
+ const dso = v.dsoDetails || v;
5937
+ const supervisorsList = dso.supervisors || [];
5938
+ const surveyorsList = dso.surveyors || [];
5939
+ const supervisorIds = supervisorsList.map(s => {
5940
+ var _s$owner;
5941
+ return s.id || ((_s$owner = s.owner) === null || _s$owner === void 0 ? void 0 : _s$owner.uuid);
5942
+ }).filter(Boolean);
5943
+ const matchedReports = (progressData === null || progressData === void 0 ? void 0 : (_progressData$supervi = progressData.supervisorReport) === null || _progressData$supervi === void 0 ? void 0 : _progressData$supervi.filter(r => supervisorIds.includes(r.supervisorId))) || [];
5944
+ const completed = matchedReports.reduce((acc, r) => acc + (r.submittedKnos || 0), 0);
5945
+ const pending = matchedReports.reduce((acc, r) => acc + (r.pendingKnos || 0), 0);
5946
+ const total = matchedReports.reduce((acc, r) => acc + (r.totalKnos || 0), 0);
5947
+ const progress = total > 0 ? Math.round(completed / total * 100) : 0;
5948
+ const rejected = 0;
5949
+ return {
5950
+ id: dso.id || dso.vendorId || v.id || v.vendorId,
5951
+ name: dso.name || dso.displayName || v.name || "N/A",
5952
+ ownerName: ((_dso$owner = dso.owner) === null || _dso$owner === void 0 ? void 0 : _dso$owner.name) || ((_v$owner = v.owner) === null || _v$owner === void 0 ? void 0 : _v$owner.name) || "N/A",
5953
+ mobileNumber: dso.mobileNumber || ((_dso$owner2 = dso.owner) === null || _dso$owner2 === void 0 ? void 0 : _dso$owner2.mobileNumber) || v.mobileNumber || "N/A",
5954
+ supervisors: supervisorsList.length,
5955
+ surveyors: surveyorsList.length,
5956
+ completed: completed,
5957
+ progress: progress,
5958
+ pending: pending,
5959
+ rejected: rejected
5960
+ };
5961
+ });
5822
5962
  }
5823
- })), showToast && /*#__PURE__*/React.createElement(Toast, {
5824
- error: toastData.error,
5825
- label: toastData.label,
5826
- onClose: () => setShowToast(false)
5827
- }));
5963
+ return [];
5964
+ }, [vendorSearchResponse, progressData]);
5965
+ const _useState = useState(false),
5966
+ ekycDownloadLoading = _useState[0],
5967
+ setEkycDownloadLoading = _useState[1];
5968
+ const _useState2 = useState(0),
5969
+ currentPage = _useState2[0];
5970
+ const _useState3 = useState(20),
5971
+ pageSize = _useState3[0];
5972
+ const _Digit$Hooks$ekyc$use2 = Digit.Hooks.ekyc.useEkycApplicationList({}, {
5973
+ tenantId,
5974
+ offset: currentPage * pageSize,
5975
+ limit: pageSize
5976
+ }, {
5977
+ keepPreviousData: true
5978
+ });
5979
+ const fullName = (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.name) || "Admin";
5980
+ const mobileNumber = (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.mobileNumber) || "N/A";
5981
+ const roleText = (loggedInUser === null || loggedInUser === void 0 ? void 0 : (_loggedInUser$roles = loggedInUser.roles) === null || _loggedInUser$roles === void 0 ? void 0 : _loggedInUser$roles.map(r => r.name).join(", ")) || "EKYC Admin";
5982
+ const handleDownloadEkycData = function () {
5983
+ try {
5984
+ setEkycDownloadLoading(true);
5985
+ return Promise.resolve(_finallyRethrows(function () {
5986
+ return _catch(function () {
5987
+ return Promise.resolve(Digit.EkycService.application_list({
5988
+ tenantId: tenantId,
5989
+ offset: 0,
5990
+ limit: 10000,
5991
+ reportDownload: true
5992
+ })).then(function (response) {
5993
+ const consumerList = (response === null || response === void 0 ? void 0 : response.consumerList) || [];
5994
+ if (consumerList.length === 0) {
5995
+ alert(t("NO_DATA_FOUND") || "No data found for download.");
5996
+ return;
5997
+ }
5998
+ const excludedKeys = ["status", "source", "submittedAt", "assignedAt", "connectionType", "approvedAt", "alternateMobileNo", "city", "state", "addressType", "addressProofType", "mrcode", "areacode", "verificationStatus", "surveyorId", "supervisorId", "vendorId", "assignmentType", "assignmentValue", "assignedTime", "isSelfAssigned", "userType", "tenantName", "tenantMobile"];
5999
+ const headerMapping = {
6000
+ kno: t("KNO") || "KNO",
6001
+ firstName: t("FIRST_NAME") || "First Name",
6002
+ middleName: t("MIDDLE_NAME") || "Middle Name",
6003
+ lastName: t("LAST_NAME") || "Last Name",
6004
+ gender: t("GENDER") || "Gender",
6005
+ mobileNumber: t("MOBILE_NUMBER") || "Mobile Number",
6006
+ emailId: t("EMAIL_ID") || "Email ID",
6007
+ fatherOrHusbandName: t("FATHER_HUSBUND_NAME") || "Father/Husband Name",
6008
+ relationship: t("RELATIONSHIP") || "Relationship",
6009
+ dob: t("DOB") || "Date of Birth",
6010
+ ekycStatus: t("EKYC_STATUS") || "eKYC Status",
6011
+ zoneName: t("ZONE") || "Zone",
6012
+ assembly: t("ASSEMBLY") || "Assembly",
6013
+ ward: t("WARD") || "Ward",
6014
+ pincode: t("PINCODE") || "Pincode",
6015
+ mrkey: t("MR_KEY") || "MR Key",
6016
+ createdTime: t("CREATED_TIME") || "Created Time",
6017
+ lastModifiedTime: t("LAST_MODIFIED_TIME") || "Last Modified Time"
6018
+ };
6019
+ const excelData = consumerList.map(item => {
6020
+ const cleanObj = {};
6021
+ const name = [item.firstName, item.middleName, item.lastName].filter(Boolean).join(" ");
6022
+ if (name) {
6023
+ cleanObj[t("CONSUMER_NAME") || "Consumer Name"] = name;
6024
+ }
6025
+ Object.keys(item).forEach(key => {
6026
+ if (excludedKeys.includes(key)) return;
6027
+ const val = item[key];
6028
+ if (typeof val === "object" && val !== null) {
6029
+ return;
6030
+ }
6031
+ const friendlyHeader = headerMapping[key] || t(key.toUpperCase()) || key;
6032
+ cleanObj[friendlyHeader] = val;
6033
+ });
6034
+ return cleanObj;
6035
+ });
6036
+ const cleanFileName = "eKYC_All_Data_Admin_" + fullName.replace(/[^a-zA-Z0-9]/g, "_");
6037
+ Digit.Download.Excel(excelData, cleanFileName);
6038
+ });
6039
+ }, function (error) {
6040
+ console.error("Error downloading eKYC Excel:", error);
6041
+ });
6042
+ }, function (_wasThrown, _result) {
6043
+ setEkycDownloadLoading(false);
6044
+ if (_wasThrown) throw _result;
6045
+ return _result;
6046
+ }));
6047
+ } catch (e) {
6048
+ return Promise.reject(e);
6049
+ }
6050
+ };
6051
+ return /*#__PURE__*/React.createElement(Card, {
6052
+ className: "surveyor-dashboard"
6053
+ }, /*#__PURE__*/React.createElement("div", {
6054
+ className: "ekyc-dashboard-section"
6055
+ }, /*#__PURE__*/React.createElement("div", {
6056
+ className: "ekyc-dashboard-header"
6057
+ }, /*#__PURE__*/React.createElement("div", {
6058
+ className: "avatar"
6059
+ }, fullName === null || fullName === void 0 ? void 0 : (_fullName$charAt = fullName.charAt(0)) === null || _fullName$charAt === void 0 ? void 0 : _fullName$charAt.toUpperCase()), /*#__PURE__*/React.createElement("div", {
6060
+ className: "header-content"
6061
+ }, /*#__PURE__*/React.createElement("h2", {
6062
+ className: "name"
6063
+ }, fullName), /*#__PURE__*/React.createElement("div", {
6064
+ className: "designation"
6065
+ }, t("EKYC_ADMIN") || "eKYC Admin / Manager"), /*#__PURE__*/React.createElement("div", {
6066
+ className: "mobile-number"
6067
+ }, mobileNumber))), /*#__PURE__*/React.createElement("button", {
6068
+ className: "download-excel-btn",
6069
+ disabled: ekycDownloadLoading,
6070
+ onClick: handleDownloadEkycData
6071
+ }, /*#__PURE__*/React.createElement("svg", {
6072
+ width: "16",
6073
+ height: "16",
6074
+ viewBox: "0 0 24 24",
6075
+ fill: "none",
6076
+ stroke: "currentColor",
6077
+ strokeWidth: "2.5",
6078
+ strokeLinecap: "round",
6079
+ strokeLinejoin: "round"
6080
+ }, /*#__PURE__*/React.createElement("path", {
6081
+ d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"
6082
+ }), /*#__PURE__*/React.createElement("polyline", {
6083
+ points: "7 10 12 15 17 10"
6084
+ }), /*#__PURE__*/React.createElement("line", {
6085
+ x1: "12",
6086
+ y1: "15",
6087
+ x2: "12",
6088
+ y2: "3"
6089
+ })), ekycDownloadLoading ? t("DOWNLOADING") || "Downloading..." : t("DOWNLOAD_EXCEL") || "Download Excel")), /*#__PURE__*/React.createElement("div", {
6090
+ className: "admin-performance-section"
6091
+ }, /*#__PURE__*/React.createElement("h3", {
6092
+ className: "section-title"
6093
+ }, t("EKYC_VENDORS_PERFORMANCE") || "eKYC Vendors Performance"), isVendorSearchLoading || isProgressLoading ? /*#__PURE__*/React.createElement(Loader, null) : /*#__PURE__*/React.createElement("div", {
6094
+ className: "vendors-grid"
6095
+ }, vendorsList.length === 0 ? /*#__PURE__*/React.createElement("div", {
6096
+ className: "no-vendors"
6097
+ }, t("NO_VENDORS_FOUND") || "No vendors found.") : vendorsList.map(vendor => /*#__PURE__*/React.createElement("div", {
6098
+ key: vendor.id,
6099
+ className: "vendor-perf-card",
6100
+ onClick: () => history.push("/digit-ui/employee/ekyc/vendors/" + vendor.id)
6101
+ }, /*#__PURE__*/React.createElement("div", {
6102
+ className: "card-header"
6103
+ }, /*#__PURE__*/React.createElement("div", {
6104
+ className: "vendor-info"
6105
+ }, /*#__PURE__*/React.createElement("h4", null, vendor.name), /*#__PURE__*/React.createElement("p", null, t("MOBILE") || "Mobile", ": ", vendor.mobileNumber)), /*#__PURE__*/React.createElement("span", {
6106
+ className: "progress-badge"
6107
+ }, vendor.progress, "%")), /*#__PURE__*/React.createElement("div", {
6108
+ className: "progress-bar-container"
6109
+ }, /*#__PURE__*/React.createElement("div", {
6110
+ className: "progress-bar-fill",
6111
+ style: {
6112
+ width: vendor.progress + "%"
6113
+ }
6114
+ })), /*#__PURE__*/React.createElement("div", {
6115
+ className: "stats-grid"
6116
+ }, /*#__PURE__*/React.createElement("div", {
6117
+ className: "stat-item"
6118
+ }, /*#__PURE__*/React.createElement("div", {
6119
+ className: "value"
6120
+ }, vendor.supervisors), /*#__PURE__*/React.createElement("div", {
6121
+ className: "label"
6122
+ }, t("SUPERVISORS") || "Supervisors")), /*#__PURE__*/React.createElement("div", {
6123
+ className: "stat-item"
6124
+ }, /*#__PURE__*/React.createElement("div", {
6125
+ className: "value"
6126
+ }, vendor.surveyors), /*#__PURE__*/React.createElement("div", {
6127
+ className: "label"
6128
+ }, t("SURVEYORS") || "Surveyors")), /*#__PURE__*/React.createElement("div", {
6129
+ className: "stat-item"
6130
+ }, /*#__PURE__*/React.createElement("div", {
6131
+ className: "value completed-val"
6132
+ }, vendor.completed), /*#__PURE__*/React.createElement("div", {
6133
+ className: "label"
6134
+ }, t("COMPLETED") || "Completed"))), /*#__PURE__*/React.createElement("div", {
6135
+ className: "card-footer"
6136
+ }, /*#__PURE__*/React.createElement("span", null, t("PENDING") || "Pending", ": ", /*#__PURE__*/React.createElement("span", {
6137
+ className: "pending-count"
6138
+ }, vendor.pending)), /*#__PURE__*/React.createElement("span", null, t("REJECTED") || "Rejected", ": ", /*#__PURE__*/React.createElement("span", {
6139
+ className: "rejected-count"
6140
+ }, vendor.rejected))))))));
5828
6141
  };
5829
6142
 
5830
- const SurveyorDetailsDashboard = () => {
5831
- var _Digit$SessionStorage, _Digit$SessionStorage2, _Digit$SessionStorage3, _Digit$SessionStorage4, _surveyor$owner, _surveyor$owner2, _surveyor$owner3, _surveyor$owner4, _fullName$charAt, _dashboardData$dashbo, _dashboardData$dashbo2, _dashboardData$dashbo3, _dashboardData$dashbo4, _surveyor$owner8, _surveyor$owner9, _surveyor$owner0, _surveyor$additionalD, _dashboardData$dashbo5, _dashboardData$dashbo6;
5832
- const tenantId = Digit.ULBService.getCurrentTenantId();
5833
- const _useState = useState(false),
5834
- showModal = _useState[0],
5835
- setShowModal = _useState[1];
5836
- const _useState2 = useState(false),
5837
- showOptions = _useState2[0],
5838
- setShowOptions = _useState2[1];
5839
- const _useState3 = useState(false),
5840
- ekycDownloadLoading = _useState3[0],
5841
- setEkycDownloadLoading = _useState3[1];
5842
- const _useParams = useParams(),
5843
- surveyorId = _useParams.id;
5844
- const ownerIds = (_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : (_Digit$SessionStorage2 = _Digit$SessionStorage.info) === null || _Digit$SessionStorage2 === void 0 ? void 0 : _Digit$SessionStorage2.uuid;
6143
+ const SupervisorDetailsCard = () => {
6144
+ var _Digit$SessionStorage, _fullName$charAt;
5845
6145
  const _useTranslation = useTranslation(),
5846
- t = _useTranslation.t;
5847
- const searchParams = surveyorId ? {
5848
- ids: surveyorId
5849
- } : {
5850
- ownerIds
5851
- };
5852
- const _Digit$Hooks$fsm$useS = Digit.Hooks.fsm.useSurveyorSearch(tenantId, searchParams, {
5853
- staleTime: Infinity
6146
+ t = _useTranslation.t;
6147
+ const history = useHistory();
6148
+ const tenantId = Digit.ULBService.getCurrentTenantId() || "dl.djb";
6149
+ const _useParams = useParams(),
6150
+ supervisorId = _useParams.id;
6151
+ const loggedInUser = (_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : _Digit$SessionStorage.info;
6152
+ const _useState = useState(false),
6153
+ ekycDownloadLoading = _useState[0],
6154
+ setEkycDownloadLoading = _useState[1];
6155
+ const _Digit$Hooks$ekyc$use = Digit.Hooks.ekyc.useEkycAssignmentProgress({
6156
+ enabled: !!tenantId,
6157
+ keepPreviousData: true
5854
6158
  }),
5855
- surveyorSearchResponse = _Digit$Hooks$fsm$useS.data,
5856
- isLoading = _Digit$Hooks$fsm$useS.isLoading;
5857
- const roles = (_Digit$SessionStorage3 = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage3 === void 0 ? void 0 : (_Digit$SessionStorage4 = _Digit$SessionStorage3.info) === null || _Digit$SessionStorage4 === void 0 ? void 0 : _Digit$SessionStorage4.roles.map(ele => ele.code);
5858
- const surveyor = useMemo(() => {
5859
- var _surveyorSearchRespon;
5860
- return (surveyorSearchResponse === null || surveyorSearchResponse === void 0 ? void 0 : (_surveyorSearchRespon = surveyorSearchResponse.surveyors) === null || _surveyorSearchRespon === void 0 ? void 0 : _surveyorSearchRespon[0]) || null;
5861
- }, [surveyorSearchResponse]);
5862
- const _Digit$Hooks$fsm$useD = Digit.Hooks.fsm.useDsoSearch(tenantId, {
6159
+ isProgressLoading = _Digit$Hooks$ekyc$use.isLoading,
6160
+ progressData = _Digit$Hooks$ekyc$use.data;
6161
+ const _Digit$Hooks$fsm$useS = Digit.Hooks.fsm.useSupervisorSearch(tenantId, {
6162
+ status: "ACTIVE"
6163
+ }, {
6164
+ enabled: !!tenantId
6165
+ }),
6166
+ supervisorSearchResponse = _Digit$Hooks$fsm$useS.data,
6167
+ isSupervisorSearchLoading = _Digit$Hooks$fsm$useS.isLoading;
6168
+ const _Digit$Hooks$fsm$useS2 = Digit.Hooks.fsm.useSurveyorSearch(tenantId, {
5863
6169
  status: "ACTIVE"
5864
6170
  }, {
5865
6171
  enabled: !!tenantId
5866
6172
  }),
5867
- vendorData = _Digit$Hooks$fsm$useD.data;
5868
- const _Digit$Hooks$fsm$useS2 = Digit.Hooks.fsm.useSupervisorSearch(tenantId, {
6173
+ surveyorSearchResponse = _Digit$Hooks$fsm$useS2.data,
6174
+ isSurveyorSearchLoading = _Digit$Hooks$fsm$useS2.isLoading;
6175
+ const _Digit$Hooks$fsm$useD = Digit.Hooks.fsm.useDsoSearch(tenantId, {
5869
6176
  status: "ACTIVE"
5870
6177
  }, {
5871
6178
  enabled: !!tenantId
5872
6179
  }),
5873
- supervisorSearchResponse = _Digit$Hooks$fsm$useS2.data;
6180
+ vendorSearchResponse = _Digit$Hooks$fsm$useD.data,
6181
+ isVendorSearchLoading = _Digit$Hooks$fsm$useD.isLoading;
6182
+ const supervisor = useMemo(() => {
6183
+ if (progressData !== null && progressData !== void 0 && progressData.supervisorReport) {
6184
+ let found = null;
6185
+ const targetId = supervisorId || (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uuid);
6186
+ if (targetId) {
6187
+ found = progressData.supervisorReport.find(s => {
6188
+ var _s$supervisorId, _s$id;
6189
+ return ((_s$supervisorId = s.supervisorId) === null || _s$supervisorId === void 0 ? void 0 : _s$supervisorId.toLowerCase()) === (targetId === null || targetId === void 0 ? void 0 : targetId.toLowerCase()) || ((_s$id = s.id) === null || _s$id === void 0 ? void 0 : _s$id.toLowerCase()) === (targetId === null || targetId === void 0 ? void 0 : targetId.toLowerCase());
6190
+ });
6191
+ }
6192
+ if (found) return found;
6193
+ }
6194
+ if (supervisorSearchResponse !== null && supervisorSearchResponse !== void 0 && supervisorSearchResponse.supervisors) {
6195
+ let matchedSup = null;
6196
+ const targetId = supervisorId || (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uuid);
6197
+ if (targetId) {
6198
+ matchedSup = supervisorSearchResponse.supervisors.find(s => {
6199
+ var _s$id2, _s$owner, _s$owner$uuid;
6200
+ return ((_s$id2 = s.id) === null || _s$id2 === void 0 ? void 0 : _s$id2.toLowerCase()) === (targetId === null || targetId === void 0 ? void 0 : targetId.toLowerCase()) || ((_s$owner = s.owner) === null || _s$owner === void 0 ? void 0 : (_s$owner$uuid = _s$owner.uuid) === null || _s$owner$uuid === void 0 ? void 0 : _s$owner$uuid.toLowerCase()) === (targetId === null || targetId === void 0 ? void 0 : targetId.toLowerCase());
6201
+ });
6202
+ }
6203
+ if (matchedSup) {
6204
+ var _matchedSup$owner2, _matchedSup$owner3, _matchedSup$owner4;
6205
+ const matchedSurveyors = surveyorSearchResponse !== null && surveyorSearchResponse !== void 0 && surveyorSearchResponse.surveyors ? surveyorSearchResponse.surveyors.filter(surv => {
6206
+ var _matchedSup$owner;
6207
+ return surv.supervisorId === (matchedSup.id || ((_matchedSup$owner = matchedSup.owner) === null || _matchedSup$owner === void 0 ? void 0 : _matchedSup$owner.uuid));
6208
+ }).map(surv => {
6209
+ var _surv$owner3, _surv$owner4, _surv$owner5, _realStats, _realStats2, _realStats3, _realStats4;
6210
+ let realStats = null;
6211
+ if (progressData !== null && progressData !== void 0 && progressData.supervisorReport) {
6212
+ for (const report of progressData.supervisorReport) {
6213
+ var _report$surveyors;
6214
+ const matchedSurv = (_report$surveyors = report.surveyors) === null || _report$surveyors === void 0 ? void 0 : _report$surveyors.find(s => {
6215
+ var _surv$owner, _surv$owner2;
6216
+ return s.surveyorId && (s.surveyorId === surv.id || s.surveyorId === ((_surv$owner = surv.owner) === null || _surv$owner === void 0 ? void 0 : _surv$owner.uuid)) || s.id && (s.id === surv.id || s.id === ((_surv$owner2 = surv.owner) === null || _surv$owner2 === void 0 ? void 0 : _surv$owner2.uuid));
6217
+ });
6218
+ if (matchedSurv) {
6219
+ realStats = matchedSurv;
6220
+ break;
6221
+ }
6222
+ }
6223
+ }
6224
+ return {
6225
+ surveyorId: surv.id || ((_surv$owner3 = surv.owner) === null || _surv$owner3 === void 0 ? void 0 : _surv$owner3.uuid),
6226
+ surveyorName: surv.name || ((_surv$owner4 = surv.owner) === null || _surv$owner4 === void 0 ? void 0 : _surv$owner4.name) || "N/A",
6227
+ mobileNo: ((_surv$owner5 = surv.owner) === null || _surv$owner5 === void 0 ? void 0 : _surv$owner5.mobileNumber) || surv.mobileNo || "N/A",
6228
+ status: surv.status || "ACTIVE",
6229
+ totalKnos: ((_realStats = realStats) === null || _realStats === void 0 ? void 0 : _realStats.totalKnos) || 0,
6230
+ submittedKnos: ((_realStats2 = realStats) === null || _realStats2 === void 0 ? void 0 : _realStats2.submittedKnos) || 0,
6231
+ pendingKnos: ((_realStats3 = realStats) === null || _realStats3 === void 0 ? void 0 : _realStats3.pendingKnos) || 0,
6232
+ progressPercent: ((_realStats4 = realStats) === null || _realStats4 === void 0 ? void 0 : _realStats4.progressPercent) || 0
6233
+ };
6234
+ }) : [];
6235
+ const totalKnos = matchedSurveyors.reduce((acc, s) => acc + (s.totalKnos || 0), 0);
6236
+ const submittedKnos = matchedSurveyors.reduce((acc, s) => acc + (s.submittedKnos || 0), 0);
6237
+ const pendingKnos = matchedSurveyors.reduce((acc, s) => acc + (s.pendingKnos || 0), 0);
6238
+ const progressPercent = totalKnos > 0 ? Math.round(submittedKnos / totalKnos * 100) : 0;
6239
+ return {
6240
+ supervisorId: matchedSup.id || ((_matchedSup$owner2 = matchedSup.owner) === null || _matchedSup$owner2 === void 0 ? void 0 : _matchedSup$owner2.uuid),
6241
+ supervisorName: matchedSup.name || ((_matchedSup$owner3 = matchedSup.owner) === null || _matchedSup$owner3 === void 0 ? void 0 : _matchedSup$owner3.name) || "N/A",
6242
+ mobileNo: ((_matchedSup$owner4 = matchedSup.owner) === null || _matchedSup$owner4 === void 0 ? void 0 : _matchedSup$owner4.mobileNumber) || matchedSup.mobileNo || "N/A",
6243
+ status: matchedSup.status || "ACTIVE",
6244
+ assignedZoneId: matchedSup.assignedZoneId || "N/A",
6245
+ vendorId: matchedSup.vendorId,
6246
+ surveyors: matchedSurveyors,
6247
+ totalKnos,
6248
+ submittedKnos,
6249
+ pendingKnos,
6250
+ progressPercent
6251
+ };
6252
+ }
6253
+ }
6254
+ return null;
6255
+ }, [progressData, supervisorSearchResponse, surveyorSearchResponse, supervisorId, loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uuid]);
6256
+ const fullName = (supervisor === null || supervisor === void 0 ? void 0 : supervisor.supervisorName) || "N/A";
6257
+ const mobileNumber = (supervisor === null || supervisor === void 0 ? void 0 : supervisor.mobileNo) || "N/A";
6258
+ const email = (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.emailId) || "N/A";
6259
+ const gender = (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.gender) || "N/A";
6260
+ const status = (supervisor === null || supervisor === void 0 ? void 0 : supervisor.status) || "N/A";
6261
+ const assignedZone = (supervisor === null || supervisor === void 0 ? void 0 : supervisor.assignedZoneId) || "N/A";
5874
6262
  const vendorName = useMemo(() => {
5875
- var _mappedVendor$dsoDeta;
5876
- if (surveyor !== null && surveyor !== void 0 && surveyor.vendorName) return surveyor.vendorName;
5877
- if (!vendorData || !(surveyor !== null && surveyor !== void 0 && surveyor.vendorId)) return "N/A";
5878
- const mappedVendor = vendorData.find(v => {
6263
+ var _matchedVendor$dsoDet;
6264
+ if (!vendorSearchResponse || !supervisor) return "N/A";
6265
+ const targetVendorId = supervisor.vendorId;
6266
+ if (!targetVendorId) return "N/A";
6267
+ const matchedVendor = vendorSearchResponse.find(v => {
5879
6268
  var _v$dsoDetails, _v$dsoDetails2;
5880
- return ((_v$dsoDetails = v.dsoDetails) === null || _v$dsoDetails === void 0 ? void 0 : _v$dsoDetails.id) === surveyor.vendorId || ((_v$dsoDetails2 = v.dsoDetails) === null || _v$dsoDetails2 === void 0 ? void 0 : _v$dsoDetails2.vendorId) === surveyor.vendorId;
5881
- });
5882
- return (mappedVendor === null || mappedVendor === void 0 ? void 0 : (_mappedVendor$dsoDeta = mappedVendor.dsoDetails) === null || _mappedVendor$dsoDeta === void 0 ? void 0 : _mappedVendor$dsoDeta.name) || surveyor.vendorId || "N/A";
5883
- }, [vendorData, surveyor === null || surveyor === void 0 ? void 0 : surveyor.vendorId, surveyor === null || surveyor === void 0 ? void 0 : surveyor.vendorName]);
5884
- const supervisorName = useMemo(() => {
5885
- var _mappedSupervisor$own;
5886
- if (surveyor !== null && surveyor !== void 0 && surveyor.supervisorName) return surveyor.supervisorName;
5887
- if (!(supervisorSearchResponse !== null && supervisorSearchResponse !== void 0 && supervisorSearchResponse.supervisors) || !(surveyor !== null && surveyor !== void 0 && surveyor.supervisorId)) return "N/A";
5888
- const mappedSupervisor = supervisorSearchResponse.supervisors.find(s => {
5889
- var _s$owner;
5890
- return s.id === surveyor.supervisorId || ((_s$owner = s.owner) === null || _s$owner === void 0 ? void 0 : _s$owner.uuid) === surveyor.supervisorId;
6269
+ return ((_v$dsoDetails = v.dsoDetails) === null || _v$dsoDetails === void 0 ? void 0 : _v$dsoDetails.id) === targetVendorId || ((_v$dsoDetails2 = v.dsoDetails) === null || _v$dsoDetails2 === void 0 ? void 0 : _v$dsoDetails2.vendorId) === targetVendorId || v.id === targetVendorId || v.vendorId === targetVendorId;
5891
6270
  });
5892
- return (mappedSupervisor === null || mappedSupervisor === void 0 ? void 0 : mappedSupervisor.name) || (mappedSupervisor === null || mappedSupervisor === void 0 ? void 0 : (_mappedSupervisor$own = mappedSupervisor.owner) === null || _mappedSupervisor$own === void 0 ? void 0 : _mappedSupervisor$own.name) || surveyor.supervisorId || "N/A";
5893
- }, [supervisorSearchResponse, surveyor === null || surveyor === void 0 ? void 0 : surveyor.supervisorId, surveyor === null || surveyor === void 0 ? void 0 : surveyor.supervisorName]);
5894
- const fullName = (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner = surveyor.owner) === null || _surveyor$owner === void 0 ? void 0 : _surveyor$owner.name) || (surveyor === null || surveyor === void 0 ? void 0 : surveyor.name) || "N/A";
5895
- const employeeId = (surveyor === null || surveyor === void 0 ? void 0 : surveyor.employeeId) || (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner2 = surveyor.owner) === null || _surveyor$owner2 === void 0 ? void 0 : _surveyor$owner2.uuid) || (surveyor === null || surveyor === void 0 ? void 0 : surveyor.id);
5896
- const mobileNumber = (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner3 = surveyor.owner) === null || _surveyor$owner3 === void 0 ? void 0 : _surveyor$owner3.mobileNumber) || (surveyor === null || surveyor === void 0 ? void 0 : surveyor.mobileNo) || "N/A";
5897
- const _useState4 = useState(0),
5898
- currentPage = _useState4[0],
5899
- setCurrentPage = _useState4[1];
5900
- const _useState5 = useState(20),
5901
- pageSize = _useState5[0],
5902
- setPageSize = _useState5[1];
5903
- const queryParams = {
5904
- tenantId: "dl.djb",
5905
- offset: currentPage * pageSize,
5906
- limit: pageSize,
5907
- surveyorId: surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner4 = surveyor.owner) === null || _surveyor$owner4 === void 0 ? void 0 : _surveyor$owner4.uuid
5908
- };
5909
- const _Digit$Hooks$ekyc$use = Digit.Hooks.ekyc.useEkycSurveyorDashboard({}, queryParams, {
5910
- enabled: !!queryParams.tenantId && !!queryParams.surveyorId,
5911
- keepPreviousData: true
5912
- }),
5913
- isDashboardLoading = _Digit$Hooks$ekyc$use.isFetching,
5914
- _Digit$Hooks$ekyc$use2 = _Digit$Hooks$ekyc$use.data,
5915
- dashboardData = _Digit$Hooks$ekyc$use2 === void 0 ? {} : _Digit$Hooks$ekyc$use2,
5916
- refetchDashboard = _Digit$Hooks$ekyc$use.refetch;
5917
- const knoColumns = useMemo(() => [{
5918
- Header: "KNO",
5919
- accessor: "kno"
6271
+ return (matchedVendor === null || matchedVendor === void 0 ? void 0 : (_matchedVendor$dsoDet = matchedVendor.dsoDetails) === null || _matchedVendor$dsoDet === void 0 ? void 0 : _matchedVendor$dsoDet.name) || (matchedVendor === null || matchedVendor === void 0 ? void 0 : matchedVendor.name) || "N/A";
6272
+ }, [vendorSearchResponse, supervisor]);
6273
+ const surveyors = useMemo(() => {
6274
+ return (supervisor === null || supervisor === void 0 ? void 0 : supervisor.surveyors) || [];
6275
+ }, [supervisor]);
6276
+ const cards = useMemo(() => [{
6277
+ label: "TOTAL_EKYC_APPLICATIONS",
6278
+ count: (supervisor === null || supervisor === void 0 ? void 0 : supervisor.totalKnos) || 0,
6279
+ color: "#0B2559",
6280
+ type: "today",
6281
+ icon: /*#__PURE__*/React.createElement(FaUsers, null)
5920
6282
  }, {
5921
- Header: "Consumer Name",
5922
- accessor: row => ((row.firstName || "") + " " + (row.middleName || "") + " " + (row.lastName || "")).trim(),
5923
- id: "consumerName"
6283
+ label: "EKYC_COMPLETED",
6284
+ count: (supervisor === null || supervisor === void 0 ? void 0 : supervisor.submittedKnos) || 0,
6285
+ color: "#10B981",
6286
+ type: "month",
6287
+ icon: /*#__PURE__*/React.createElement(FaCheckCircle, null)
5924
6288
  }, {
5925
- Header: "Zone",
5926
- accessor: "zoneName"
6289
+ label: "PENDING_APPLICATIONS",
6290
+ count: (supervisor === null || supervisor === void 0 ? void 0 : supervisor.pendingKnos) || 0,
6291
+ color: "#F59E0B",
6292
+ type: "pending",
6293
+ icon: /*#__PURE__*/React.createElement(FaClock, null)
5927
6294
  }, {
5928
- Header: "Status",
5929
- accessor: "status",
6295
+ label: "OVERALL_PROGRESS",
6296
+ count: ((supervisor === null || supervisor === void 0 ? void 0 : supervisor.progressPercent) || 0) + "%",
6297
+ color: "#A855F7",
6298
+ type: "progress",
6299
+ icon: /*#__PURE__*/React.createElement(FaChartLine, null)
6300
+ }], [supervisor]);
6301
+ const _useState2 = useState(0),
6302
+ currentPage = _useState2[0],
6303
+ setCurrentPage = _useState2[1];
6304
+ const _useState3 = useState(20),
6305
+ pageSize = _useState3[0],
6306
+ setPageSize = _useState3[1];
6307
+ const paginatedSurveyors = useMemo(() => {
6308
+ const start = currentPage * pageSize;
6309
+ const end = start + pageSize;
6310
+ return surveyors.slice(start, end);
6311
+ }, [surveyors, currentPage, pageSize]);
6312
+ const surveyorColumns = useMemo(() => [{
6313
+ Header: t("SURVEYOR_NAME") || "Surveyor Name",
6314
+ accessor: row => (row === null || row === void 0 ? void 0 : row.surveyorName) || "N/A",
5930
6315
  Cell: _ref => {
5931
- let value = _ref.value;
5932
- return /*#__PURE__*/React.createElement("span", {
5933
- className: "status-badge " + (value === "ACTIVE" ? "verified" : value === "PENDING" ? "pending" : "assigned")
5934
- }, value);
6316
+ var _Digit$SessionStorage2, _Digit$SessionStorage3, _Digit$SessionStorage4, _row$original;
6317
+ let row = _ref.row;
6318
+ const userType = ((_Digit$SessionStorage2 = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage2 === void 0 ? void 0 : (_Digit$SessionStorage3 = _Digit$SessionStorage2.info) === null || _Digit$SessionStorage3 === void 0 ? void 0 : (_Digit$SessionStorage4 = _Digit$SessionStorage3.type) === null || _Digit$SessionStorage4 === void 0 ? void 0 : _Digit$SessionStorage4.toLowerCase()) || "citizen";
6319
+ const targetPath = "/digit-ui/" + userType + "/ekyc/surveyor-dashboard/" + row.original.surveyorId;
6320
+ return /*#__PURE__*/React.createElement("a", {
6321
+ href: targetPath,
6322
+ style: {
6323
+ color: "#1D70B8",
6324
+ fontWeight: "600",
6325
+ textDecoration: "none"
6326
+ },
6327
+ onClick: e => {
6328
+ e.preventDefault();
6329
+ history.push(targetPath);
6330
+ }
6331
+ }, ((_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original.surveyorName) || "N/A");
5935
6332
  }
5936
6333
  }, {
5937
- Header: "eKYC Status",
5938
- accessor: "ekycStatus",
5939
- Cell: _ref2 => {
5940
- let value = _ref2.value;
5941
- return value || "-";
5942
- }
5943
- }], []);
5944
- const _useState6 = useState(false),
5945
- showReportMenu = _useState6[0],
5946
- setShowReportMenu = _useState6[1];
5947
- const _useState7 = useState({
5948
- from: "",
5949
- to: ""
5950
- }),
5951
- customDate = _useState7[0],
5952
- setCustomDate = _useState7[1];
5953
- const _useState8 = useState(false),
5954
- showCustomPicker = _useState8[0],
5955
- setShowCustomPicker = _useState8[1];
5956
- const _useState9 = useState(false),
5957
- reportLoading = _useState9[0],
5958
- setReportLoading = _useState9[1];
5959
- const reportMenuRef = useRef(null);
5960
- useEffect(() => {
5961
- const handler = e => {
5962
- if (reportMenuRef.current && !reportMenuRef.current.contains(e.target)) {
5963
- setShowReportMenu(false);
5964
- setShowCustomPicker(false);
5965
- }
5966
- };
5967
- document.addEventListener("mousedown", handler);
5968
- return () => document.removeEventListener("mousedown", handler);
5969
- }, []);
5970
- if (isLoading) {
5971
- return /*#__PURE__*/React.createElement(Loader, null);
5972
- }
5973
- if (!surveyor) {
5974
- return /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement("div", {
5975
- style: {
5976
- padding: "24px"
5977
- }
5978
- }, t("NO_SURVEYOR_FOUND")));
5979
- }
5980
- const getDateRange = filter => {
5981
- const now = new Date();
5982
- const start = new Date(now);
5983
- if (filter === "today") {
5984
- start.setHours(0, 0, 0, 0);
5985
- return {
5986
- from: start,
5987
- to: now
5988
- };
5989
- }
5990
- if (filter === "week") {
5991
- start.setDate(now.getDate() - now.getDay());
5992
- start.setHours(0, 0, 0, 0);
5993
- return {
5994
- from: start,
5995
- to: now
5996
- };
5997
- }
5998
- if (filter === "month") {
5999
- start.setDate(1);
6000
- start.setHours(0, 0, 0, 0);
6001
- return {
6002
- from: start,
6003
- to: now
6004
- };
6005
- }
6006
- return null;
6007
- };
6008
- const handlePresetDownload = function (filter) {
6009
- try {
6010
- const range = getDateRange(filter);
6011
- if (!range) return Promise.resolve();
6012
- setReportLoading(true);
6013
- const _temp = _finallyRethrows(function () {
6014
- return _catch(function () {
6015
- var _surveyor$owner5;
6016
- return Promise.resolve(Digit.EkycService.dashboard({}, {
6017
- tenantId: "dl.djb",
6018
- offset: 0,
6019
- limit: 1000,
6020
- surveyorId: surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner5 = surveyor.owner) === null || _surveyor$owner5 === void 0 ? void 0 : _surveyor$owner5.uuid,
6021
- fromDate: range.from.getTime(),
6022
- toDate: range.to.getTime()
6023
- })).then(function (response) {
6024
- var _response$dashboardIn;
6025
- const rows = (response === null || response === void 0 ? void 0 : (_response$dashboardIn = response.dashboardInfo) === null || _response$dashboardIn === void 0 ? void 0 : _response$dashboardIn.consumerList) || [];
6026
- downloadSurveyorPDF({
6027
- rows: rows,
6028
- surveyorName: fullName,
6029
- vendorName,
6030
- supervisorName,
6031
- employeeId,
6032
- mobileNumber,
6033
- dashboardInfo: (response === null || response === void 0 ? void 0 : response.dashboardInfo) || {},
6034
- t
6035
- });
6036
- });
6037
- }, function (err) {
6038
- console.error("Failed to fetch dashboard data for report download:", err);
6039
- });
6040
- }, function (_wasThrown, _result) {
6041
- setReportLoading(false);
6042
- setShowReportMenu(false);
6043
- setShowCustomPicker(false);
6044
- if (_wasThrown) throw _result;
6045
- return _result;
6046
- });
6047
- return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
6048
- } catch (e) {
6049
- return Promise.reject(e);
6334
+ Header: t("MOBILE_NUMBER") || "Mobile Number",
6335
+ accessor: row => (row === null || row === void 0 ? void 0 : row.mobileNo) || "N/A",
6336
+ id: "mobileNumber"
6337
+ }, {
6338
+ Header: t("STATUS") || "Status",
6339
+ accessor: () => "ACTIVE",
6340
+ id: "status",
6341
+ Cell: _ref2 => {
6342
+ let value = _ref2.value;
6343
+ return /*#__PURE__*/React.createElement("span", {
6344
+ className: "status-badge verified"
6345
+ }, t(value) || value);
6050
6346
  }
6051
- };
6052
- const handleCustomDownload = function () {
6053
- try {
6054
- if (!customDate.from || !customDate.to) {
6055
- alert(t("SELECT_DATE_RANGE") || "Please select both From and To dates.");
6056
- return Promise.resolve();
6057
- }
6058
- const from = new Date(customDate.from);
6059
- from.setHours(0, 0, 0, 0);
6060
- const to = new Date(customDate.to);
6061
- to.setHours(23, 59, 59, 999);
6062
- setReportLoading(true);
6063
- const _temp2 = _finallyRethrows(function () {
6064
- return _catch(function () {
6065
- var _surveyor$owner6;
6066
- return Promise.resolve(Digit.EkycService.dashboard({}, {
6067
- tenantId: "dl.djb",
6068
- offset: 0,
6069
- limit: 1000,
6070
- surveyorId: surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner6 = surveyor.owner) === null || _surveyor$owner6 === void 0 ? void 0 : _surveyor$owner6.uuid,
6071
- fromDate: from.getTime(),
6072
- toDate: to.getTime()
6073
- })).then(function (response) {
6074
- var _response$dashboardIn2;
6075
- const rows = (response === null || response === void 0 ? void 0 : (_response$dashboardIn2 = response.dashboardInfo) === null || _response$dashboardIn2 === void 0 ? void 0 : _response$dashboardIn2.consumerList) || [];
6076
- downloadSurveyorPDF({
6077
- rows: rows,
6078
- surveyorName: fullName,
6079
- vendorName,
6080
- supervisorName,
6081
- employeeId,
6082
- mobileNumber,
6083
- dashboardInfo: (response === null || response === void 0 ? void 0 : response.dashboardInfo) || {},
6084
- t
6085
- });
6086
- });
6087
- }, function (err) {
6088
- console.error("Failed to fetch custom dashboard data for report download:", err);
6089
- });
6090
- }, function (_wasThrown2, _result2) {
6091
- setReportLoading(false);
6347
+ }, {
6348
+ Header: t("TOTAL_EKYC_APPLICATIONS") || "Total eKYC Applications",
6349
+ accessor: row => (row === null || row === void 0 ? void 0 : row.totalKnos) || 0,
6350
+ id: "totalEkycApplications"
6351
+ }, {
6352
+ Header: t("EKYC_COMPLETED") || "eKYC Completed",
6353
+ accessor: row => (row === null || row === void 0 ? void 0 : row.submittedKnos) || 0,
6354
+ id: "ekycCompleted"
6355
+ }, {
6356
+ Header: t("PENDING_APPLICATIONS") || "Pending Applications",
6357
+ accessor: row => (row === null || row === void 0 ? void 0 : row.pendingKnos) || 0,
6358
+ id: "pendingApplications"
6359
+ }, {
6360
+ Header: t("OVERALL_PROGRESS") || "Overall Progress",
6361
+ accessor: row => ((row === null || row === void 0 ? void 0 : row.progressPercent) || 0) + "%",
6362
+ id: "overallProgress"
6363
+ }], [t, history]);
6364
+ const _useState4 = useState(false),
6365
+ showReportMenu = _useState4[0],
6366
+ setShowReportMenu = _useState4[1];
6367
+ const _useState5 = useState({
6368
+ from: "",
6369
+ to: ""
6370
+ }),
6371
+ customDate = _useState5[0],
6372
+ setCustomDate = _useState5[1];
6373
+ const _useState6 = useState(false),
6374
+ showCustomPicker = _useState6[0],
6375
+ setShowCustomPicker = _useState6[1];
6376
+ const _useState7 = useState(false),
6377
+ reportLoading = _useState7[0];
6378
+ const reportMenuRef = useRef(null);
6379
+ useEffect(() => {
6380
+ const handler = e => {
6381
+ if (reportMenuRef.current && !reportMenuRef.current.contains(e.target)) {
6092
6382
  setShowReportMenu(false);
6093
6383
  setShowCustomPicker(false);
6094
- if (_wasThrown2) throw _result2;
6095
- return _result2;
6096
- });
6097
- return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
6098
- } catch (e) {
6099
- return Promise.reject(e);
6100
- }
6101
- };
6102
- const StatCard = _ref3 => {
6103
- let title = _ref3.title,
6104
- value = _ref3.value,
6105
- type = _ref3.type,
6106
- isLoading = _ref3.isLoading,
6107
- icon = _ref3.icon;
6108
- return /*#__PURE__*/React.createElement("div", {
6109
- className: "stat-card " + type
6110
- }, isLoading ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
6111
- className: "stat-title skeleton skeleton-text"
6112
- }), /*#__PURE__*/React.createElement("div", {
6113
- className: "stat-value skeleton skeleton-number"
6114
- })) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
6115
- className: "stat-title"
6116
- }, title), /*#__PURE__*/React.createElement("div", {
6117
- className: "stat-value"
6118
- }, value), icon && /*#__PURE__*/React.createElement("div", {
6119
- className: "stat-icon"
6120
- }, icon)));
6384
+ }
6385
+ };
6386
+ document.addEventListener("mousedown", handler);
6387
+ return () => document.removeEventListener("mousedown", handler);
6388
+ }, []);
6389
+ const handlePresetDownload = filter => {
6390
+ handleDownload();
6121
6391
  };
6122
- const options = [{
6123
- action: "Assign"
6124
- }];
6125
- const handleMenuSelect = option => {
6126
- setShowOptions(false);
6127
- setShowModal(true);
6392
+ const handleCustomDownload = () => {
6393
+ if (!customDate.from || !customDate.to) {
6394
+ alert(t("SELECT_DATE_RANGE") || "Please select both From and To dates.");
6395
+ return;
6396
+ }
6397
+ handleDownload();
6128
6398
  };
6129
6399
  const handleDownloadEkycData = function () {
6130
6400
  try {
6401
+ if (!surveyors || surveyors.length === 0) {
6402
+ alert(t("NO_SURVEYORS_ASSIGNED") || "No surveyors assigned to this supervisor.");
6403
+ return Promise.resolve();
6404
+ }
6131
6405
  setEkycDownloadLoading(true);
6132
6406
  return Promise.resolve(_finallyRethrows(function () {
6133
6407
  return _catch(function () {
6134
- var _surveyor$owner7;
6135
- return Promise.resolve(Digit.EkycService.application_list({
6408
+ const fetchPromises = surveyors.map(s => Digit.EkycService.application_list({
6136
6409
  tenantId: tenantId || "dl.djb",
6137
6410
  offset: 0,
6138
- limit: 10000,
6139
- surveyorId: surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner7 = surveyor.owner) === null || _surveyor$owner7 === void 0 ? void 0 : _surveyor$owner7.uuid,
6411
+ limit: 5000,
6412
+ surveyorId: s.surveyorId || s.id,
6140
6413
  reportDownload: true
6141
- })).then(function (response) {
6142
- const consumerList = (response === null || response === void 0 ? void 0 : response.consumerList) || [];
6414
+ }).catch(err => {
6415
+ console.error("Error fetching applications for surveyor " + s.surveyorName + ":", err);
6416
+ return {
6417
+ consumerList: []
6418
+ };
6419
+ }));
6420
+ return Promise.resolve(Promise.all(fetchPromises)).then(function (results) {
6421
+ const consumerList = results.flatMap(res => (res === null || res === void 0 ? void 0 : res.consumerList) || []);
6143
6422
  if (consumerList.length === 0) {
6144
6423
  alert(t("NO_DATA_FOUND") || "No data found for download.");
6145
6424
  return;
@@ -6182,29 +6461,52 @@ const SurveyorDetailsDashboard = () => {
6182
6461
  });
6183
6462
  return cleanObj;
6184
6463
  });
6185
- const cleanFileName = "eKYC_Data_" + fullName.replace(/[^a-zA-Z0-9]/g, "_");
6464
+ const cleanFileName = "eKYC_Data_Supervisor_" + fullName.replace(/[^a-zA-Z0-9]/g, "_");
6186
6465
  Digit.Download.Excel(excelData, cleanFileName);
6187
6466
  });
6188
6467
  }, function (error) {
6189
6468
  console.error("Error downloading eKYC Excel:", error);
6190
6469
  });
6191
- }, function (_wasThrown3, _result3) {
6470
+ }, function (_wasThrown, _result) {
6192
6471
  setEkycDownloadLoading(false);
6193
- if (_wasThrown3) throw _result3;
6194
- return _result3;
6472
+ if (_wasThrown) throw _result;
6473
+ return _result;
6195
6474
  }));
6196
6475
  } catch (e) {
6197
6476
  return Promise.reject(e);
6198
6477
  }
6199
6478
  };
6200
- const closeModal = function () {
6201
- try {
6202
- setShowModal(false);
6203
- return Promise.resolve();
6204
- } catch (e) {
6205
- return Promise.reject(e);
6206
- }
6479
+ const StatCard = _ref3 => {
6480
+ let title = _ref3.title,
6481
+ value = _ref3.value,
6482
+ type = _ref3.type,
6483
+ isLoading = _ref3.isLoading,
6484
+ icon = _ref3.icon;
6485
+ return /*#__PURE__*/React.createElement("div", {
6486
+ className: "stat-card " + type
6487
+ }, isLoading ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
6488
+ className: "stat-title skeleton skeleton-text"
6489
+ }), /*#__PURE__*/React.createElement("div", {
6490
+ className: "stat-value skeleton skeleton-number"
6491
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
6492
+ className: "stat-title"
6493
+ }, title), /*#__PURE__*/React.createElement("div", {
6494
+ className: "stat-value"
6495
+ }, value), icon && /*#__PURE__*/React.createElement("div", {
6496
+ className: "stat-icon"
6497
+ }, icon)));
6207
6498
  };
6499
+ const isPageLoading = isProgressLoading || isSupervisorSearchLoading || isSurveyorSearchLoading || isVendorSearchLoading;
6500
+ if (isPageLoading && !supervisor) {
6501
+ return /*#__PURE__*/React.createElement(Loader, null);
6502
+ }
6503
+ if (!supervisor) {
6504
+ return /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement("div", {
6505
+ style: {
6506
+ padding: "24px"
6507
+ }
6508
+ }, t("NO_SUPERVISOR_FOUND")));
6509
+ }
6208
6510
  return /*#__PURE__*/React.createElement(Card, {
6209
6511
  className: "surveyor-dashboard"
6210
6512
  }, /*#__PURE__*/React.createElement("div", {
@@ -6219,7 +6521,7 @@ const SurveyorDetailsDashboard = () => {
6219
6521
  className: "name"
6220
6522
  }, fullName), /*#__PURE__*/React.createElement("div", {
6221
6523
  className: "designation"
6222
- }, (surveyor === null || surveyor === void 0 ? void 0 : surveyor.description) || t("FIELD_SURVEYOR")))), /*#__PURE__*/React.createElement("div", {
6524
+ }, t("FIELD_SUPERVISOR") || "Field Supervisor"))), /*#__PURE__*/React.createElement("div", {
6223
6525
  className: "report-download",
6224
6526
  ref: reportMenuRef
6225
6527
  }, /*#__PURE__*/React.createElement("button", {
@@ -6246,7 +6548,7 @@ const SurveyorDetailsDashboard = () => {
6246
6548
  return /*#__PURE__*/React.createElement("div", {
6247
6549
  key: key,
6248
6550
  className: "menu-item",
6249
- onClick: () => handlePresetDownload(key)
6551
+ onClick: () => handlePresetDownload()
6250
6552
  }, label);
6251
6553
  }), /*#__PURE__*/React.createElement("div", {
6252
6554
  className: "custom-date-trigger",
@@ -6280,33 +6582,14 @@ const SurveyorDetailsDashboard = () => {
6280
6582
  onClick: handleCustomDownload
6281
6583
  }, t("DOWNLOAD") || "Download"))))), /*#__PURE__*/React.createElement("div", {
6282
6584
  className: "stats-wrapper"
6283
- }, /*#__PURE__*/React.createElement(StatCard, {
6284
- title: t("TOTAL_ASSIGNED"),
6285
- value: (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo = dashboardData.dashboardInfo) === null || _dashboardData$dashbo === void 0 ? void 0 : _dashboardData$dashbo.total) || 0,
6286
- type: "today",
6287
- isLoading: isDashboardLoading,
6288
- icon: /*#__PURE__*/React.createElement(FaUsers, null)
6289
- }), /*#__PURE__*/React.createElement(StatCard, {
6290
- title: t("COMPLETED"),
6291
- value: (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo2 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo2 === void 0 ? void 0 : _dashboardData$dashbo2.completed) || 0,
6292
- type: "week",
6293
- isLoading: isDashboardLoading,
6294
- icon: /*#__PURE__*/React.createElement(FaCheckCircle, null)
6295
- }), /*#__PURE__*/React.createElement(StatCard, {
6296
- title: t("PENDING"),
6297
- value: (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo3 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo3 === void 0 ? void 0 : _dashboardData$dashbo3.pending) || 0,
6298
- type: "pending",
6299
- isLoading: isDashboardLoading,
6300
- icon: /*#__PURE__*/React.createElement(FaClock, null)
6301
- }), /*#__PURE__*/React.createElement(StatCard, {
6302
- title: t("SUBMITTED"),
6303
- value: (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo4 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo4 === void 0 ? void 0 : _dashboardData$dashbo4.submittedCount) || 0,
6304
- type: "month",
6305
- isLoading: isDashboardLoading,
6306
- icon: /*#__PURE__*/React.createElement(FaChartLine, null)
6307
- })), /*#__PURE__*/React.createElement("div", {
6308
- className: "charts-wrapper"
6309
- }), /*#__PURE__*/React.createElement("div", {
6585
+ }, cards.map((card, idx) => /*#__PURE__*/React.createElement(StatCard, {
6586
+ key: idx,
6587
+ title: t(card.label),
6588
+ value: card.count,
6589
+ type: card.type,
6590
+ isLoading: isProgressLoading,
6591
+ icon: card.icon
6592
+ }))), /*#__PURE__*/React.createElement("div", {
6310
6593
  className: "ekyc-dashboard-section"
6311
6594
  }, /*#__PURE__*/React.createElement("div", {
6312
6595
  className: "ekyc-details-wrapper"
@@ -6320,43 +6603,37 @@ const SurveyorDetailsDashboard = () => {
6320
6603
  className: "label"
6321
6604
  }, t("MOBILE")), /*#__PURE__*/React.createElement("span", {
6322
6605
  className: "value"
6323
- }, (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner8 = surveyor.owner) === null || _surveyor$owner8 === void 0 ? void 0 : _surveyor$owner8.mobileNumber) || (surveyor === null || surveyor === void 0 ? void 0 : surveyor.mobileNo) || "N/A")), /*#__PURE__*/React.createElement("div", {
6606
+ }, mobileNumber)), /*#__PURE__*/React.createElement("div", {
6324
6607
  className: "detail-item"
6325
6608
  }, /*#__PURE__*/React.createElement("span", {
6326
6609
  className: "label"
6327
6610
  }, t("EMAIL")), /*#__PURE__*/React.createElement("span", {
6328
6611
  className: "value"
6329
- }, (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner9 = surveyor.owner) === null || _surveyor$owner9 === void 0 ? void 0 : _surveyor$owner9.emailId) || "N/A")), /*#__PURE__*/React.createElement("div", {
6612
+ }, email)), /*#__PURE__*/React.createElement("div", {
6330
6613
  className: "detail-item"
6331
6614
  }, /*#__PURE__*/React.createElement("span", {
6332
6615
  className: "label"
6333
6616
  }, t("GENDER")), /*#__PURE__*/React.createElement("span", {
6334
6617
  className: "value"
6335
- }, (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner0 = surveyor.owner) === null || _surveyor$owner0 === void 0 ? void 0 : _surveyor$owner0.gender) || "N/A")), /*#__PURE__*/React.createElement("div", {
6618
+ }, gender)), /*#__PURE__*/React.createElement("div", {
6336
6619
  className: "detail-item"
6337
6620
  }, /*#__PURE__*/React.createElement("span", {
6338
6621
  className: "label"
6339
6622
  }, t("STATUS")), /*#__PURE__*/React.createElement("span", {
6340
6623
  className: "value"
6341
- }, (surveyor === null || surveyor === void 0 ? void 0 : surveyor.status) || "N/A")), /*#__PURE__*/React.createElement("div", {
6624
+ }, status)), /*#__PURE__*/React.createElement("div", {
6342
6625
  className: "detail-item"
6343
6626
  }, /*#__PURE__*/React.createElement("span", {
6344
6627
  className: "label"
6345
- }, t("SERVICE_TYPE")), /*#__PURE__*/React.createElement("span", {
6628
+ }, t("ASSIGNED_ZONE") || "Assigned Zone"), /*#__PURE__*/React.createElement("span", {
6346
6629
  className: "value"
6347
- }, (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$additionalD = surveyor.additionalDetails) === null || _surveyor$additionalD === void 0 ? void 0 : _surveyor$additionalD.serviceType) || "N/A")), /*#__PURE__*/React.createElement("div", {
6630
+ }, assignedZone)), /*#__PURE__*/React.createElement("div", {
6348
6631
  className: "detail-item"
6349
6632
  }, /*#__PURE__*/React.createElement("span", {
6350
6633
  className: "label"
6351
6634
  }, t("VENDOR_NAME") || "Vendor Name"), /*#__PURE__*/React.createElement("span", {
6352
6635
  className: "value"
6353
- }, vendorName)), /*#__PURE__*/React.createElement("div", {
6354
- className: "detail-item"
6355
- }, /*#__PURE__*/React.createElement("span", {
6356
- className: "label"
6357
- }, t("SUPERVISOR_NAME") || "Supervisor Name"), /*#__PURE__*/React.createElement("span", {
6358
- className: "value"
6359
- }, supervisorName)))), /*#__PURE__*/React.createElement("div", {
6636
+ }, vendorName)))), /*#__PURE__*/React.createElement("div", {
6360
6637
  className: "details-right"
6361
6638
  }, /*#__PURE__*/React.createElement("div", {
6362
6639
  className: "download-card"
@@ -6386,19 +6663,17 @@ const SurveyorDetailsDashboard = () => {
6386
6663
  className: "dashboard-card"
6387
6664
  }, /*#__PURE__*/React.createElement(Table, {
6388
6665
  t: t,
6389
- tableTitle: t("ASSIGNED_KNOS"),
6390
- tableClass: "ekycTable",
6391
- data: (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo5 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo5 === void 0 ? void 0 : _dashboardData$dashbo5.consumerList) || [],
6392
- columns: knoColumns,
6393
- isLoading: isDashboardLoading,
6394
- totalRecords: dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo6 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo6 === void 0 ? void 0 : _dashboardData$dashbo6.total,
6666
+ tableTitle: t("CONNECTED_SURVEYORS") || "Connected Surveyors",
6667
+ tableClass: "ekycTable",
6668
+ data: paginatedSurveyors,
6669
+ columns: surveyorColumns,
6670
+ isLoading: isProgressLoading,
6671
+ totalRecords: surveyors.length,
6395
6672
  currentPage: currentPage,
6396
6673
  pageSizeLimit: pageSize,
6397
- showAutoSerialNo: true,
6398
6674
  isPaginationRequired: true,
6399
6675
  onNextPage: () => {
6400
- var _dashboardData$dashbo7;
6401
- if (currentPage < ((dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo7 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo7 === void 0 ? void 0 : _dashboardData$dashbo7.totalPages) || 1) - 1) {
6676
+ if (currentPage < Math.ceil(surveyors.length / pageSize) - 1) {
6402
6677
  setCurrentPage(prev => prev + 1);
6403
6678
  }
6404
6679
  },
@@ -6411,422 +6686,795 @@ const SurveyorDetailsDashboard = () => {
6411
6686
  setCurrentPage(0);
6412
6687
  },
6413
6688
  onLastPage: () => {
6414
- var _dashboardData$dashbo8;
6415
- setCurrentPage(Math.max(((dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo8 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo8 === void 0 ? void 0 : _dashboardData$dashbo8.totalPages) || 1) - 1, 0));
6689
+ setCurrentPage(Math.max(Math.ceil(surveyors.length / pageSize) - 1, 0));
6416
6690
  },
6417
6691
  onPageSizeChange: e => {
6418
6692
  setPageSize(Number(e.target.value));
6419
6693
  setCurrentPage(0);
6420
6694
  }
6421
- })), (!roles.includes("EKYC_SURVEYOR") || roles.includes("EMPLOYEE")) && /*#__PURE__*/React.createElement(ActionBar, null, /*#__PURE__*/React.createElement(SubmitBar, {
6422
- label: t("EKYC_ASSIGN_KNOS"),
6423
- onSubmit: () => setShowOptions(prev => !prev)
6424
- }), showOptions && /*#__PURE__*/React.createElement(Menu, {
6425
- options: options,
6426
- optionKey: "action",
6427
- t: t,
6428
- onSelect: handleMenuSelect,
6429
- style: {
6430
- color: "#FFFFFF",
6431
- fontSize: "18px"
6432
- }
6433
- })), showModal && /*#__PURE__*/React.createElement(AssignEkycModal, {
6434
- surveyor: surveyor,
6435
- closeModal: closeModal,
6436
- refetchDashboard: refetchDashboard
6437
- }));
6438
- };
6439
-
6440
- function formReducer(state, payload) {
6441
- const storageKey = "EKYC.SW.INBOX";
6442
- switch (payload.action) {
6443
- case "mutateSearchForm":
6444
- Digit.SessionStorage.set(storageKey, _extends({}, state, {
6445
- searchForm: payload.data
6446
- }));
6447
- return _extends({}, state, {
6448
- searchForm: payload.data
6449
- });
6450
- case "mutateFilterForm":
6451
- Digit.SessionStorage.set(storageKey, _extends({}, state, {
6452
- filterForm: payload.data
6453
- }));
6454
- return _extends({}, state, {
6455
- filterForm: payload.data
6456
- });
6457
- case "mutateTableForm":
6458
- Digit.SessionStorage.set(storageKey, _extends({}, state, {
6459
- tableForm: payload.data
6460
- }));
6461
- return _extends({}, state, {
6462
- tableForm: payload.data
6463
- });
6464
- default:
6465
- return state;
6466
- }
6467
- }
6468
- const formInitValue = {
6469
- filterForm: {},
6470
- searchForm: {},
6471
- tableForm: {
6472
- limit: 10,
6473
- offset: 0,
6474
- sortBy: "createdTime",
6475
- sortOrder: "DESC"
6476
- }
6695
+ })));
6477
6696
  };
6478
- const tableColumnConfig = (t, handleReview) => [{
6479
- Header: t("SURVEYOR_NAME"),
6480
- accessor: "surveyorName",
6481
- Cell: _ref => {
6482
- var _row$original, _row$original2, _row$original3;
6483
- let row = _ref.row;
6484
- const id = (_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original.id;
6485
- return /*#__PURE__*/React.createElement("span", {
6486
- className: "link",
6487
- onClick: () => handleReview(id)
6488
- }, ((_row$original2 = row.original) === null || _row$original2 === void 0 ? void 0 : _row$original2.surveyorName) || ((_row$original3 = row.original) === null || _row$original3 === void 0 ? void 0 : _row$original3.name) || "NA");
6489
- }
6490
- }, {
6491
- Header: t("MOBILE_NUMBER"),
6492
- accessor: "mobileNo",
6493
- Cell: _ref2 => {
6494
- var _row$original4, _row$original5, _row$original5$owner;
6495
- let row = _ref2.row;
6496
- return /*#__PURE__*/React.createElement("span", null, ((_row$original4 = row.original) === null || _row$original4 === void 0 ? void 0 : _row$original4.mobileNo) || ((_row$original5 = row.original) === null || _row$original5 === void 0 ? void 0 : (_row$original5$owner = _row$original5.owner) === null || _row$original5$owner === void 0 ? void 0 : _row$original5$owner.mobileNumber) || "NA");
6497
- }
6498
- }, {
6499
- Header: t("STATUS"),
6500
- accessor: "status",
6501
- Cell: _ref3 => {
6502
- var _row$original6;
6503
- let row = _ref3.row;
6504
- const status = ((_row$original6 = row.original) === null || _row$original6 === void 0 ? void 0 : _row$original6.status) || "DEFAULT";
6505
- return /*#__PURE__*/React.createElement("span", {
6506
- className: "ekyc-status-tag " + status
6507
- }, t(status));
6508
- }
6509
- }, {
6510
- Header: t("SERVICE_TYPE"),
6511
- accessor: "serviceType",
6512
- Cell: _ref4 => {
6513
- var _row$original7;
6514
- let row = _ref4.row;
6515
- return /*#__PURE__*/React.createElement("span", null, ((_row$original7 = row.original) === null || _row$original7 === void 0 ? void 0 : _row$original7.serviceType) || "NA");
6516
- }
6517
- }];
6518
6697
 
6519
- const SupervisorInboxTableConfig = _ref => {
6520
- var _Digit$SessionStorage, _Digit$SessionStorage2, _Digit$SessionStorage3, _formState$tableForm, _formState$tableForm2;
6521
- let onPageSizeChange = _ref.onPageSizeChange,
6522
- formState = _ref.formState,
6523
- totalCount = _ref.totalCount,
6524
- table = _ref.table,
6525
- dispatch = _ref.dispatch,
6526
- onSortingByData = _ref.onSortingByData,
6527
- _ref$inboxStyles = _ref.inboxStyles,
6528
- inboxStyles = _ref$inboxStyles === void 0 ? {} : _ref$inboxStyles,
6529
- _ref$tableStyle = _ref.tableStyle,
6530
- tableStyle = _ref$tableStyle === void 0 ? {} : _ref$tableStyle;
6698
+ const AssignEkycModal = _ref => {
6699
+ let surveyor = _ref.surveyor,
6700
+ closeModal = _ref.closeModal,
6701
+ refetchDashboard = _ref.refetchDashboard;
6531
6702
  const _useTranslation = useTranslation(),
6532
6703
  t = _useTranslation.t;
6533
- const history = useHistory();
6534
- const userType = ((_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : (_Digit$SessionStorage2 = _Digit$SessionStorage.info) === null || _Digit$SessionStorage2 === void 0 ? void 0 : (_Digit$SessionStorage3 = _Digit$SessionStorage2.type) === null || _Digit$SessionStorage3 === void 0 ? void 0 : _Digit$SessionStorage3.toLowerCase()) || "citizen";
6535
- const handleReview = id => {
6536
- history.push("/digit-ui/" + userType + "/ekyc/assign/surveyor-details/" + id);
6537
- };
6538
- const limit = (formState === null || formState === void 0 ? void 0 : (_formState$tableForm = formState.tableForm) === null || _formState$tableForm === void 0 ? void 0 : _formState$tableForm.limit) || 10;
6539
- const offset = (formState === null || formState === void 0 ? void 0 : (_formState$tableForm2 = formState.tableForm) === null || _formState$tableForm2 === void 0 ? void 0 : _formState$tableForm2.offset) || 0;
6540
- return {
6541
- disableSort: false,
6542
- autoSort: false,
6543
- manualPagination: true,
6544
- currentPage: Math.floor(offset / limit),
6545
- onPageSizeChange,
6546
- onNextPage: () => dispatch({
6547
- action: "mutateTableForm",
6548
- data: _extends({}, formState.tableForm, {
6549
- offset: Number(offset) + Number(limit)
6550
- })
6551
- }),
6552
- onPrevPage: () => dispatch({
6553
- action: "mutateTableForm",
6554
- data: _extends({}, formState.tableForm, {
6555
- offset: Number(offset) - Number(limit)
6556
- })
6557
- }),
6558
- onLastPage: () => dispatch({
6559
- action: "mutateTableForm",
6560
- data: _extends({}, formState.tableForm, {
6561
- offset: Math.ceil(totalCount / limit) * limit - Number(limit)
6562
- })
6563
- }),
6564
- onFirstPage: () => dispatch({
6565
- action: "mutateTableForm",
6566
- data: _extends({}, formState.tableForm, {
6567
- offset: 0
6568
- })
6704
+ const _useState = useState([]),
6705
+ selectedKnos = _useState[0],
6706
+ setSelectedKnos = _useState[1];
6707
+ const _useState2 = useState(false),
6708
+ isBulkSelection = _useState2[0],
6709
+ setIsBulkSelection = _useState2[1];
6710
+ const _useState3 = useState(0),
6711
+ currentPage = _useState3[0],
6712
+ setCurrentPage = _useState3[1];
6713
+ const _useState4 = useState(10),
6714
+ pageSize = _useState4[0],
6715
+ setPageSize = _useState4[1];
6716
+ const _useState5 = useState(false),
6717
+ showToast = _useState5[0],
6718
+ setShowToast = _useState5[1];
6719
+ const _useState6 = useState({
6720
+ error: false,
6721
+ label: ""
6569
6722
  }),
6570
- totalRecords: totalCount,
6571
- onSort: onSortingByData,
6572
- data: table,
6573
- columns: tableColumnConfig(t, handleReview),
6574
- inboxStyles: _extends({}, inboxStyles),
6575
- tableStyle: _extends({}, tableStyle)
6576
- };
6577
- };
6578
-
6579
- const AssignEkyc = () => {
6580
- var _formState$tableForm, _formState$tableForm2, _formState$tableForm3, _formState$tableForm4, _formState$searchForm, _dashboardData$dashbo;
6581
- let tenantId = Digit.ULBService.getCurrentTenantId();
6582
- if (!tenantId || tenantId === "dl") {
6583
- tenantId = "dl.djb";
6584
- }
6585
- const _useReducer = useReducer(formReducer, formInitValue),
6586
- formState = _useReducer[0],
6587
- dispatch = _useReducer[1];
6588
- let paginationParms = {
6589
- limit: (formState === null || formState === void 0 ? void 0 : (_formState$tableForm = formState.tableForm) === null || _formState$tableForm === void 0 ? void 0 : _formState$tableForm.limit) || 10,
6590
- offset: (formState === null || formState === void 0 ? void 0 : (_formState$tableForm2 = formState.tableForm) === null || _formState$tableForm2 === void 0 ? void 0 : _formState$tableForm2.offset) || 0,
6591
- sortBy: (formState === null || formState === void 0 ? void 0 : (_formState$tableForm3 = formState.tableForm) === null || _formState$tableForm3 === void 0 ? void 0 : _formState$tableForm3.sortBy) || "createdTime",
6592
- sortOrder: (formState === null || formState === void 0 ? void 0 : (_formState$tableForm4 = formState.tableForm) === null || _formState$tableForm4 === void 0 ? void 0 : _formState$tableForm4.sortOrder) || "DESC"
6593
- };
6594
- const mobileNumber = (formState === null || formState === void 0 ? void 0 : (_formState$searchForm = formState.searchForm) === null || _formState$searchForm === void 0 ? void 0 : _formState$searchForm.mobileNumber) || "";
6595
- const isSearchActive = !!mobileNumber;
6596
- const filters = _extends({}, paginationParms, {
6597
- status: "ACTIVE,DISABLED"
6598
- });
6599
- if (isSearchActive) {
6600
- filters.mobileNumber = mobileNumber;
6601
- }
6602
- const _Digit$Hooks$fsm$useS = Digit.Hooks.fsm.useSurveyorSearch(tenantId, filters, {
6603
- enabled: !!tenantId,
6604
- keepPreviousData: true
6723
+ toastData = _useState6[0],
6724
+ setToastData = _useState6[1];
6725
+ const _useState7 = useState({
6726
+ kno: "",
6727
+ pincode: "",
6728
+ zoneCode: "",
6729
+ zoneName: "",
6730
+ ward: "",
6731
+ assembly: "",
6732
+ mrkey: "",
6733
+ ekycStatus: ""
6605
6734
  }),
6606
- dashboardData = _Digit$Hooks$fsm$useS.data,
6607
- isLoading = _Digit$Hooks$fsm$useS.isLoading;
6608
- const _Digit$Hooks$ekyc$use = Digit.Hooks.ekyc.useEkycAssignmentProgress({
6609
- enabled: !!tenantId,
6735
+ filters = _useState7[0],
6736
+ setFilters = _useState7[1];
6737
+ const _useState8 = useState(filters),
6738
+ debouncedFilters = _useState8[0],
6739
+ setDebouncedFilters = _useState8[1];
6740
+ const _Digit$Hooks$ws$useWS = Digit.Hooks.ws.useWSConfigMDMS.ZROLocation("dl.djb"),
6741
+ zroLocationsData = _Digit$Hooks$ws$useWS.data,
6742
+ isZroLoading = _Digit$Hooks$ws$useWS.isLoading;
6743
+ const mappedZROLocation = useMemo(() => {
6744
+ return (zroLocationsData || []).map(item => ({
6745
+ code: item.code,
6746
+ name: item.name
6747
+ }));
6748
+ }, [zroLocationsData]);
6749
+ const _Digit$Hooks$useCommo = Digit.Hooks.useCommonMDMS("dl.djb", "egov-location", ["TenantBoundary"]),
6750
+ egovLocationData = _Digit$Hooks$useCommo.data;
6751
+ const boundaryData = useMemo(() => {
6752
+ var _egovLocationData$ego;
6753
+ const tenantBoundary = (egovLocationData === null || egovLocationData === void 0 ? void 0 : (_egovLocationData$ego = egovLocationData["egov-location"]) === null || _egovLocationData$ego === void 0 ? void 0 : _egovLocationData$ego.TenantBoundary) || [];
6754
+ const revenueData = tenantBoundary.find(item => {
6755
+ var _item$hierarchyType;
6756
+ return (item === null || item === void 0 ? void 0 : (_item$hierarchyType = item.hierarchyType) === null || _item$hierarchyType === void 0 ? void 0 : _item$hierarchyType.code) === "REVENUE";
6757
+ });
6758
+ const boundary = (revenueData === null || revenueData === void 0 ? void 0 : revenueData.boundary) || [];
6759
+ return Array.isArray(boundary) ? boundary : [boundary];
6760
+ }, [egovLocationData]);
6761
+ const _useMemo = useMemo(() => {
6762
+ const assemblies = new Map();
6763
+ const wards = new Map();
6764
+ const boundaries = Array.isArray(boundaryData) ? boundaryData : boundaryData ? [boundaryData] : [];
6765
+ const traverse = node => {
6766
+ if (!node) return;
6767
+ if (node.label === "Ward" || node.label === "WARD" || node.label === "Block" || node.label === "BLOCK") {
6768
+ const code = node.code || node.localname || node.name;
6769
+ const name = node.name || node.localname || code;
6770
+ if (code) wards.set(code, {
6771
+ code,
6772
+ name: name
6773
+ });
6774
+ }
6775
+ if (node.label === "Assembly Constituency" || node.label === "ASSEMBLY_CONSTITUENCY") {
6776
+ const code = node.code || node.localname || node.name;
6777
+ const name = node.name || node.localname || code;
6778
+ if (code) assemblies.set(code, {
6779
+ code,
6780
+ name: name
6781
+ });
6782
+ }
6783
+ if (node.children && node.children.length > 0) {
6784
+ node.children.forEach(traverse);
6785
+ }
6786
+ };
6787
+ boundaries.forEach(traverse);
6788
+ return {
6789
+ assemblyOptions: Array.from(assemblies.values()).sort((a, b) => a.name.localeCompare(b.name)),
6790
+ wardOptions: Array.from(wards.values()).sort((a, b) => a.name.localeCompare(b.name))
6791
+ };
6792
+ }, [boundaryData]),
6793
+ assemblyOptions = _useMemo.assemblyOptions,
6794
+ wardOptions = _useMemo.wardOptions;
6795
+ const structuredLocalityData = useMemo(() => {
6796
+ let localities = [];
6797
+ const boundaries = Array.isArray(boundaryData) ? boundaryData : boundaryData ? [boundaryData] : [];
6798
+ const extractLocalities = node => {
6799
+ if (!node) return;
6800
+ if (node.label === "Locality" || node.label === "LOCALITY") {
6801
+ localities.push(_extends({}, node, {
6802
+ name: node.localname || node.name || node.code
6803
+ }));
6804
+ }
6805
+ if (node.children && node.children.length > 0) {
6806
+ node.children.forEach(child => extractLocalities(child));
6807
+ }
6808
+ };
6809
+ boundaries.forEach(rootNode => extractLocalities(rootNode));
6810
+ return localities;
6811
+ }, [boundaryData]);
6812
+ const fetchedPincodes = useMemo(() => {
6813
+ const pinSet = new Set();
6814
+ structuredLocalityData.forEach(loc => {
6815
+ if (loc.pincode) {
6816
+ const pins = Array.isArray(loc.pincode) ? loc.pincode : [loc.pincode];
6817
+ pins.forEach(p => {
6818
+ if (p) {
6819
+ const sanitizedPin = p.toString().split(".")[0];
6820
+ pinSet.add(sanitizedPin);
6821
+ }
6822
+ });
6823
+ }
6824
+ });
6825
+ return Array.from(pinSet).sort();
6826
+ }, [structuredLocalityData]);
6827
+ useEffect(() => {
6828
+ const timer = setTimeout(() => {
6829
+ setDebouncedFilters(filters);
6830
+ }, 500);
6831
+ return () => clearTimeout(timer);
6832
+ }, [filters]);
6833
+ useEffect(() => {
6834
+ setCurrentPage(0);
6835
+ }, [debouncedFilters, filters.kno]);
6836
+ const _Digit$Hooks$ekyc$use = Digit.Hooks.ekyc.useEkycApplicationList(_extends({
6837
+ unassignedOnly: true
6838
+ }, filters.kno && {
6839
+ kno: filters.kno
6840
+ }, debouncedFilters.ekycStatus && {
6841
+ ekycStatus: debouncedFilters.ekycStatus
6842
+ }, debouncedFilters.zoneName && {
6843
+ zoneName: debouncedFilters.zoneName
6844
+ }, debouncedFilters.assembly && {
6845
+ assembly: debouncedFilters.assembly
6846
+ }, debouncedFilters.ward && {
6847
+ ward: debouncedFilters.ward
6848
+ }, debouncedFilters.mrkey && {
6849
+ mrkey: debouncedFilters.mrkey
6850
+ }, debouncedFilters.pincode && {
6851
+ pincode: debouncedFilters.pincode
6852
+ }), {
6853
+ tenantId: "dl.djb",
6854
+ offset: currentPage * pageSize,
6855
+ limit: pageSize
6856
+ }, {
6610
6857
  keepPreviousData: true
6611
6858
  }),
6612
- isDataSearchLoading = _Digit$Hooks$ekyc$use.isLoading;
6613
- const sourceData = useMemo(() => {
6614
- return (dashboardData === null || dashboardData === void 0 ? void 0 : dashboardData.surveyors) || [];
6615
- }, [dashboardData]);
6616
- const filteredData = useMemo(() => {
6617
- return (sourceData || []).map(item => {
6618
- var _owner$roles, _owner$roles$map, _item$additionalDetai, _item$auditDetails, _item$auditDetails2;
6619
- const owner = (item === null || item === void 0 ? void 0 : item.owner) || {};
6620
- const roleCodes = (owner === null || owner === void 0 ? void 0 : (_owner$roles = owner.roles) === null || _owner$roles === void 0 ? void 0 : (_owner$roles$map = _owner$roles.map(role => role.code)) === null || _owner$roles$map === void 0 ? void 0 : _owner$roles$map.join(", ")) || "";
6621
- return _extends({}, item, {
6622
- id: (item === null || item === void 0 ? void 0 : item.id) || "",
6623
- surveyorName: (item === null || item === void 0 ? void 0 : item.name) || (owner === null || owner === void 0 ? void 0 : owner.name) || "",
6624
- mobileNo: (item === null || item === void 0 ? void 0 : item.mobileNo) || (owner === null || owner === void 0 ? void 0 : owner.mobileNumber) || "",
6625
- email: (owner === null || owner === void 0 ? void 0 : owner.emailId) || "",
6626
- vendorId: (item === null || item === void 0 ? void 0 : item.vendorId) || "",
6627
- tenantId: (item === null || item === void 0 ? void 0 : item.tenantId) || "",
6628
- supervisorId: (item === null || item === void 0 ? void 0 : item.supervisorId) || "",
6629
- status: (item === null || item === void 0 ? void 0 : item.status) || "",
6630
- roleCodes,
6631
- userName: (owner === null || owner === void 0 ? void 0 : owner.userName) || "",
6632
- gender: (owner === null || owner === void 0 ? void 0 : owner.gender) || "",
6633
- serviceType: (item === null || item === void 0 ? void 0 : (_item$additionalDetai = item.additionalDetails) === null || _item$additionalDetai === void 0 ? void 0 : _item$additionalDetai.serviceType) || "",
6634
- createdTime: (item === null || item === void 0 ? void 0 : (_item$auditDetails = item.auditDetails) === null || _item$auditDetails === void 0 ? void 0 : _item$auditDetails.createdTime) || 0,
6635
- lastModifiedTime: (item === null || item === void 0 ? void 0 : (_item$auditDetails2 = item.auditDetails) === null || _item$auditDetails2 === void 0 ? void 0 : _item$auditDetails2.lastModifiedTime) || 0
6859
+ applicationData = _Digit$Hooks$ekyc$use.data,
6860
+ isLoading = _Digit$Hooks$ekyc$use.isFetching;
6861
+ const handleAssignmentError = (errMsg, variables) => {
6862
+ const isAlreadyAssigned = errMsg.toLowerCase().includes("already assigned") || errMsg.toLowerCase().includes("already assign") || errMsg.toLowerCase().includes("active assignment") || errMsg.toLowerCase().includes("mrkey") || errMsg.toLowerCase().includes("mr key") || errMsg.toLowerCase().includes("kno") || errMsg.toLowerCase().includes("already exists");
6863
+ if (isAlreadyAssigned) {
6864
+ const isMrKeyType = (variables === null || variables === void 0 ? void 0 : variables.assignmentType) === "MRKEY";
6865
+ if (isMrKeyType) {
6866
+ setToastData({
6867
+ error: true,
6868
+ label: t("EKYC_MR_KEY_ALREADY_ASSIGNED_WITH_ANOTHER_SURVEYOR") || "mr key is already assign with another surveyor"
6869
+ });
6870
+ } else {
6871
+ setToastData({
6872
+ error: true,
6873
+ label: t("EKYC_KNO_ALREADY_ASSIGNED_WITH_ANOTHER_SURVEYOR") || "kno is already assign with another surveyor"
6874
+ });
6875
+ }
6876
+ } else {
6877
+ setToastData({
6878
+ error: true,
6879
+ label: t(errMsg) || errMsg || t("EKYC_SOMETHING_WENT_WRONG") || "Something went wrong"
6636
6880
  });
6637
- });
6638
- }, [sourceData]);
6639
- const totalRecords = (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo = dashboardData.dashboardInfo) === null || _dashboardData$dashbo === void 0 ? void 0 : _dashboardData$dashbo.totalRecords) || (dashboardData === null || dashboardData === void 0 ? void 0 : dashboardData.totalCount) || 0;
6640
- const SearchFormFields = useCallback(_ref => {
6641
- let registerRef = _ref.registerRef,
6642
- searchFormState = _ref.searchFormState,
6643
- controlSearchForm = _ref.controlSearchForm;
6644
- return /*#__PURE__*/React.createElement(SearchFormFieldsComponents, {
6645
- registerRef,
6646
- searchFormState,
6647
- controlSearchForm,
6648
- searchType: "mobile",
6649
- className: "search"
6650
- });
6651
- }, []);
6652
- const tableOrderFormDefaultValues = {
6653
- sortBy: "createdTime",
6654
- limit: window.Digit.Utils.browser.isMobile() ? 50 : 10,
6655
- offset: 0,
6656
- sortOrder: "DESC"
6657
- };
6658
- const onSearchFormSubmit = data => {
6659
- data.hasOwnProperty("") && (data === null || data === void 0 ? true : delete data[""]);
6660
- dispatch({
6661
- action: "mutateTableForm",
6662
- data: _extends({}, tableOrderFormDefaultValues)
6663
- });
6664
- dispatch({
6665
- action: "mutateSearchForm",
6666
- data
6667
- });
6668
- };
6669
- const searchFormDefaultValues = {
6670
- mobileNumber: "",
6671
- applicationNumber: "",
6672
- consumerNo: ""
6881
+ }
6882
+ setShowToast(true);
6673
6883
  };
6674
- const onSearchFormReset = setSearchFormValue => {
6675
- setSearchFormValue("mobileNumber", null);
6676
- setSearchFormValue("applicationNumber", null);
6677
- setSearchFormValue("consumerNo", null);
6678
- dispatch({
6679
- action: "mutateSearchForm",
6680
- data: searchFormDefaultValues
6884
+ const assignmentMutation = Digit.Hooks.ekyc.useEkycAssignmentCreate({
6885
+ onSuccess: (response, variables) => {
6886
+ if (response !== null && response !== void 0 && response.error) {
6887
+ var _response$data;
6888
+ const errMsg = (response === null || response === void 0 ? void 0 : (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.message) || "";
6889
+ handleAssignmentError(errMsg, variables);
6890
+ return;
6891
+ }
6892
+ if (response !== null && response !== void 0 && response.skipped && response.skipped.length > 0) {
6893
+ var _response$skipped$;
6894
+ const reason = ((_response$skipped$ = response.skipped[0]) === null || _response$skipped$ === void 0 ? void 0 : _response$skipped$.reason) || "";
6895
+ handleAssignmentError(reason, variables);
6896
+ return;
6897
+ }
6898
+ setToastData({
6899
+ error: false,
6900
+ label: t("EKYC_ASSIGNMENT_SUCCESSFUL") || "Assignment successful"
6901
+ });
6902
+ setShowToast(true);
6903
+ setTimeout(function () {
6904
+ try {
6905
+ return Promise.resolve(refetchDashboard()).then(function () {
6906
+ closeModal();
6907
+ });
6908
+ } catch (e) {
6909
+ return Promise.reject(e);
6910
+ }
6911
+ }, 1000);
6912
+ },
6913
+ onError: (error, variables) => {
6914
+ var _error$data, _error$response, _error$response$data;
6915
+ const errMsg = (error === null || error === void 0 ? void 0 : (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.message) || (error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.message) || "";
6916
+ handleAssignmentError(errMsg, variables);
6917
+ }
6918
+ });
6919
+ const tableData = (applicationData === null || applicationData === void 0 ? void 0 : applicationData.consumerList) || [];
6920
+ const getAssignmentPayload = () => {
6921
+ if (isBulkSelection) {
6922
+ const filterMappings = [{
6923
+ key: "ekycStatus",
6924
+ type: "EKYCSTATUS"
6925
+ }, {
6926
+ key: "zoneName",
6927
+ type: "ZONENAME"
6928
+ }, {
6929
+ key: "assembly",
6930
+ type: "ASSEMBLY"
6931
+ }, {
6932
+ key: "ward",
6933
+ type: "WARD"
6934
+ }, {
6935
+ key: "mrkey",
6936
+ type: "MRKEY"
6937
+ }, {
6938
+ key: "pincode",
6939
+ type: "PINCODE"
6940
+ }];
6941
+ const appliedFilter = filterMappings.find(_ref2 => {
6942
+ let key = _ref2.key;
6943
+ return debouncedFilters[key];
6944
+ });
6945
+ if (appliedFilter) {
6946
+ return {
6947
+ assignmentType: appliedFilter.type,
6948
+ assignmentValue: debouncedFilters[appliedFilter.key]
6949
+ };
6950
+ }
6951
+ }
6952
+ return {
6953
+ assignmentType: "KNO",
6954
+ assignmentValue: selectedKnos
6955
+ };
6956
+ };
6957
+ const handleAssign = () => {
6958
+ var _surveyor$owner;
6959
+ const _getAssignmentPayload = getAssignmentPayload(),
6960
+ assignmentType = _getAssignmentPayload.assignmentType,
6961
+ assignmentValue = _getAssignmentPayload.assignmentValue;
6962
+ assignmentMutation.mutate({
6963
+ tenantId: "dl.djb",
6964
+ surveyorId: surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner = surveyor.owner) === null || _surveyor$owner === void 0 ? void 0 : _surveyor$owner.uuid,
6965
+ assignmentType,
6966
+ assignmentValue
6681
6967
  });
6682
6968
  };
6683
- const propsForSearchForm = {
6684
- SearchFormFields,
6685
- onSearchFormSubmit,
6686
- searchFormDefaultValues: formState === null || formState === void 0 ? void 0 : formState.searchForm,
6687
- resetSearchFormDefaultValues: searchFormDefaultValues,
6688
- onSearchFormReset,
6689
- className: "search-form-wns-inbox"
6969
+ const handleSelectAll = () => {
6970
+ setIsBulkSelection(true);
6971
+ const pageKnos = tableData.map(item => item.kno);
6972
+ const allSelected = pageKnos.length > 0 && pageKnos.every(kno => selectedKnos.includes(kno));
6973
+ setSelectedKnos(prev => allSelected ? prev.filter(kno => !pageKnos.includes(kno)) : [...new Set([...prev, ...pageKnos])]);
6690
6974
  };
6691
- const onPageSizeChange = e => {
6692
- const newLimit = Number(e.target.value);
6693
- dispatch({
6694
- action: "mutateTableForm",
6695
- data: _extends({}, formState.tableForm, {
6696
- limit: newLimit,
6697
- offset: 0
6698
- })
6699
- });
6975
+ const handleFilterChange = (key, value) => {
6976
+ setFilters(prev => _extends({}, prev, {
6977
+ [key]: value
6978
+ }));
6700
6979
  };
6701
- const onSortingByData = e => {
6702
- if (e.length > 0) {
6703
- const _e$ = e[0],
6704
- id = _e$.id,
6705
- desc = _e$.desc;
6706
- const sortOrder = desc ? "DESC" : "ASC";
6707
- const sortBy = id;
6708
- if (!(formState.tableForm.sortBy === sortBy && formState.tableForm.sortOrder === sortOrder)) {
6709
- dispatch({
6710
- action: "mutateTableForm",
6711
- data: _extends({}, formState.tableForm, {
6712
- sortBy: id,
6713
- sortOrder: desc ? "DESC" : "ASC"
6714
- })
6715
- });
6716
- }
6980
+ const columns = useMemo(() => [{
6981
+ Header: () => /*#__PURE__*/React.createElement("input", {
6982
+ type: "checkbox",
6983
+ checked: tableData.length > 0 && tableData.every(item => selectedKnos.includes(item.kno)),
6984
+ onChange: handleSelectAll
6985
+ }),
6986
+ id: "selection",
6987
+ Cell: _ref3 => {
6988
+ let row = _ref3.row;
6989
+ const kno = row.original.kno;
6990
+ return /*#__PURE__*/React.createElement("input", {
6991
+ type: "checkbox",
6992
+ checked: selectedKnos.includes(kno),
6993
+ onChange: () => handleSelect(kno)
6994
+ });
6995
+ }
6996
+ }, {
6997
+ Header: "KNO",
6998
+ accessor: "kno"
6999
+ }, {
7000
+ Header: "Consumer Name",
7001
+ accessor: row => ((row.firstName || "") + " " + (row.middleName || "") + " " + (row.lastName || "")).trim(),
7002
+ id: "consumerName"
7003
+ }, {
7004
+ Header: "Zone",
7005
+ accessor: "zoneName"
7006
+ }, {
7007
+ Header: "Pincode",
7008
+ accessor: "pincode"
7009
+ }, {
7010
+ Header: "Status",
7011
+ accessor: "status",
7012
+ Cell: _ref4 => {
7013
+ let value = _ref4.value;
7014
+ return /*#__PURE__*/React.createElement("span", {
7015
+ className: "status-badge " + (value === "ACTIVE" ? "verified" : value === "PENDING" ? "pending" : "assigned")
7016
+ }, value);
7017
+ }
7018
+ }, {
7019
+ Header: "eKYC Status",
7020
+ accessor: "ekycStatus",
7021
+ Cell: _ref5 => {
7022
+ let value = _ref5.value;
7023
+ const status = (value || "NA").toUpperCase();
7024
+ return value ? /*#__PURE__*/React.createElement("span", {
7025
+ className: "ekyc-status-tag " + status
7026
+ }, t(status)) : "-";
6717
7027
  }
7028
+ }], [selectedKnos, tableData]);
7029
+ const handleSelect = kno => {
7030
+ setSelectedKnos(prev => prev.includes(kno) ? prev.filter(item => item !== kno) : [...prev, kno]);
6718
7031
  };
6719
- const propsForInboxTable = SupervisorInboxTableConfig(_extends({}, {
6720
- onPageSizeChange,
6721
- formState,
6722
- totalCount: totalRecords,
6723
- table: filteredData,
6724
- dispatch,
6725
- onSortingByData,
6726
- tenantId,
6727
- inboxStyles: {
6728
- overflowX: "scroll",
6729
- overflowY: "hidden"
7032
+ return /*#__PURE__*/React.createElement(Modal, {
7033
+ headerBarMain: "Assign KNOs to " + (surveyor === null || surveyor === void 0 ? void 0 : surveyor.name),
7034
+ headerBarEnd: /*#__PURE__*/React.createElement(Close, {
7035
+ onClick: closeModal
7036
+ }),
7037
+ actionCancelLabel: "Cancel",
7038
+ actionCancelOnSubmit: closeModal,
7039
+ actionSaveLabel: "Assign " + selectedKnos.length + " KNOs",
7040
+ actionSaveOnSubmit: handleAssign,
7041
+ isDisabled: !(selectedKnos !== null && selectedKnos !== void 0 && selectedKnos.length)
7042
+ }, /*#__PURE__*/React.createElement("div", {
7043
+ className: "assign-knos-modal"
7044
+ }, /*#__PURE__*/React.createElement("div", {
7045
+ className: "filters-grid"
7046
+ }, /*#__PURE__*/React.createElement("input", {
7047
+ className: "form-control",
7048
+ placeholder: "KNO",
7049
+ value: filters.kno,
7050
+ onChange: e => handleFilterChange("kno", e.target.value)
7051
+ }), /*#__PURE__*/React.createElement("select", {
7052
+ className: "form-control",
7053
+ value: filters.pincode,
7054
+ onChange: e => handleFilterChange("pincode", e.target.value)
7055
+ }, /*#__PURE__*/React.createElement("option", {
7056
+ value: ""
7057
+ }, "Select Pincode"), fetchedPincodes.map(pin => /*#__PURE__*/React.createElement("option", {
7058
+ key: pin,
7059
+ value: pin
7060
+ }, pin))), /*#__PURE__*/React.createElement("select", {
7061
+ className: "form-control",
7062
+ value: filters.zoneName,
7063
+ onChange: e => {
7064
+ const val = e.target.value;
7065
+ setFilters(prev => _extends({}, prev, {
7066
+ zoneCode: val,
7067
+ zoneName: val
7068
+ }));
6730
7069
  },
6731
- tableStyle: {
6732
- width: "70%"
7070
+ disabled: isZroLoading
7071
+ }, /*#__PURE__*/React.createElement("option", {
7072
+ value: ""
7073
+ }, isZroLoading ? "Loading ZRO Locations..." : "Select ZRO Location"), mappedZROLocation.map(loc => /*#__PURE__*/React.createElement("option", {
7074
+ key: loc.code,
7075
+ value: loc.name
7076
+ }, loc.name))), /*#__PURE__*/React.createElement("select", {
7077
+ className: "form-control",
7078
+ value: filters.ward,
7079
+ onChange: e => handleFilterChange("ward", e.target.value)
7080
+ }, /*#__PURE__*/React.createElement("option", {
7081
+ value: ""
7082
+ }, "Select Ward"), wardOptions.map(ward => /*#__PURE__*/React.createElement("option", {
7083
+ key: ward.code,
7084
+ value: ward.name
7085
+ }, ward.name))), /*#__PURE__*/React.createElement("select", {
7086
+ className: "form-control",
7087
+ value: filters.assembly,
7088
+ onChange: e => handleFilterChange("assembly", e.target.value)
7089
+ }, /*#__PURE__*/React.createElement("option", {
7090
+ value: ""
7091
+ }, "Select Assembly"), assemblyOptions.map(assembly => /*#__PURE__*/React.createElement("option", {
7092
+ key: assembly.code,
7093
+ value: assembly.name
7094
+ }, assembly.name))), /*#__PURE__*/React.createElement("input", {
7095
+ className: "form-control",
7096
+ placeholder: "MR Key",
7097
+ value: filters.mrkey,
7098
+ onChange: e => handleFilterChange("mrkey", e.target.value)
7099
+ }), selectedKnos.length > 0 && /*#__PURE__*/React.createElement("button", {
7100
+ className: "clear-selected-btn",
7101
+ type: "button",
7102
+ onClick: () => setSelectedKnos([])
7103
+ }, t("EKYC_CLEAR_SELECTION") || "Clear Selected (" + selectedKnos.length + ")")), /*#__PURE__*/React.createElement(Table, {
7104
+ tableTitle: "eKYC Applications",
7105
+ tableClass: "ekycTable",
7106
+ data: tableData,
7107
+ columns: columns,
7108
+ isLoading: isLoading,
7109
+ totalRecords: (applicationData === null || applicationData === void 0 ? void 0 : applicationData.totalCount) || 0,
7110
+ currentPage: currentPage,
7111
+ pageSizeLimit: pageSize,
7112
+ manualPagination: true,
7113
+ isPaginationRequired: true,
7114
+ onNextPage: () => {
7115
+ if (currentPage < ((applicationData === null || applicationData === void 0 ? void 0 : applicationData.totalPages) || 1) - 1) {
7116
+ setCurrentPage(prev => prev + 1);
7117
+ }
7118
+ },
7119
+ onPrevPage: () => {
7120
+ if (currentPage > 0) {
7121
+ setCurrentPage(prev => prev - 1);
7122
+ }
7123
+ },
7124
+ onFirstPage: () => {
7125
+ setCurrentPage(0);
7126
+ },
7127
+ onLastPage: () => {
7128
+ setCurrentPage(Math.max(((applicationData === null || applicationData === void 0 ? void 0 : applicationData.totalPages) || 1) - 1, 0));
7129
+ },
7130
+ onPageSizeChange: e => {
7131
+ setPageSize(Number(e.target.value));
7132
+ setCurrentPage(0);
6733
7133
  }
7134
+ })), showToast && /*#__PURE__*/React.createElement(Toast, {
7135
+ error: toastData.error,
7136
+ label: toastData.label,
7137
+ onClose: () => setShowToast(false)
6734
7138
  }));
6735
- const isInboxLoading = isLoading;
6736
- return /*#__PURE__*/React.createElement("div", {
6737
- className: "app-container"
6738
- }, /*#__PURE__*/React.createElement(InboxComposer, _extends({
6739
- isInboxLoading
6740
- }, propsForSearchForm, {
6741
- propsForInboxTable,
6742
- formState,
6743
- countData: dashboardData === null || dashboardData === void 0 ? void 0 : dashboardData.dashboardInfo,
6744
- isCardLoading: isDataSearchLoading
6745
- })));
6746
7139
  };
6747
7140
 
6748
- const AdminDashboard = () => {
6749
- var _Digit$SessionStorage, _loggedInUser$roles, _fullName$charAt;
7141
+ const SurveyorDetailsDashboard = () => {
7142
+ var _Digit$SessionStorage, _Digit$SessionStorage2, _Digit$SessionStorage3, _Digit$SessionStorage4, _surveyor$owner, _surveyor$owner2, _surveyor$owner3, _surveyor$owner4, _fullName$charAt, _dashboardData$dashbo, _dashboardData$dashbo2, _dashboardData$dashbo3, _dashboardData$dashbo4, _surveyor$owner8, _surveyor$owner9, _surveyor$owner0, _surveyor$additionalD, _dashboardData$dashbo5, _dashboardData$dashbo6;
7143
+ const tenantId = Digit.ULBService.getCurrentTenantId();
7144
+ const _useState = useState(false),
7145
+ showModal = _useState[0],
7146
+ setShowModal = _useState[1];
7147
+ const _useState2 = useState(false),
7148
+ showOptions = _useState2[0],
7149
+ setShowOptions = _useState2[1];
7150
+ const _useState3 = useState(false),
7151
+ ekycDownloadLoading = _useState3[0],
7152
+ setEkycDownloadLoading = _useState3[1];
7153
+ const _useParams = useParams(),
7154
+ surveyorId = _useParams.id;
7155
+ const ownerIds = (_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : (_Digit$SessionStorage2 = _Digit$SessionStorage.info) === null || _Digit$SessionStorage2 === void 0 ? void 0 : _Digit$SessionStorage2.uuid;
6750
7156
  const _useTranslation = useTranslation(),
6751
7157
  t = _useTranslation.t;
6752
- const history = useHistory();
6753
- let tenantId = Digit.ULBService.getCurrentTenantId();
6754
- if (!tenantId || tenantId === "dl") {
6755
- tenantId = "dl.djb";
6756
- }
6757
- const loggedInUser = (_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : _Digit$SessionStorage.info;
7158
+ const _Digit$Hooks$fsm$useS = Digit.Hooks.fsm.useSurveyorSearch(tenantId, {
7159
+ ids: surveyorId
7160
+ }, {
7161
+ enabled: !!surveyorId,
7162
+ staleTime: Infinity
7163
+ }),
7164
+ surveyorSearchById = _Digit$Hooks$fsm$useS.data,
7165
+ isLoadingId = _Digit$Hooks$fsm$useS.isLoading;
7166
+ const _Digit$Hooks$fsm$useS2 = Digit.Hooks.fsm.useSurveyorSearch(tenantId, surveyorId ? {
7167
+ ownerIds: surveyorId
7168
+ } : {
7169
+ ownerIds
7170
+ }, {
7171
+ enabled: true,
7172
+ staleTime: Infinity
7173
+ }),
7174
+ surveyorSearchByOwner = _Digit$Hooks$fsm$useS2.data,
7175
+ isLoadingOwner = _Digit$Hooks$fsm$useS2.isLoading;
7176
+ const surveyorSearchResponse = useMemo(() => {
7177
+ if (surveyorId) {
7178
+ var _surveyorSearchById$s;
7179
+ return surveyorSearchById !== null && surveyorSearchById !== void 0 && (_surveyorSearchById$s = surveyorSearchById.surveyors) !== null && _surveyorSearchById$s !== void 0 && _surveyorSearchById$s.length ? surveyorSearchById : surveyorSearchByOwner;
7180
+ }
7181
+ return surveyorSearchByOwner;
7182
+ }, [surveyorId, surveyorSearchById, surveyorSearchByOwner]);
7183
+ const isLoading = surveyorId ? isLoadingId || isLoadingOwner : isLoadingOwner;
7184
+ const roles = (_Digit$SessionStorage3 = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage3 === void 0 ? void 0 : (_Digit$SessionStorage4 = _Digit$SessionStorage3.info) === null || _Digit$SessionStorage4 === void 0 ? void 0 : _Digit$SessionStorage4.roles.map(ele => ele.code);
7185
+ const surveyor = useMemo(() => {
7186
+ var _surveyorSearchRespon;
7187
+ return (surveyorSearchResponse === null || surveyorSearchResponse === void 0 ? void 0 : (_surveyorSearchRespon = surveyorSearchResponse.surveyors) === null || _surveyorSearchRespon === void 0 ? void 0 : _surveyorSearchRespon[0]) || null;
7188
+ }, [surveyorSearchResponse]);
6758
7189
  const _Digit$Hooks$fsm$useD = Digit.Hooks.fsm.useDsoSearch(tenantId, {
6759
7190
  status: "ACTIVE"
6760
7191
  }, {
6761
7192
  enabled: !!tenantId
6762
7193
  }),
6763
- vendorSearchResponse = _Digit$Hooks$fsm$useD.data,
6764
- isVendorSearchLoading = _Digit$Hooks$fsm$useD.isLoading;
6765
- const _Digit$Hooks$ekyc$use = Digit.Hooks.ekyc.useEkycAssignmentProgress({
6766
- enabled: !!tenantId,
7194
+ vendorData = _Digit$Hooks$fsm$useD.data,
7195
+ isVendorLoading = _Digit$Hooks$fsm$useD.isLoading;
7196
+ const _Digit$Hooks$fsm$useS3 = Digit.Hooks.fsm.useSupervisorSearch(tenantId, {
7197
+ status: "ACTIVE"
7198
+ }, {
7199
+ enabled: !!tenantId
7200
+ }),
7201
+ supervisorSearchResponse = _Digit$Hooks$fsm$useS3.data,
7202
+ isSupervisorSearchLoading = _Digit$Hooks$fsm$useS3.isLoading;
7203
+ const vendorName = useMemo(() => {
7204
+ var _mappedVendor$dsoDeta;
7205
+ if (surveyor !== null && surveyor !== void 0 && surveyor.vendorName) return surveyor.vendorName;
7206
+ if (!vendorData || !(surveyor !== null && surveyor !== void 0 && surveyor.vendorId)) return "N/A";
7207
+ const mappedVendor = vendorData.find(v => {
7208
+ var _v$dsoDetails, _v$dsoDetails2;
7209
+ return ((_v$dsoDetails = v.dsoDetails) === null || _v$dsoDetails === void 0 ? void 0 : _v$dsoDetails.id) === surveyor.vendorId || ((_v$dsoDetails2 = v.dsoDetails) === null || _v$dsoDetails2 === void 0 ? void 0 : _v$dsoDetails2.vendorId) === surveyor.vendorId;
7210
+ });
7211
+ return (mappedVendor === null || mappedVendor === void 0 ? void 0 : (_mappedVendor$dsoDeta = mappedVendor.dsoDetails) === null || _mappedVendor$dsoDeta === void 0 ? void 0 : _mappedVendor$dsoDeta.name) || surveyor.vendorId || "N/A";
7212
+ }, [vendorData, surveyor === null || surveyor === void 0 ? void 0 : surveyor.vendorId, surveyor === null || surveyor === void 0 ? void 0 : surveyor.vendorName]);
7213
+ const supervisorName = useMemo(() => {
7214
+ var _mappedSupervisor$own;
7215
+ if (surveyor !== null && surveyor !== void 0 && surveyor.supervisorName) return surveyor.supervisorName;
7216
+ if (!(supervisorSearchResponse !== null && supervisorSearchResponse !== void 0 && supervisorSearchResponse.supervisors) || !(surveyor !== null && surveyor !== void 0 && surveyor.supervisorId)) return "N/A";
7217
+ const mappedSupervisor = supervisorSearchResponse.supervisors.find(s => {
7218
+ var _s$owner;
7219
+ return s.id === surveyor.supervisorId || ((_s$owner = s.owner) === null || _s$owner === void 0 ? void 0 : _s$owner.uuid) === surveyor.supervisorId;
7220
+ });
7221
+ return (mappedSupervisor === null || mappedSupervisor === void 0 ? void 0 : mappedSupervisor.name) || (mappedSupervisor === null || mappedSupervisor === void 0 ? void 0 : (_mappedSupervisor$own = mappedSupervisor.owner) === null || _mappedSupervisor$own === void 0 ? void 0 : _mappedSupervisor$own.name) || surveyor.supervisorId || "N/A";
7222
+ }, [supervisorSearchResponse, surveyor === null || surveyor === void 0 ? void 0 : surveyor.supervisorId, surveyor === null || surveyor === void 0 ? void 0 : surveyor.supervisorName]);
7223
+ const fullName = (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner = surveyor.owner) === null || _surveyor$owner === void 0 ? void 0 : _surveyor$owner.name) || (surveyor === null || surveyor === void 0 ? void 0 : surveyor.name) || "N/A";
7224
+ const employeeId = (surveyor === null || surveyor === void 0 ? void 0 : surveyor.employeeId) || (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner2 = surveyor.owner) === null || _surveyor$owner2 === void 0 ? void 0 : _surveyor$owner2.uuid) || (surveyor === null || surveyor === void 0 ? void 0 : surveyor.id);
7225
+ const mobileNumber = (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner3 = surveyor.owner) === null || _surveyor$owner3 === void 0 ? void 0 : _surveyor$owner3.mobileNumber) || (surveyor === null || surveyor === void 0 ? void 0 : surveyor.mobileNo) || "N/A";
7226
+ const _useState4 = useState(0),
7227
+ currentPage = _useState4[0],
7228
+ setCurrentPage = _useState4[1];
7229
+ const _useState5 = useState(20),
7230
+ pageSize = _useState5[0],
7231
+ setPageSize = _useState5[1];
7232
+ const queryParams = {
7233
+ tenantId: "dl.djb",
7234
+ offset: currentPage * pageSize,
7235
+ limit: pageSize,
7236
+ surveyorId: surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner4 = surveyor.owner) === null || _surveyor$owner4 === void 0 ? void 0 : _surveyor$owner4.uuid
7237
+ };
7238
+ const _Digit$Hooks$ekyc$use = Digit.Hooks.ekyc.useEkycSurveyorDashboard({}, queryParams, {
7239
+ enabled: !!queryParams.tenantId && !!queryParams.surveyorId,
6767
7240
  keepPreviousData: true
6768
7241
  }),
6769
- progressData = _Digit$Hooks$ekyc$use.data,
6770
- isProgressLoading = _Digit$Hooks$ekyc$use.isLoading;
6771
- const vendorsList = useMemo(() => {
6772
- if (vendorSearchResponse && vendorSearchResponse.length > 0) {
6773
- return vendorSearchResponse.map(v => {
6774
- var _progressData$supervi, _dso$owner, _v$owner, _dso$owner2;
6775
- const dso = v.dsoDetails || v;
6776
- const supervisorsList = dso.supervisors || [];
6777
- const surveyorsList = dso.surveyors || [];
6778
- const supervisorIds = supervisorsList.map(s => {
6779
- var _s$owner;
6780
- return s.id || ((_s$owner = s.owner) === null || _s$owner === void 0 ? void 0 : _s$owner.uuid);
6781
- }).filter(Boolean);
6782
- const matchedReports = (progressData === null || progressData === void 0 ? void 0 : (_progressData$supervi = progressData.supervisorReport) === null || _progressData$supervi === void 0 ? void 0 : _progressData$supervi.filter(r => supervisorIds.includes(r.supervisorId))) || [];
6783
- const completed = matchedReports.reduce((acc, r) => acc + (r.submittedKnos || 0), 0);
6784
- const pending = matchedReports.reduce((acc, r) => acc + (r.pendingKnos || 0), 0);
6785
- const total = matchedReports.reduce((acc, r) => acc + (r.totalKnos || 0), 0);
6786
- const progress = total > 0 ? Math.round(completed / total * 100) : 0;
6787
- const rejected = 0;
6788
- return {
6789
- id: dso.id || dso.vendorId || v.id || v.vendorId,
6790
- name: dso.name || dso.displayName || v.name || "N/A",
6791
- ownerName: ((_dso$owner = dso.owner) === null || _dso$owner === void 0 ? void 0 : _dso$owner.name) || ((_v$owner = v.owner) === null || _v$owner === void 0 ? void 0 : _v$owner.name) || "N/A",
6792
- mobileNumber: dso.mobileNumber || ((_dso$owner2 = dso.owner) === null || _dso$owner2 === void 0 ? void 0 : _dso$owner2.mobileNumber) || v.mobileNumber || "N/A",
6793
- supervisors: supervisorsList.length,
6794
- surveyors: surveyorsList.length,
6795
- completed: completed,
6796
- progress: progress,
6797
- pending: pending,
6798
- rejected: rejected
6799
- };
7242
+ isDashboardLoading = _Digit$Hooks$ekyc$use.isFetching,
7243
+ _Digit$Hooks$ekyc$use2 = _Digit$Hooks$ekyc$use.data,
7244
+ dashboardData = _Digit$Hooks$ekyc$use2 === void 0 ? {} : _Digit$Hooks$ekyc$use2,
7245
+ refetchDashboard = _Digit$Hooks$ekyc$use.refetch;
7246
+ const knoColumns = useMemo(() => [{
7247
+ Header: t("KNO") || "KNO",
7248
+ accessor: "kno"
7249
+ }, {
7250
+ Header: t("CONSUMER_NAME") || "Consumer Name",
7251
+ accessor: row => ((row.firstName || "") + " " + (row.middleName || "") + " " + (row.lastName || "")).trim(),
7252
+ id: "consumerName"
7253
+ }, {
7254
+ Header: t("ZONE") || "Zone",
7255
+ accessor: "zoneName"
7256
+ }, {
7257
+ Header: t("EKYC_STATUS") || "eKYC Status",
7258
+ accessor: "ekycStatus",
7259
+ Cell: _ref => {
7260
+ let value = _ref.value;
7261
+ const status = (value || "NA").toUpperCase();
7262
+ return value ? /*#__PURE__*/React.createElement("span", {
7263
+ className: "ekyc-status-tag " + status
7264
+ }, t(status)) : "-";
7265
+ }
7266
+ }, {
7267
+ Header: t("SUBMITTED_AT") || "Submitted At",
7268
+ accessor: "submittedAt",
7269
+ Cell: _ref2 => {
7270
+ let value = _ref2.value;
7271
+ return value ? Digit.DateUtils.ConvertEpochToDate(value) : "-";
7272
+ }
7273
+ }, {
7274
+ Header: t("ASSIGNED_AT") || "Assigned At",
7275
+ accessor: "assignedAt",
7276
+ Cell: _ref3 => {
7277
+ let value = _ref3.value;
7278
+ return value ? Digit.DateUtils.ConvertEpochToDate(value) : "-";
7279
+ }
7280
+ }], [t]);
7281
+ const _useState6 = useState(false),
7282
+ showReportMenu = _useState6[0],
7283
+ setShowReportMenu = _useState6[1];
7284
+ const _useState7 = useState({
7285
+ from: "",
7286
+ to: ""
7287
+ }),
7288
+ customDate = _useState7[0],
7289
+ setCustomDate = _useState7[1];
7290
+ const _useState8 = useState(false),
7291
+ showCustomPicker = _useState8[0],
7292
+ setShowCustomPicker = _useState8[1];
7293
+ const _useState9 = useState(false),
7294
+ reportLoading = _useState9[0],
7295
+ setReportLoading = _useState9[1];
7296
+ const reportMenuRef = useRef(null);
7297
+ useEffect(() => {
7298
+ const handler = e => {
7299
+ if (reportMenuRef.current && !reportMenuRef.current.contains(e.target)) {
7300
+ setShowReportMenu(false);
7301
+ setShowCustomPicker(false);
7302
+ }
7303
+ };
7304
+ document.addEventListener("mousedown", handler);
7305
+ return () => document.removeEventListener("mousedown", handler);
7306
+ }, []);
7307
+ const isPageLoading = isLoading || isVendorLoading || isSupervisorSearchLoading;
7308
+ if (isPageLoading && !surveyor) {
7309
+ return /*#__PURE__*/React.createElement(Loader, null);
7310
+ }
7311
+ if (!surveyor) {
7312
+ return /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement("div", {
7313
+ style: {
7314
+ padding: "24px"
7315
+ }
7316
+ }, t("NO_SURVEYOR_FOUND")));
7317
+ }
7318
+ const getDateRange = filter => {
7319
+ const now = new Date();
7320
+ const start = new Date(now);
7321
+ if (filter === "today") {
7322
+ start.setHours(0, 0, 0, 0);
7323
+ return {
7324
+ from: start,
7325
+ to: now
7326
+ };
7327
+ }
7328
+ if (filter === "week") {
7329
+ start.setDate(now.getDate() - now.getDay());
7330
+ start.setHours(0, 0, 0, 0);
7331
+ return {
7332
+ from: start,
7333
+ to: now
7334
+ };
7335
+ }
7336
+ if (filter === "month") {
7337
+ start.setDate(1);
7338
+ start.setHours(0, 0, 0, 0);
7339
+ return {
7340
+ from: start,
7341
+ to: now
7342
+ };
7343
+ }
7344
+ return null;
7345
+ };
7346
+ const handlePresetDownload = function (filter) {
7347
+ try {
7348
+ const range = getDateRange(filter);
7349
+ if (!range) return Promise.resolve();
7350
+ setReportLoading(true);
7351
+ const _temp = _finallyRethrows(function () {
7352
+ return _catch(function () {
7353
+ var _surveyor$owner5;
7354
+ return Promise.resolve(Digit.EkycService.dashboard({}, {
7355
+ tenantId: "dl.djb",
7356
+ offset: 0,
7357
+ limit: 1000,
7358
+ surveyorId: surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner5 = surveyor.owner) === null || _surveyor$owner5 === void 0 ? void 0 : _surveyor$owner5.uuid,
7359
+ fromDate: range.from.getTime(),
7360
+ toDate: range.to.getTime()
7361
+ })).then(function (response) {
7362
+ var _response$dashboardIn;
7363
+ const rows = (response === null || response === void 0 ? void 0 : (_response$dashboardIn = response.dashboardInfo) === null || _response$dashboardIn === void 0 ? void 0 : _response$dashboardIn.consumerList) || [];
7364
+ downloadSurveyorPDF({
7365
+ rows: rows,
7366
+ surveyorName: fullName,
7367
+ vendorName,
7368
+ supervisorName,
7369
+ employeeId,
7370
+ mobileNumber,
7371
+ dashboardInfo: (response === null || response === void 0 ? void 0 : response.dashboardInfo) || {},
7372
+ t
7373
+ });
7374
+ });
7375
+ }, function (err) {
7376
+ console.error("Failed to fetch dashboard data for report download:", err);
7377
+ });
7378
+ }, function (_wasThrown, _result) {
7379
+ setReportLoading(false);
7380
+ setShowReportMenu(false);
7381
+ setShowCustomPicker(false);
7382
+ if (_wasThrown) throw _result;
7383
+ return _result;
7384
+ });
7385
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
7386
+ } catch (e) {
7387
+ return Promise.reject(e);
7388
+ }
7389
+ };
7390
+ const handleCustomDownload = function () {
7391
+ try {
7392
+ if (!customDate.from || !customDate.to) {
7393
+ alert(t("SELECT_DATE_RANGE") || "Please select both From and To dates.");
7394
+ return Promise.resolve();
7395
+ }
7396
+ const from = new Date(customDate.from);
7397
+ from.setHours(0, 0, 0, 0);
7398
+ const to = new Date(customDate.to);
7399
+ to.setHours(23, 59, 59, 999);
7400
+ setReportLoading(true);
7401
+ const _temp2 = _finallyRethrows(function () {
7402
+ return _catch(function () {
7403
+ var _surveyor$owner6;
7404
+ return Promise.resolve(Digit.EkycService.dashboard({}, {
7405
+ tenantId: "dl.djb",
7406
+ offset: 0,
7407
+ limit: 1000,
7408
+ surveyorId: surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner6 = surveyor.owner) === null || _surveyor$owner6 === void 0 ? void 0 : _surveyor$owner6.uuid,
7409
+ fromDate: from.getTime(),
7410
+ toDate: to.getTime()
7411
+ })).then(function (response) {
7412
+ var _response$dashboardIn2;
7413
+ const rows = (response === null || response === void 0 ? void 0 : (_response$dashboardIn2 = response.dashboardInfo) === null || _response$dashboardIn2 === void 0 ? void 0 : _response$dashboardIn2.consumerList) || [];
7414
+ downloadSurveyorPDF({
7415
+ rows: rows,
7416
+ surveyorName: fullName,
7417
+ vendorName,
7418
+ supervisorName,
7419
+ employeeId,
7420
+ mobileNumber,
7421
+ dashboardInfo: (response === null || response === void 0 ? void 0 : response.dashboardInfo) || {},
7422
+ t
7423
+ });
7424
+ });
7425
+ }, function (err) {
7426
+ console.error("Failed to fetch custom dashboard data for report download:", err);
7427
+ });
7428
+ }, function (_wasThrown2, _result2) {
7429
+ setReportLoading(false);
7430
+ setShowReportMenu(false);
7431
+ setShowCustomPicker(false);
7432
+ if (_wasThrown2) throw _result2;
7433
+ return _result2;
6800
7434
  });
7435
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
7436
+ } catch (e) {
7437
+ return Promise.reject(e);
6801
7438
  }
6802
- return [];
6803
- }, [vendorSearchResponse, progressData]);
6804
- const _useState = useState(false),
6805
- ekycDownloadLoading = _useState[0],
6806
- setEkycDownloadLoading = _useState[1];
6807
- const _useState2 = useState(0),
6808
- currentPage = _useState2[0];
6809
- const _useState3 = useState(20),
6810
- pageSize = _useState3[0];
6811
- const _Digit$Hooks$ekyc$use2 = Digit.Hooks.ekyc.useEkycApplicationList({}, {
6812
- tenantId,
6813
- offset: currentPage * pageSize,
6814
- limit: pageSize
6815
- }, {
6816
- keepPreviousData: true
6817
- });
6818
- const fullName = (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.name) || "Admin";
6819
- const mobileNumber = (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.mobileNumber) || "N/A";
6820
- const roleText = (loggedInUser === null || loggedInUser === void 0 ? void 0 : (_loggedInUser$roles = loggedInUser.roles) === null || _loggedInUser$roles === void 0 ? void 0 : _loggedInUser$roles.map(r => r.name).join(", ")) || "EKYC Admin";
7439
+ };
7440
+ const StatCard = _ref4 => {
7441
+ let title = _ref4.title,
7442
+ value = _ref4.value,
7443
+ type = _ref4.type,
7444
+ isLoading = _ref4.isLoading,
7445
+ icon = _ref4.icon;
7446
+ return /*#__PURE__*/React.createElement("div", {
7447
+ className: "stat-card " + type
7448
+ }, isLoading ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
7449
+ className: "stat-title skeleton skeleton-text"
7450
+ }), /*#__PURE__*/React.createElement("div", {
7451
+ className: "stat-value skeleton skeleton-number"
7452
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
7453
+ className: "stat-title"
7454
+ }, title), /*#__PURE__*/React.createElement("div", {
7455
+ className: "stat-value"
7456
+ }, value), icon && /*#__PURE__*/React.createElement("div", {
7457
+ className: "stat-icon"
7458
+ }, icon)));
7459
+ };
7460
+ const options = [{
7461
+ action: "Assign"
7462
+ }];
7463
+ const handleMenuSelect = option => {
7464
+ setShowOptions(false);
7465
+ setShowModal(true);
7466
+ };
6821
7467
  const handleDownloadEkycData = function () {
6822
7468
  try {
6823
7469
  setEkycDownloadLoading(true);
6824
7470
  return Promise.resolve(_finallyRethrows(function () {
6825
7471
  return _catch(function () {
7472
+ var _surveyor$owner7;
6826
7473
  return Promise.resolve(Digit.EkycService.application_list({
6827
- tenantId: tenantId,
7474
+ tenantId: tenantId || "dl.djb",
6828
7475
  offset: 0,
6829
7476
  limit: 10000,
7477
+ surveyorId: surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner7 = surveyor.owner) === null || _surveyor$owner7 === void 0 ? void 0 : _surveyor$owner7.uuid,
6830
7478
  reportDownload: true
6831
7479
  })).then(function (response) {
6832
7480
  const consumerList = (response === null || response === void 0 ? void 0 : response.consumerList) || [];
@@ -6857,9 +7505,9 @@ const AdminDashboard = () => {
6857
7505
  };
6858
7506
  const excelData = consumerList.map(item => {
6859
7507
  const cleanObj = {};
6860
- const name = [item.firstName, item.middleName, item.lastName].filter(Boolean).join(" ");
6861
- if (name) {
6862
- cleanObj[t("CONSUMER_NAME") || "Consumer Name"] = name;
7508
+ const fullName = [item.firstName, item.middleName, item.lastName].filter(Boolean).join(" ");
7509
+ if (fullName) {
7510
+ cleanObj[t("CONSUMER_NAME") || "Consumer Name"] = fullName;
6863
7511
  }
6864
7512
  Object.keys(item).forEach(key => {
6865
7513
  if (excludedKeys.includes(key)) return;
@@ -6872,21 +7520,29 @@ const AdminDashboard = () => {
6872
7520
  });
6873
7521
  return cleanObj;
6874
7522
  });
6875
- const cleanFileName = "eKYC_All_Data_Admin_" + fullName.replace(/[^a-zA-Z0-9]/g, "_");
7523
+ const cleanFileName = "eKYC_Data_" + fullName.replace(/[^a-zA-Z0-9]/g, "_");
6876
7524
  Digit.Download.Excel(excelData, cleanFileName);
6877
7525
  });
6878
7526
  }, function (error) {
6879
7527
  console.error("Error downloading eKYC Excel:", error);
6880
7528
  });
6881
- }, function (_wasThrown, _result) {
7529
+ }, function (_wasThrown3, _result3) {
6882
7530
  setEkycDownloadLoading(false);
6883
- if (_wasThrown) throw _result;
6884
- return _result;
7531
+ if (_wasThrown3) throw _result3;
7532
+ return _result3;
6885
7533
  }));
6886
7534
  } catch (e) {
6887
7535
  return Promise.reject(e);
6888
7536
  }
6889
7537
  };
7538
+ const closeModal = function () {
7539
+ try {
7540
+ setShowModal(false);
7541
+ return Promise.resolve();
7542
+ } catch (e) {
7543
+ return Promise.reject(e);
7544
+ }
7545
+ };
6890
7546
  return /*#__PURE__*/React.createElement(Card, {
6891
7547
  className: "surveyor-dashboard"
6892
7548
  }, /*#__PURE__*/React.createElement("div", {
@@ -6901,19 +7557,151 @@ const AdminDashboard = () => {
6901
7557
  className: "name"
6902
7558
  }, fullName), /*#__PURE__*/React.createElement("div", {
6903
7559
  className: "designation"
6904
- }, t("EKYC_ADMIN") || "eKYC Admin / Manager"), /*#__PURE__*/React.createElement("div", {
6905
- className: "mobile-number"
6906
- }, mobileNumber))), /*#__PURE__*/React.createElement("button", {
7560
+ }, (surveyor === null || surveyor === void 0 ? void 0 : surveyor.description) || t("FIELD_SURVEYOR")))), /*#__PURE__*/React.createElement("div", {
7561
+ className: "report-download",
7562
+ ref: reportMenuRef
7563
+ }, /*#__PURE__*/React.createElement("button", {
7564
+ className: "download-btn",
7565
+ disabled: reportLoading,
7566
+ onClick: () => {
7567
+ setShowReportMenu(p => !p);
7568
+ setShowCustomPicker(false);
7569
+ }
7570
+ }, reportLoading ? t("DOWNLOADING") || "Downloading..." : t("DOWNLOAD_REPORT") || "Download Report"), showReportMenu && /*#__PURE__*/React.createElement("div", {
7571
+ className: "report-menu"
7572
+ }, [{
7573
+ label: t("TODAY") || "Today",
7574
+ key: "today"
7575
+ }, {
7576
+ label: t("THIS_WEEK") || "This Week",
7577
+ key: "week"
7578
+ }, {
7579
+ label: t("THIS_MONTH") || "This Month",
7580
+ key: "month"
7581
+ }].map(_ref5 => {
7582
+ let label = _ref5.label,
7583
+ key = _ref5.key;
7584
+ return /*#__PURE__*/React.createElement("div", {
7585
+ key: key,
7586
+ className: "menu-item",
7587
+ onClick: () => handlePresetDownload(key)
7588
+ }, label);
7589
+ }), /*#__PURE__*/React.createElement("div", {
7590
+ className: "custom-date-trigger",
7591
+ onClick: () => setShowCustomPicker(p => !p)
7592
+ }, t("CUSTOM_DATE") || "Custom Date"), showCustomPicker && /*#__PURE__*/React.createElement("div", {
7593
+ className: "custom-picker"
7594
+ }, /*#__PURE__*/React.createElement("div", {
7595
+ className: "date-field"
7596
+ }, /*#__PURE__*/React.createElement("label", {
7597
+ className: "date-label"
7598
+ }, t("FROM_DATE") || "From"), /*#__PURE__*/React.createElement("input", {
7599
+ type: "date",
7600
+ className: "date-input",
7601
+ value: customDate.from,
7602
+ onChange: e => setCustomDate(d => _extends({}, d, {
7603
+ from: e.target.value
7604
+ }))
7605
+ })), /*#__PURE__*/React.createElement("div", {
7606
+ className: "date-field"
7607
+ }, /*#__PURE__*/React.createElement("label", {
7608
+ className: "date-label"
7609
+ }, t("TO_DATE") || "To"), /*#__PURE__*/React.createElement("input", {
7610
+ type: "date",
7611
+ className: "date-input",
7612
+ value: customDate.to,
7613
+ onChange: e => setCustomDate(d => _extends({}, d, {
7614
+ to: e.target.value
7615
+ }))
7616
+ })), /*#__PURE__*/React.createElement("button", {
7617
+ className: "download-action-btn",
7618
+ onClick: handleCustomDownload
7619
+ }, t("DOWNLOAD") || "Download"))))), /*#__PURE__*/React.createElement("div", {
7620
+ className: "stats-wrapper"
7621
+ }, /*#__PURE__*/React.createElement(StatCard, {
7622
+ title: t("TOTAL_ASSIGNED"),
7623
+ value: (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo = dashboardData.dashboardInfo) === null || _dashboardData$dashbo === void 0 ? void 0 : _dashboardData$dashbo.total) || 0,
7624
+ type: "today",
7625
+ isLoading: isDashboardLoading,
7626
+ icon: /*#__PURE__*/React.createElement(FaUsers, null)
7627
+ }), /*#__PURE__*/React.createElement(StatCard, {
7628
+ title: t("COMPLETED"),
7629
+ value: (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo2 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo2 === void 0 ? void 0 : _dashboardData$dashbo2.completed) || 0,
7630
+ type: "week",
7631
+ isLoading: isDashboardLoading,
7632
+ icon: /*#__PURE__*/React.createElement(FaCheckCircle, null)
7633
+ }), /*#__PURE__*/React.createElement(StatCard, {
7634
+ title: t("PENDING"),
7635
+ value: (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo3 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo3 === void 0 ? void 0 : _dashboardData$dashbo3.pending) || 0,
7636
+ type: "pending",
7637
+ isLoading: isDashboardLoading,
7638
+ icon: /*#__PURE__*/React.createElement(FaClock, null)
7639
+ }), /*#__PURE__*/React.createElement(StatCard, {
7640
+ title: t("SUBMITTED"),
7641
+ value: (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo4 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo4 === void 0 ? void 0 : _dashboardData$dashbo4.submittedCount) || 0,
7642
+ type: "month",
7643
+ isLoading: isDashboardLoading,
7644
+ icon: /*#__PURE__*/React.createElement(FaChartLine, null)
7645
+ })), /*#__PURE__*/React.createElement("div", {
7646
+ className: "charts-wrapper"
7647
+ }), /*#__PURE__*/React.createElement("div", {
7648
+ className: "ekyc-dashboard-section"
7649
+ }, /*#__PURE__*/React.createElement("div", {
7650
+ className: "ekyc-details-wrapper"
7651
+ }, /*#__PURE__*/React.createElement("div", {
7652
+ className: "details-left"
7653
+ }, /*#__PURE__*/React.createElement("div", {
7654
+ className: "details-grid"
7655
+ }, /*#__PURE__*/React.createElement("div", {
7656
+ className: "detail-item"
7657
+ }, /*#__PURE__*/React.createElement("span", {
7658
+ className: "label"
7659
+ }, t("MOBILE")), /*#__PURE__*/React.createElement("span", {
7660
+ className: "value"
7661
+ }, (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner8 = surveyor.owner) === null || _surveyor$owner8 === void 0 ? void 0 : _surveyor$owner8.mobileNumber) || (surveyor === null || surveyor === void 0 ? void 0 : surveyor.mobileNo) || "N/A")), /*#__PURE__*/React.createElement("div", {
7662
+ className: "detail-item"
7663
+ }, /*#__PURE__*/React.createElement("span", {
7664
+ className: "label"
7665
+ }, t("EMAIL")), /*#__PURE__*/React.createElement("span", {
7666
+ className: "value"
7667
+ }, (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner9 = surveyor.owner) === null || _surveyor$owner9 === void 0 ? void 0 : _surveyor$owner9.emailId) || "N/A")), /*#__PURE__*/React.createElement("div", {
7668
+ className: "detail-item"
7669
+ }, /*#__PURE__*/React.createElement("span", {
7670
+ className: "label"
7671
+ }, t("GENDER")), /*#__PURE__*/React.createElement("span", {
7672
+ className: "value"
7673
+ }, (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$owner0 = surveyor.owner) === null || _surveyor$owner0 === void 0 ? void 0 : _surveyor$owner0.gender) || "N/A")), /*#__PURE__*/React.createElement("div", {
7674
+ className: "detail-item"
7675
+ }, /*#__PURE__*/React.createElement("span", {
7676
+ className: "label"
7677
+ }, t("STATUS")), /*#__PURE__*/React.createElement("span", {
7678
+ className: "value"
7679
+ }, (surveyor === null || surveyor === void 0 ? void 0 : surveyor.status) || "N/A")), /*#__PURE__*/React.createElement("div", {
7680
+ className: "detail-item"
7681
+ }, /*#__PURE__*/React.createElement("span", {
7682
+ className: "label"
7683
+ }, t("SERVICE_TYPE")), /*#__PURE__*/React.createElement("span", {
7684
+ className: "value"
7685
+ }, (surveyor === null || surveyor === void 0 ? void 0 : (_surveyor$additionalD = surveyor.additionalDetails) === null || _surveyor$additionalD === void 0 ? void 0 : _surveyor$additionalD.serviceType) || "N/A")), /*#__PURE__*/React.createElement("div", {
7686
+ className: "detail-item"
7687
+ }, /*#__PURE__*/React.createElement("span", {
7688
+ className: "label"
7689
+ }, t("VENDOR_NAME") || "Vendor Name"), /*#__PURE__*/React.createElement("span", {
7690
+ className: "value"
7691
+ }, vendorName)), /*#__PURE__*/React.createElement("div", {
7692
+ className: "detail-item"
7693
+ }, /*#__PURE__*/React.createElement("span", {
7694
+ className: "label"
7695
+ }, t("SUPERVISOR_NAME") || "Supervisor Name"), /*#__PURE__*/React.createElement("span", {
7696
+ className: "value"
7697
+ }, supervisorName)))), /*#__PURE__*/React.createElement("div", {
7698
+ className: "details-right"
7699
+ }, /*#__PURE__*/React.createElement("div", {
7700
+ className: "download-card"
7701
+ }, /*#__PURE__*/React.createElement("h4", null, t("DOWNLOAD_EKYC_DATA") || "Download eKYC Data"), /*#__PURE__*/React.createElement("p", null, t("DOWNLOAD_EKYC_DATA_DESC") || "Export the complete eKYC verification records for your assigned jurisdiction into Excel format."), /*#__PURE__*/React.createElement("button", {
6907
7702
  className: "download-excel-btn",
6908
7703
  disabled: ekycDownloadLoading,
6909
- onClick: handleDownloadEkycData,
6910
- style: {
6911
- margin: 0,
6912
- padding: "8px 16px",
6913
- height: "auto",
6914
- minHeight: "36px",
6915
- width: "auto"
6916
- }
7704
+ onClick: handleDownloadEkycData
6917
7705
  }, /*#__PURE__*/React.createElement("svg", {
6918
7706
  width: "16",
6919
7707
  height: "16",
@@ -6922,206 +7710,297 @@ const AdminDashboard = () => {
6922
7710
  stroke: "currentColor",
6923
7711
  strokeWidth: "2.5",
6924
7712
  strokeLinecap: "round",
6925
- strokeLinejoin: "round",
6926
- style: {
6927
- marginRight: "8px"
6928
- }
6929
- }, /*#__PURE__*/React.createElement("path", {
6930
- d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"
6931
- }), /*#__PURE__*/React.createElement("polyline", {
6932
- points: "7 10 12 15 17 10"
6933
- }), /*#__PURE__*/React.createElement("line", {
6934
- x1: "12",
6935
- y1: "15",
6936
- x2: "12",
6937
- y2: "3"
6938
- })), ekycDownloadLoading ? t("DOWNLOADING") || "Downloading..." : t("DOWNLOAD_EXCEL") || "Download Excel")), /*#__PURE__*/React.createElement("div", {
6939
- style: {
6940
- marginTop: "32px"
6941
- }
6942
- }, /*#__PURE__*/React.createElement("h3", {
6943
- style: {
6944
- fontSize: "20px",
6945
- fontWeight: "700",
6946
- color: "#101828",
6947
- marginBottom: "20px"
6948
- }
6949
- }, t("EKYC_VENDORS_PERFORMANCE") || "eKYC Vendors Performance"), isVendorSearchLoading || isProgressLoading ? /*#__PURE__*/React.createElement(Loader, null) : /*#__PURE__*/React.createElement("div", {
6950
- style: {
6951
- display: "grid",
6952
- gridTemplateColumns: "repeat(3, 1fr)",
6953
- gap: "24px",
6954
- width: "100%"
6955
- }
6956
- }, vendorsList.length === 0 ? /*#__PURE__*/React.createElement("div", {
6957
- style: {
6958
- gridColumn: "span 3",
6959
- textAlign: "center",
6960
- padding: "40px",
6961
- color: "#64748B",
6962
- fontSize: "16px"
6963
- }
6964
- }, t("NO_VENDORS_FOUND") || "No vendors found.") : vendorsList.map(vendor => /*#__PURE__*/React.createElement("div", {
6965
- key: vendor.id,
6966
- onClick: () => history.push("/digit-ui/employee/ekyc/vendors/" + vendor.id),
6967
- style: {
6968
- background: "#ffffff",
6969
- border: "1px solid #E2E8F0",
6970
- borderRadius: "16px",
6971
- padding: "24px",
6972
- boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03)",
6973
- cursor: "pointer",
6974
- transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
6975
- display: "flex",
6976
- flexDirection: "column",
6977
- justifyContent: "space-between",
6978
- gap: "16px"
7713
+ strokeLinejoin: "round"
7714
+ }, /*#__PURE__*/React.createElement("path", {
7715
+ d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"
7716
+ }), /*#__PURE__*/React.createElement("polyline", {
7717
+ points: "7 10 12 15 17 10"
7718
+ }), /*#__PURE__*/React.createElement("line", {
7719
+ x1: "12",
7720
+ y1: "15",
7721
+ x2: "12",
7722
+ y2: "3"
7723
+ })), ekycDownloadLoading ? t("DOWNLOADING") || "Downloading..." : t("DOWNLOAD_EXCEL") || "Download Excel"))))), /*#__PURE__*/React.createElement(Card, {
7724
+ className: "dashboard-card"
7725
+ }, /*#__PURE__*/React.createElement(Table, {
7726
+ t: t,
7727
+ tableTitle: t("ASSIGNED_KNOS"),
7728
+ tableClass: "ekycTable",
7729
+ data: (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo5 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo5 === void 0 ? void 0 : _dashboardData$dashbo5.consumerList) || [],
7730
+ columns: knoColumns,
7731
+ isLoading: isDashboardLoading,
7732
+ totalRecords: dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo6 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo6 === void 0 ? void 0 : _dashboardData$dashbo6.total,
7733
+ currentPage: currentPage,
7734
+ pageSizeLimit: pageSize,
7735
+ showAutoSerialNo: true,
7736
+ isPaginationRequired: true,
7737
+ onNextPage: () => {
7738
+ var _dashboardData$dashbo7;
7739
+ if (currentPage < ((dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo7 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo7 === void 0 ? void 0 : _dashboardData$dashbo7.totalPages) || 1) - 1) {
7740
+ setCurrentPage(prev => prev + 1);
7741
+ }
7742
+ },
7743
+ onPrevPage: () => {
7744
+ if (currentPage > 0) {
7745
+ setCurrentPage(prev => prev - 1);
7746
+ }
6979
7747
  },
6980
- onMouseEnter: e => {
6981
- e.currentTarget.style.transform = "translateY(-4px)";
6982
- e.currentTarget.style.boxShadow = "0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04)";
6983
- e.currentTarget.style.borderColor = "#CBD5E1";
7748
+ onFirstPage: () => {
7749
+ setCurrentPage(0);
6984
7750
  },
6985
- onMouseLeave: e => {
6986
- e.currentTarget.style.transform = "translateY(0)";
6987
- e.currentTarget.style.boxShadow = "0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03)";
6988
- e.currentTarget.style.borderColor = "#E2E8F0";
6989
- }
6990
- }, /*#__PURE__*/React.createElement("div", {
6991
- style: {
6992
- display: "flex",
6993
- justifyContent: "space-between",
6994
- alignItems: "flex-start"
6995
- }
6996
- }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h4", {
6997
- style: {
6998
- fontSize: "18px",
6999
- fontWeight: "700",
7000
- color: "#0B2559",
7001
- margin: 0
7002
- }
7003
- }, vendor.name), /*#__PURE__*/React.createElement("p", {
7004
- style: {
7005
- fontSize: "12px",
7006
- color: "#64748B",
7007
- marginTop: "2px",
7008
- marginBottom: 0
7009
- }
7010
- }, t("MOBILE") || "Mobile", ": ", vendor.mobileNumber)), /*#__PURE__*/React.createElement("span", {
7011
- style: {
7012
- background: "#E0F2FE",
7013
- color: "#0369A1",
7014
- padding: "6px 12px",
7015
- borderRadius: "999px",
7016
- fontSize: "13px",
7017
- fontWeight: "700"
7751
+ onLastPage: () => {
7752
+ var _dashboardData$dashbo8;
7753
+ setCurrentPage(Math.max(((dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo8 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo8 === void 0 ? void 0 : _dashboardData$dashbo8.totalPages) || 1) - 1, 0));
7754
+ },
7755
+ onPageSizeChange: e => {
7756
+ setPageSize(Number(e.target.value));
7757
+ setCurrentPage(0);
7018
7758
  }
7019
- }, vendor.progress, "%")), /*#__PURE__*/React.createElement("div", {
7759
+ })), roles.includes("EKYC_SUPERVISOR") && /*#__PURE__*/React.createElement(ActionBar, null, /*#__PURE__*/React.createElement(SubmitBar, {
7760
+ label: t("EKYC_ASSIGN_KNOS"),
7761
+ onSubmit: () => setShowOptions(prev => !prev)
7762
+ }), showOptions && /*#__PURE__*/React.createElement(Menu, {
7763
+ options: options,
7764
+ optionKey: "action",
7765
+ t: t,
7766
+ onSelect: handleMenuSelect,
7020
7767
  style: {
7021
- width: "100%",
7022
- height: "8px",
7023
- background: "#F1F5F9",
7024
- borderRadius: "999px",
7025
- overflow: "hidden"
7768
+ color: "#FFFFFF",
7769
+ fontSize: "18px"
7026
7770
  }
7771
+ })), showModal && /*#__PURE__*/React.createElement(AssignEkycModal, {
7772
+ surveyor: surveyor,
7773
+ closeModal: closeModal,
7774
+ refetchDashboard: refetchDashboard
7775
+ }));
7776
+ };
7777
+
7778
+ const vendors = [{
7779
+ id: 1,
7780
+ name: "Vendor Alpha",
7781
+ progress: 78,
7782
+ supervisors: 12,
7783
+ surveyors: 148,
7784
+ completed: 154200,
7785
+ pending: 43200,
7786
+ rejected: 3200
7787
+ }, {
7788
+ id: 2,
7789
+ name: "Vendor Beta",
7790
+ progress: 64,
7791
+ supervisors: 10,
7792
+ surveyors: 122,
7793
+ completed: 121000,
7794
+ pending: 68500,
7795
+ rejected: 2800
7796
+ }, {
7797
+ id: 3,
7798
+ name: "Vendor Gamma",
7799
+ progress: 91,
7800
+ supervisors: 15,
7801
+ surveyors: 182,
7802
+ completed: 201500,
7803
+ pending: 19800,
7804
+ rejected: 1800
7805
+ }];
7806
+ const zones = [{
7807
+ zone: "North Delhi",
7808
+ totalConnections: 220000,
7809
+ ekycDone: 172000,
7810
+ liveSurveyors: 58,
7811
+ todayCompleted: 2800
7812
+ }, {
7813
+ zone: "South Delhi",
7814
+ totalConnections: 198000,
7815
+ ekycDone: 154500,
7816
+ liveSurveyors: 42,
7817
+ todayCompleted: 2100
7818
+ }, {
7819
+ zone: "East Delhi",
7820
+ totalConnections: 175000,
7821
+ ekycDone: 132800,
7822
+ liveSurveyors: 37,
7823
+ todayCompleted: 1740
7824
+ }, {
7825
+ zone: "West Delhi",
7826
+ totalConnections: 212000,
7827
+ ekycDone: 188300,
7828
+ liveSurveyors: 48,
7829
+ todayCompleted: 2560
7830
+ }];
7831
+ const alerts = ["15 Surveyors inactive for more than 2 hours", "Vendor Beta completion dropped by 12% this week", "North Delhi has highest pending backlog", "2,843 eKYC applications rejected today"];
7832
+ const CeoDashboard$1 = () => {
7833
+ return /*#__PURE__*/React.createElement("div", {
7834
+ className: "ekyc-dashboard-wrapper"
7835
+ }, /*#__PURE__*/React.createElement("div", {
7836
+ className: "ceo-dashboard"
7837
+ }, /*#__PURE__*/React.createElement("main", {
7838
+ className: "main-content"
7839
+ }, /*#__PURE__*/React.createElement("div", {
7840
+ className: "kpi-grid"
7841
+ }, /*#__PURE__*/React.createElement("div", {
7842
+ className: "kpi-card primary"
7843
+ }, /*#__PURE__*/React.createElement("div", {
7844
+ className: "icon-box"
7845
+ }, /*#__PURE__*/React.createElement(FaUsers, null)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, "7,85,000"), /*#__PURE__*/React.createElement("p", null, "Total Water Connections"))), /*#__PURE__*/React.createElement("div", {
7846
+ className: "kpi-card success"
7847
+ }, /*#__PURE__*/React.createElement("div", {
7848
+ className: "icon-box"
7849
+ }, /*#__PURE__*/React.createElement(FaCheckCircle, null)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, "6,47,300"), /*#__PURE__*/React.createElement("p", null, "eKYC Completed"))), /*#__PURE__*/React.createElement("div", {
7850
+ className: "kpi-card warning"
7851
+ }, /*#__PURE__*/React.createElement("div", {
7852
+ className: "icon-box"
7853
+ }, /*#__PURE__*/React.createElement(FaClock, null)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, "1,31,500"), /*#__PURE__*/React.createElement("p", null, "Pending eKYC"))), /*#__PURE__*/React.createElement("div", {
7854
+ className: "kpi-card danger"
7855
+ }, /*#__PURE__*/React.createElement("div", {
7856
+ className: "icon-box"
7857
+ }, /*#__PURE__*/React.createElement(FaExclamationTriangle, null)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, "7,200"), /*#__PURE__*/React.createElement("p", null, "Rejected Applications")))), /*#__PURE__*/React.createElement("section", {
7858
+ className: "dashboard-section"
7859
+ }, /*#__PURE__*/React.createElement("div", {
7860
+ className: "section-header"
7861
+ }, /*#__PURE__*/React.createElement("h2", null, /*#__PURE__*/React.createElement(FaChartLine, null), " Vendor Performance Overview"), /*#__PURE__*/React.createElement("button", null, "View All")), /*#__PURE__*/React.createElement("div", {
7862
+ className: "vendor-grid"
7863
+ }, vendors.map(vendor => /*#__PURE__*/React.createElement("div", {
7864
+ className: "vendor-card",
7865
+ key: vendor.id
7027
7866
  }, /*#__PURE__*/React.createElement("div", {
7867
+ className: "vendor-top"
7868
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, vendor.name), /*#__PURE__*/React.createElement("p", null, "Jurisdiction Assigned Vendor")), /*#__PURE__*/React.createElement("span", null, vendor.progress, "%")), /*#__PURE__*/React.createElement("div", {
7869
+ className: "progress-bar"
7870
+ }, /*#__PURE__*/React.createElement("div", {
7871
+ className: "progress-fill",
7028
7872
  style: {
7029
- width: vendor.progress + "%",
7030
- height: "100%",
7031
- background: "linear-gradient(90deg, #3B82F6 0%, #10B981 100%)",
7032
- borderRadius: "999px"
7873
+ width: vendor.progress + "%"
7033
7874
  }
7034
7875
  })), /*#__PURE__*/React.createElement("div", {
7035
- style: {
7036
- display: "grid",
7037
- gridTemplateColumns: "repeat(3, 1fr)",
7038
- gap: "12px"
7039
- }
7876
+ className: "vendor-stats"
7877
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h4", null, vendor.supervisors), /*#__PURE__*/React.createElement("p", null, "Supervisors")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h4", null, vendor.surveyors), /*#__PURE__*/React.createElement("p", null, "Surveyors")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h4", null, vendor.completed), /*#__PURE__*/React.createElement("p", null, "Completed"))), /*#__PURE__*/React.createElement("div", {
7878
+ className: "vendor-footer"
7879
+ }, /*#__PURE__*/React.createElement("span", null, "Pending: ", vendor.pending), /*#__PURE__*/React.createElement("span", null, "Rejected: ", vendor.rejected)))))), /*#__PURE__*/React.createElement("section", {
7880
+ className: "dashboard-section"
7040
7881
  }, /*#__PURE__*/React.createElement("div", {
7041
- style: {
7042
- background: "#F8FAFC",
7043
- padding: "12px 8px",
7044
- borderRadius: "10px",
7045
- textAlign: "center"
7046
- }
7882
+ className: "section-header"
7883
+ }, /*#__PURE__*/React.createElement("h2", null, /*#__PURE__*/React.createElement(FaMapMarkedAlt, null), " Jurisdiction Monitoring"), /*#__PURE__*/React.createElement("button", null, "Export Data")), /*#__PURE__*/React.createElement("div", {
7884
+ className: "table-wrapper"
7885
+ }, /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Zone"), /*#__PURE__*/React.createElement("th", null, "Total Connections"), /*#__PURE__*/React.createElement("th", null, "eKYC Done"), /*#__PURE__*/React.createElement("th", null, "Live Surveyors"), /*#__PURE__*/React.createElement("th", null, "Today's Completion"), /*#__PURE__*/React.createElement("th", null, "Status"))), /*#__PURE__*/React.createElement("tbody", null, zones.map((item, index) => /*#__PURE__*/React.createElement("tr", {
7886
+ key: index
7887
+ }, /*#__PURE__*/React.createElement("td", null, item.zone), /*#__PURE__*/React.createElement("td", null, item.totalConnections), /*#__PURE__*/React.createElement("td", null, item.ekycDone), /*#__PURE__*/React.createElement("td", null, item.liveSurveyors), /*#__PURE__*/React.createElement("td", null, item.todayCompleted), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", {
7888
+ className: "status-badge success"
7889
+ }, "Active")))))))), /*#__PURE__*/React.createElement("div", {
7890
+ className: "bottom-grid"
7891
+ }, /*#__PURE__*/React.createElement("section", {
7892
+ className: "dashboard-section alerts-section"
7047
7893
  }, /*#__PURE__*/React.createElement("div", {
7048
- style: {
7049
- fontSize: "16px",
7050
- fontWeight: "700",
7051
- color: "#1E293B"
7052
- }
7053
- }, vendor.supervisors), /*#__PURE__*/React.createElement("div", {
7054
- style: {
7055
- fontSize: "10px",
7056
- fontWeight: "600",
7057
- color: "#64748B",
7058
- textTransform: "uppercase",
7059
- marginTop: "4px"
7060
- }
7061
- }, t("SUPERVISORS") || "Supervisors")), /*#__PURE__*/React.createElement("div", {
7062
- style: {
7063
- background: "#F8FAFC",
7064
- padding: "12px 8px",
7065
- borderRadius: "10px",
7066
- textAlign: "center"
7067
- }
7894
+ className: "section-header"
7895
+ }, /*#__PURE__*/React.createElement("h2", null, /*#__PURE__*/React.createElement(FaExclamationTriangle, null), " Critical Alerts")), /*#__PURE__*/React.createElement("div", {
7896
+ className: "alerts-list"
7897
+ }, alerts.map((alert, index) => /*#__PURE__*/React.createElement("div", {
7898
+ className: "alert-card",
7899
+ key: index
7900
+ }, /*#__PURE__*/React.createElement(FaExclamationTriangle, null), /*#__PURE__*/React.createElement("p", null, alert))))), /*#__PURE__*/React.createElement("section", {
7901
+ className: "dashboard-section team-section"
7068
7902
  }, /*#__PURE__*/React.createElement("div", {
7069
- style: {
7070
- fontSize: "16px",
7071
- fontWeight: "700",
7072
- color: "#1E293B"
7073
- }
7074
- }, vendor.surveyors), /*#__PURE__*/React.createElement("div", {
7075
- style: {
7076
- fontSize: "10px",
7077
- fontWeight: "600",
7078
- color: "#64748B",
7079
- textTransform: "uppercase",
7080
- marginTop: "4px"
7081
- }
7082
- }, t("SURVEYORS") || "Surveyors")), /*#__PURE__*/React.createElement("div", {
7083
- style: {
7084
- background: "#F8FAFC",
7085
- padding: "12px 8px",
7086
- borderRadius: "10px",
7087
- textAlign: "center"
7088
- }
7903
+ className: "section-header"
7904
+ }, /*#__PURE__*/React.createElement("h2", null, /*#__PURE__*/React.createElement(FaUserTie, null), " Workforce Monitoring")), /*#__PURE__*/React.createElement("div", {
7905
+ className: "team-stats-grid"
7089
7906
  }, /*#__PURE__*/React.createElement("div", {
7090
- style: {
7091
- fontSize: "16px",
7092
- fontWeight: "700",
7093
- color: "#10B981"
7094
- }
7095
- }, vendor.completed), /*#__PURE__*/React.createElement("div", {
7096
- style: {
7097
- fontSize: "10px",
7098
- fontWeight: "600",
7099
- color: "#64748B",
7100
- textTransform: "uppercase",
7101
- marginTop: "4px"
7102
- }
7103
- }, t("COMPLETED") || "Completed"))), /*#__PURE__*/React.createElement("div", {
7104
- style: {
7105
- display: "flex",
7106
- justifyContent: "space-between",
7107
- fontSize: "12px",
7108
- color: "#64748B",
7109
- borderTop: "1px solid #F1F5F9",
7110
- paddingTop: "12px"
7111
- }
7112
- }, /*#__PURE__*/React.createElement("span", null, t("PENDING") || "Pending", ": ", /*#__PURE__*/React.createElement("span", {
7113
- style: {
7114
- fontWeight: "700",
7115
- color: "#F59E0B"
7116
- }
7117
- }, vendor.pending)), /*#__PURE__*/React.createElement("span", null, t("REJECTED") || "Rejected", ": ", /*#__PURE__*/React.createElement("span", {
7118
- style: {
7119
- fontWeight: "700",
7120
- color: "#EF4444"
7121
- }
7122
- }, vendor.rejected))))))));
7907
+ className: "team-box"
7908
+ }, /*#__PURE__*/React.createElement("h3", null, "37"), /*#__PURE__*/React.createElement("p", null, "Total Supervisors Online")), /*#__PURE__*/React.createElement("div", {
7909
+ className: "team-box"
7910
+ }, /*#__PURE__*/React.createElement("h3", null, "154"), /*#__PURE__*/React.createElement("p", null, "Surveyors Active")), /*#__PURE__*/React.createElement("div", {
7911
+ className: "team-box"
7912
+ }, /*#__PURE__*/React.createElement("h3", null, "12,430"), /*#__PURE__*/React.createElement("p", null, "Today's eKYC Completed")), /*#__PURE__*/React.createElement("div", {
7913
+ className: "team-box"
7914
+ }, /*#__PURE__*/React.createElement("h3", null, "92%"), /*#__PURE__*/React.createElement("p", null, "Operational Efficiency"))))))));
7123
7915
  };
7124
7916
 
7917
+ const breadcrumb = (userType, listLabel, listPath, detailLabel) => [{
7918
+ label: listLabel,
7919
+ path: "/digit-ui/" + userType + "/ekyc/" + listPath
7920
+ }, {
7921
+ label: detailLabel
7922
+ }];
7923
+ const getEkycRoutes = userType => [{
7924
+ path: "/dashboard",
7925
+ component: Dashboard,
7926
+ layout: "normal",
7927
+ breadcrumb: "EKYC_DASHBOARD"
7928
+ }, {
7929
+ path: "/inbox",
7930
+ component: Inbox,
7931
+ layout: "normal",
7932
+ breadcrumb: "EKYC_INBOX"
7933
+ }, {
7934
+ path: "/review/:kno",
7935
+ component: Review,
7936
+ layout: "normal",
7937
+ breadcrumb: "EKYC_REVIEW"
7938
+ }, {
7939
+ path: "/create-kyc",
7940
+ component: Create,
7941
+ layout: "normal",
7942
+ breadcrumb: "EKYC_CREATE_KYC"
7943
+ }, {
7944
+ path: "/mapping",
7945
+ component: Mapping,
7946
+ layout: "normal",
7947
+ breadcrumb: "EKYC_MAPPING"
7948
+ }, {
7949
+ path: "/admin-dashboard",
7950
+ component: AdminDashboard,
7951
+ layout: "normal",
7952
+ breadcrumb: "EKYC_ADMIN_DASHBOARD"
7953
+ }, {
7954
+ path: "/ceo-dashboard",
7955
+ component: CeoDashboard$1,
7956
+ layout: "normal",
7957
+ breadcrumb: "CEO_M.F_DOR_FINANCE_VIEW"
7958
+ }, {
7959
+ path: "/consumer-details",
7960
+ component: EKYCForm,
7961
+ layout: "normal",
7962
+ breadcrumb: "EKYC_CONSUMER_DETAILS"
7963
+ }, {
7964
+ path: "/address-details",
7965
+ component: EKYCForm,
7966
+ layout: "normal",
7967
+ breadcrumb: "EKYC_ADDRESS_DETAILS"
7968
+ }, {
7969
+ path: "/property-info",
7970
+ component: EKYCForm,
7971
+ layout: "normal",
7972
+ breadcrumb: "EKYC_PROPERTY_INFO"
7973
+ }, {
7974
+ path: "/meter-details",
7975
+ component: EKYCForm,
7976
+ layout: "normal",
7977
+ breadcrumb: "EKYC_METER_DETAILS"
7978
+ }, {
7979
+ path: ["/assign"],
7980
+ component: AssignEkyc,
7981
+ layout: "normal",
7982
+ breadcrumb: [{
7983
+ label: "EKYC_ASSIGN",
7984
+ path: "/digit-ui/" + userType + "/ekyc/assign"
7985
+ }]
7986
+ }, {
7987
+ path: ["/vendors/:vendorId", "/vendors"],
7988
+ component: VendorDetailsCard,
7989
+ layout: "normal",
7990
+ breadcrumb: breadcrumb(userType, "EKYC_VENDORS", "vendors:vendorId", "EKYC_VENDOR_DETAILS")
7991
+ }, {
7992
+ path: ["/supervisor-dashboard/:id", "/supervisor-dashboard"],
7993
+ component: SupervisorDetailsCard,
7994
+ layout: "action",
7995
+ breadcrumb: breadcrumb(userType, "EKYC_SUPERVISOR_DASHBOARD", "supervisor-dashboard:id", "EKYC_SUPERVISOR_DETAILS")
7996
+ }, {
7997
+ path: ["/surveyor-dashboard/:id", "/surveyor-dashboard"],
7998
+ component: SurveyorDetailsDashboard,
7999
+ layout: "action",
8000
+ breadcrumb: breadcrumb(userType, "EKYC_SURVEYOR_DASHBOARD", "surveyor-dashboard/:id", "EKYC_SURVEYOR_DETAILS")
8001
+ }];
8002
+ const ekycRoutes = getEkycRoutes("employee");
8003
+
7125
8004
  const EmployeeApp = _ref => {
7126
8005
  let path = _ref.path;
7127
8006
  const _useTranslation = useTranslation(),
@@ -7129,7 +8008,6 @@ const EmployeeApp = _ref => {
7129
8008
  const location = useLocation();
7130
8009
  sessionStorage.removeItem("revalidateddone");
7131
8010
  const getDynamicBreadcrumbs = () => {
7132
- const pathname = location.pathname;
7133
8011
  const crumbs = [{
7134
8012
  icon: HomeIcon,
7135
8013
  path: "/digit-ui/employee"
@@ -7137,70 +8015,44 @@ const EmployeeApp = _ref => {
7137
8015
  label: t("ACTION_TEST_EKYC"),
7138
8016
  path: "/digit-ui/employee/module/details"
7139
8017
  }];
7140
- if (pathname.includes("/create-kyc")) {
7141
- crumbs.push({
7142
- label: t("EKYC_CREATE_KYC")
7143
- });
7144
- } else if (pathname.includes("/consumer-details")) {
7145
- crumbs.push({
7146
- label: t("EKYC_CONSUMER_DETAILS")
7147
- });
7148
- } else if (pathname.includes("/address-details")) {
7149
- crumbs.push({
7150
- label: t("EKYC_ADDRESS_DETAILS")
7151
- });
7152
- } else if (pathname.includes("/property-info")) {
7153
- crumbs.push({
7154
- label: t("EKYC_PROPERTY_INFO")
7155
- });
7156
- } else if (pathname.includes("/meter-details")) {
7157
- crumbs.push({
7158
- label: t("EKYC_METER_DETAILS")
7159
- });
7160
- } else if (pathname.includes("/review")) {
7161
- crumbs.push({
7162
- label: t("EKYC_INBOX"),
7163
- path: "/digit-ui/employee/ekyc/inbox"
7164
- });
7165
- crumbs.push({
7166
- label: t("EKYC_REVIEW")
7167
- });
7168
- } else if (pathname.includes("/assign/surveyor-details")) {
7169
- crumbs.push({
7170
- label: t("EKYC_ASSIGN"),
7171
- path: "/digit-ui/employee/ekyc/assign"
7172
- });
7173
- crumbs.push({
7174
- label: t("EKYC_SURVEYOR_DETAILS")
7175
- });
7176
- } else if (pathname.includes("/assign")) {
7177
- crumbs.push({
7178
- label: t("EKYC_ASSIGN")
7179
- });
7180
- } else if (pathname.includes("/ceo-dashboard")) {
7181
- crumbs.push({
7182
- label: t("CEO_M.F_DOR_FINANCE_VIEW")
7183
- });
7184
- } else if (pathname.includes("/admin-dashboard")) {
7185
- crumbs.push({
7186
- label: t("EKYC_ADMIN_DASHBOARD") || "Admin Dashboard"
7187
- });
7188
- } else if (pathname.includes("/vendors/")) {
7189
- crumbs.push({
7190
- label: t("EKYC_VENDOR_DETAILS")
7191
- });
7192
- } else if (pathname.includes("/mapping")) {
7193
- crumbs.push({
7194
- label: t("EKYC_MAPPING")
7195
- });
7196
- } else if (pathname.includes("/dashboard")) {
7197
- crumbs.push({
7198
- label: t("EKYC_DASHBOARD")
7199
- });
7200
- } else if (pathname.includes("/inbox")) {
7201
- crumbs.push({
7202
- label: t("EKYC_INBOX")
8018
+ const pathSegments = location.pathname.split("/").filter(Boolean);
8019
+ const ekycIndex = pathSegments.indexOf("ekyc");
8020
+ const relativeSegments = ekycIndex !== -1 ? pathSegments.slice(ekycIndex + 1) : [];
8021
+ let matchedPath = "";
8022
+ const currentRoute = ekycRoutes.find(route => {
8023
+ const paths = Array.isArray(route.path) ? route.path : [route.path];
8024
+ return paths.some(singlePath => {
8025
+ const routeSegments = singlePath.split("/").filter(Boolean);
8026
+ if (routeSegments.length === relativeSegments.length && routeSegments.every((seg, i) => seg.startsWith(":") || seg === relativeSegments[i])) {
8027
+ matchedPath = singlePath;
8028
+ return true;
8029
+ }
8030
+ return false;
7203
8031
  });
8032
+ });
8033
+ if (currentRoute) {
8034
+ if (Array.isArray(currentRoute.breadcrumb)) {
8035
+ currentRoute.breadcrumb.forEach(crumb => {
8036
+ let crumbPath = crumb.path;
8037
+ if (crumbPath && matchedPath) {
8038
+ matchedPath.split("/").filter(Boolean).forEach((segment, idx) => {
8039
+ if (segment.startsWith(":")) {
8040
+ const val = relativeSegments[idx];
8041
+ crumbPath = crumbPath.replace(new RegExp("\\/" + segment, "g"), "/" + val).replace(new RegExp("(\\w+)" + segment, "g"), "$1/" + val).replace(new RegExp(segment, "g"), val);
8042
+ }
8043
+ });
8044
+ }
8045
+ crumbs.push(_extends({
8046
+ label: t(crumb.label)
8047
+ }, crumbPath ? {
8048
+ path: crumbPath
8049
+ } : {}));
8050
+ });
8051
+ } else {
8052
+ crumbs.push({
8053
+ label: t(currentRoute.breadcrumb)
8054
+ });
8055
+ }
7204
8056
  }
7205
8057
  return crumbs;
7206
8058
  };
@@ -7245,12 +8097,6 @@ const EmployeeApp = _ref => {
7245
8097
  component: () => /*#__PURE__*/React.createElement(LayoutWrapper, {
7246
8098
  layoutClass: "normal"
7247
8099
  }, /*#__PURE__*/React.createElement(Mapping, null))
7248
- }), /*#__PURE__*/React.createElement(PrivateRoute, {
7249
- path: path + "/assign",
7250
- exact: true,
7251
- component: () => /*#__PURE__*/React.createElement(LayoutWrapper, {
7252
- layoutClass: "normal"
7253
- }, /*#__PURE__*/React.createElement(AssignEkyc, null))
7254
8100
  }), /*#__PURE__*/React.createElement(PrivateRoute, {
7255
8101
  path: path + "/assign/surveyor-details/:id",
7256
8102
  exact: true,
@@ -7284,6 +8130,16 @@ const EmployeeApp = _ref => {
7284
8130
  component: () => /*#__PURE__*/React.createElement(LayoutWrapper, {
7285
8131
  layoutClass: "normal"
7286
8132
  }, /*#__PURE__*/React.createElement(VendorDetailsCard, null))
8133
+ }), /*#__PURE__*/React.createElement(PrivateRoute, {
8134
+ path: [path + "/supervisor-dashboard/:id", path + "/supervisor-dashboard"],
8135
+ component: () => /*#__PURE__*/React.createElement(LayoutWrapper, {
8136
+ layoutClass: "normal"
8137
+ }, /*#__PURE__*/React.createElement(SupervisorDetailsCard, null))
8138
+ }), /*#__PURE__*/React.createElement(PrivateRoute, {
8139
+ path: [path + "/surveyor-dashboard/:id", path + "/surveyor-dashboard"],
8140
+ component: () => /*#__PURE__*/React.createElement(LayoutWrapper, {
8141
+ layoutClass: "normal"
8142
+ }, /*#__PURE__*/React.createElement(SurveyorDetailsDashboard, null))
7287
8143
  })))));
7288
8144
  };
7289
8145
 
@@ -8328,20 +9184,17 @@ const Home = () => {
8328
9184
  }
8329
9185
  if (roles.includes("EKYC_SUPERVISOR") || roles.includes("EKYC_VENDOR")) {
8330
9186
  propsForModuleCard.links.push({
8331
- label: t("EKYC_DASHBOARD"),
8332
- link: "/digit-ui/citizen/ekyc/dashboard"
8333
- }, {
8334
9187
  label: t("EKYC_INBOX"),
8335
9188
  link: "/digit-ui/citizen/ekyc/inbox"
8336
- }, {
8337
- label: t("EKYC_ASSIGN"),
8338
- link: "/digit-ui/citizen/ekyc/assign"
8339
9189
  });
8340
9190
  }
8341
9191
  if (roles.includes("EKYC_SUPERVISOR")) {
8342
9192
  propsForModuleCard.links.push({
8343
9193
  label: t("EKYC_SUPERVISOR_DASHBOARD"),
8344
9194
  link: "/digit-ui/citizen/ekyc/supervisor-dashboard"
9195
+ }, {
9196
+ label: t("EKYC_ASSIGN"),
9197
+ link: "/digit-ui/citizen/ekyc/assign"
8345
9198
  });
8346
9199
  }
8347
9200
  if (roles.includes("EKYC_VENDOR")) {
@@ -8546,470 +9399,97 @@ const Inbox$1 = _ref => {
8546
9399
  });
8547
9400
  case "mutateTableForm":
8548
9401
  Digit.SessionStorage.set(storageKey, _extends({}, state, {
8549
- tableForm: payload.data
8550
- }));
8551
- return _extends({}, state, {
8552
- tableForm: payload.data
8553
- });
8554
- default:
8555
- return state;
8556
- }
8557
- }
8558
- const onPageSizeChange = e => {
8559
- const newLimit = Number(e.target.value);
8560
- dispatch({
8561
- action: "mutateTableForm",
8562
- data: _extends({}, formState.tableForm, {
8563
- limit: newLimit,
8564
- offset: 0
8565
- }),
8566
- checkPathName
8567
- });
8568
- };
8569
- const onSortingByData = e => {
8570
- if (e.length > 0) {
8571
- const _e$ = e[0],
8572
- id = _e$.id,
8573
- desc = _e$.desc;
8574
- const sortOrder = desc ? "DESC" : "ASC";
8575
- const sortBy = id;
8576
- if (!(formState.tableForm.sortBy === sortBy && formState.tableForm.sortOrder === sortOrder)) {
8577
- dispatch({
8578
- action: "mutateTableForm",
8579
- data: _extends({}, formState.tableForm, {
8580
- sortBy: id,
8581
- sortOrder: desc ? "DESC" : "ASC"
8582
- }),
8583
- checkPathName
8584
- });
8585
- }
8586
- }
8587
- };
8588
- const propsForInboxTable = useInboxTableConfig(_extends({}, {
8589
- parentRoute,
8590
- onPageSizeChange,
8591
- formState,
8592
- totalCount: totalRecords,
8593
- table: filteredData,
8594
- dispatch,
8595
- onSortingByData,
8596
- tenantId,
8597
- checkPathName,
8598
- inboxStyles: {
8599
- overflowX: "scroll",
8600
- overflowY: "hidden"
8601
- },
8602
- tableStyle: {
8603
- width: "70%"
8604
- }
8605
- }));
8606
- const isInboxLoading = isLoading || isSearchLoading;
8607
- return /*#__PURE__*/React.createElement("div", {
8608
- className: "app-container"
8609
- }, /*#__PURE__*/React.createElement(InboxComposer, _extends({
8610
- isInboxLoading
8611
- }, propsForSearchForm, {
8612
- propsForInboxTable,
8613
- formState
8614
- })));
8615
- };
8616
-
8617
- const SupervisorDetailsCard = () => {
8618
- var _Digit$SessionStorage, _fullName$charAt;
8619
- const _useTranslation = useTranslation(),
8620
- t = _useTranslation.t;
8621
- const tenantId = Digit.ULBService.getCurrentTenantId() || "dl.djb";
8622
- const _useParams = useParams(),
8623
- supervisorId = _useParams.id;
8624
- const loggedInUser = (_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : _Digit$SessionStorage.info;
8625
- const _useState = useState(false),
8626
- ekycDownloadLoading = _useState[0],
8627
- setEkycDownloadLoading = _useState[1];
8628
- const _Digit$Hooks$ekyc$use = Digit.Hooks.ekyc.useEkycAssignmentProgress({
8629
- enabled: !!tenantId,
8630
- keepPreviousData: true
8631
- }),
8632
- isProgressLoading = _Digit$Hooks$ekyc$use.isLoading,
8633
- progressData = _Digit$Hooks$ekyc$use.data;
8634
- const supervisor = useMemo(() => {
8635
- if (!(progressData !== null && progressData !== void 0 && progressData.supervisorReport)) return null;
8636
- if (supervisorId) {
8637
- return progressData.supervisorReport.find(s => s.supervisorId === supervisorId) || progressData.supervisorReport[0];
8638
- }
8639
- const userUuid = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uuid;
8640
- if (userUuid) {
8641
- return progressData.supervisorReport.find(s => s.supervisorId === userUuid) || progressData.supervisorReport[0];
8642
- }
8643
- return progressData.supervisorReport[0];
8644
- }, [progressData, supervisorId, loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uuid]);
8645
- const fullName = (supervisor === null || supervisor === void 0 ? void 0 : supervisor.supervisorName) || (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.name) || "N/A";
8646
- const mobileNumber = (supervisor === null || supervisor === void 0 ? void 0 : supervisor.mobileNo) || (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.mobileNumber) || "N/A";
8647
- const email = (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.emailId) || "N/A";
8648
- const gender = (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.gender) || "N/A";
8649
- const status = supervisor ? "ACTIVE" : "N/A";
8650
- const assignedZone = (supervisor === null || supervisor === void 0 ? void 0 : supervisor.assignedZoneId) || "N/A";
8651
- const vendorName = "N/A";
8652
- const surveyors = useMemo(() => {
8653
- return (supervisor === null || supervisor === void 0 ? void 0 : supervisor.surveyors) || [];
8654
- }, [supervisor]);
8655
- const _useState2 = useState(0),
8656
- currentPage = _useState2[0],
8657
- setCurrentPage = _useState2[1];
8658
- const _useState3 = useState(20),
8659
- pageSize = _useState3[0],
8660
- setPageSize = _useState3[1];
8661
- const paginatedSurveyors = useMemo(() => {
8662
- const start = currentPage * pageSize;
8663
- const end = start + pageSize;
8664
- return surveyors.slice(start, end);
8665
- }, [surveyors, currentPage, pageSize]);
8666
- const surveyorColumns = useMemo(() => [{
8667
- Header: t("SURVEYOR_NAME") || "Surveyor Name",
8668
- accessor: row => (row === null || row === void 0 ? void 0 : row.surveyorName) || "N/A",
8669
- Cell: _ref => {
8670
- var _row$original;
8671
- let row = _ref.row;
8672
- return /*#__PURE__*/React.createElement("a", {
8673
- href: "/digit-ui/citizen/ekyc/surveyor-dashboard/" + row.original.surveyorId,
8674
- style: {
8675
- color: "#1D70B8",
8676
- fontWeight: "600",
8677
- textDecoration: "none"
8678
- }
8679
- }, ((_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original.surveyorName) || "N/A");
8680
- }
8681
- }, {
8682
- Header: t("MOBILE_NUMBER") || "Mobile Number",
8683
- accessor: row => (row === null || row === void 0 ? void 0 : row.mobileNo) || "N/A",
8684
- id: "mobileNumber"
8685
- }, {
8686
- Header: t("STATUS") || "Status",
8687
- accessor: () => "ACTIVE",
8688
- id: "status",
8689
- Cell: _ref2 => {
8690
- let value = _ref2.value;
8691
- return /*#__PURE__*/React.createElement("span", {
8692
- className: "status-badge verified"
8693
- }, t(value) || value);
8694
- }
8695
- }, {
8696
- Header: t("TOTAL_EKYC_APPLICATIONS") || "Total eKYC Applications",
8697
- accessor: row => (row === null || row === void 0 ? void 0 : row.totalKnos) || 0,
8698
- id: "totalEkycApplications"
8699
- }, {
8700
- Header: t("EKYC_COMPLETED") || "eKYC Completed",
8701
- accessor: row => (row === null || row === void 0 ? void 0 : row.submittedKnos) || 0,
8702
- id: "ekycCompleted"
8703
- }, {
8704
- Header: t("PENDING_APPLICATIONS") || "Pending Applications",
8705
- accessor: row => (row === null || row === void 0 ? void 0 : row.pendingKnos) || 0,
8706
- id: "pendingApplications"
8707
- }, {
8708
- Header: t("OVERALL_PROGRESS") || "Overall Progress",
8709
- accessor: row => ((row === null || row === void 0 ? void 0 : row.progressPercent) || 0) + "%",
8710
- id: "overallProgress"
8711
- }], [t]);
8712
- const _useState4 = useState(false),
8713
- showReportMenu = _useState4[0],
8714
- setShowReportMenu = _useState4[1];
8715
- const _useState5 = useState({
8716
- from: "",
8717
- to: ""
8718
- }),
8719
- customDate = _useState5[0],
8720
- setCustomDate = _useState5[1];
8721
- const _useState6 = useState(false),
8722
- showCustomPicker = _useState6[0],
8723
- setShowCustomPicker = _useState6[1];
8724
- const _useState7 = useState(false),
8725
- reportLoading = _useState7[0];
8726
- const reportMenuRef = useRef(null);
8727
- useEffect(() => {
8728
- const handler = e => {
8729
- if (reportMenuRef.current && !reportMenuRef.current.contains(e.target)) {
8730
- setShowReportMenu(false);
8731
- setShowCustomPicker(false);
8732
- }
8733
- };
8734
- document.addEventListener("mousedown", handler);
8735
- return () => document.removeEventListener("mousedown", handler);
8736
- }, []);
8737
- const handlePresetDownload = filter => {
8738
- handleDownload();
8739
- };
8740
- const handleCustomDownload = () => {
8741
- if (!customDate.from || !customDate.to) {
8742
- alert(t("SELECT_DATE_RANGE") || "Please select both From and To dates.");
8743
- return;
8744
- }
8745
- handleDownload();
8746
- };
8747
- const handleDownloadEkycData = function () {
8748
- try {
8749
- if (!surveyors || surveyors.length === 0) {
8750
- alert(t("NO_SURVEYORS_ASSIGNED") || "No surveyors assigned to this supervisor.");
8751
- return Promise.resolve();
8752
- }
8753
- setEkycDownloadLoading(true);
8754
- return Promise.resolve(_finallyRethrows(function () {
8755
- return _catch(function () {
8756
- const fetchPromises = surveyors.map(s => Digit.EkycService.application_list({
8757
- tenantId: tenantId || "dl.djb",
8758
- offset: 0,
8759
- limit: 5000,
8760
- surveyorId: s.surveyorId || s.id,
8761
- reportDownload: true
8762
- }).catch(err => {
8763
- console.error("Error fetching applications for surveyor " + s.surveyorName + ":", err);
8764
- return {
8765
- consumerList: []
8766
- };
8767
- }));
8768
- return Promise.resolve(Promise.all(fetchPromises)).then(function (results) {
8769
- const consumerList = results.flatMap(res => (res === null || res === void 0 ? void 0 : res.consumerList) || []);
8770
- if (consumerList.length === 0) {
8771
- alert(t("NO_DATA_FOUND") || "No data found for download.");
8772
- return;
8773
- }
8774
- const excludedKeys = ["status", "source", "submittedAt", "assignedAt", "connectionType", "approvedAt", "alternateMobileNo", "city", "state", "addressType", "addressProofType", "mrcode", "areacode", "verificationStatus", "surveyorId", "supervisorId", "vendorId", "assignmentType", "assignmentValue", "assignedTime", "isSelfAssigned", "userType", "tenantName", "tenantMobile"];
8775
- const headerMapping = {
8776
- kno: t("KNO") || "KNO",
8777
- firstName: t("FIRST_NAME") || "First Name",
8778
- middleName: t("MIDDLE_NAME") || "Middle Name",
8779
- lastName: t("LAST_NAME") || "Last Name",
8780
- gender: t("GENDER") || "Gender",
8781
- mobileNumber: t("MOBILE_NUMBER") || "Mobile Number",
8782
- emailId: t("EMAIL_ID") || "Email ID",
8783
- fatherOrHusbandName: t("FATHER_HUSBUND_NAME") || "Father/Husband Name",
8784
- relationship: t("RELATIONSHIP") || "Relationship",
8785
- dob: t("DOB") || "Date of Birth",
8786
- ekycStatus: t("EKYC_STATUS") || "eKYC Status",
8787
- zoneName: t("ZONE") || "Zone",
8788
- assembly: t("ASSEMBLY") || "Assembly",
8789
- ward: t("WARD") || "Ward",
8790
- pincode: t("PINCODE") || "Pincode",
8791
- mrkey: t("MR_KEY") || "MR Key",
8792
- createdTime: t("CREATED_TIME") || "Created Time",
8793
- lastModifiedTime: t("LAST_MODIFIED_TIME") || "Last Modified Time"
8794
- };
8795
- const excelData = consumerList.map(item => {
8796
- const cleanObj = {};
8797
- const fullName = [item.firstName, item.middleName, item.lastName].filter(Boolean).join(" ");
8798
- if (fullName) {
8799
- cleanObj[t("CONSUMER_NAME") || "Consumer Name"] = fullName;
8800
- }
8801
- Object.keys(item).forEach(key => {
8802
- if (excludedKeys.includes(key)) return;
8803
- const val = item[key];
8804
- if (typeof val === "object" && val !== null) {
8805
- return;
8806
- }
8807
- const friendlyHeader = headerMapping[key] || t(key.toUpperCase()) || key;
8808
- cleanObj[friendlyHeader] = val;
8809
- });
8810
- return cleanObj;
8811
- });
8812
- const cleanFileName = "eKYC_Data_Supervisor_" + fullName.replace(/[^a-zA-Z0-9]/g, "_");
8813
- Digit.Download.Excel(excelData, cleanFileName);
8814
- });
8815
- }, function (error) {
8816
- console.error("Error downloading eKYC Excel:", error);
9402
+ tableForm: payload.data
9403
+ }));
9404
+ return _extends({}, state, {
9405
+ tableForm: payload.data
8817
9406
  });
8818
- }, function (_wasThrown, _result) {
8819
- setEkycDownloadLoading(false);
8820
- if (_wasThrown) throw _result;
8821
- return _result;
8822
- }));
8823
- } catch (e) {
8824
- return Promise.reject(e);
9407
+ default:
9408
+ return state;
8825
9409
  }
8826
- };
8827
- if (isProgressLoading) {
8828
- return /*#__PURE__*/React.createElement(Loader, null);
8829
9410
  }
8830
- if (!supervisor) {
8831
- return /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement("div", {
8832
- style: {
8833
- padding: "24px"
9411
+ const onPageSizeChange = e => {
9412
+ const newLimit = Number(e.target.value);
9413
+ dispatch({
9414
+ action: "mutateTableForm",
9415
+ data: _extends({}, formState.tableForm, {
9416
+ limit: newLimit,
9417
+ offset: 0
9418
+ }),
9419
+ checkPathName
9420
+ });
9421
+ };
9422
+ const onSortingByData = e => {
9423
+ if (e.length > 0) {
9424
+ const _e$ = e[0],
9425
+ id = _e$.id,
9426
+ desc = _e$.desc;
9427
+ const sortOrder = desc ? "DESC" : "ASC";
9428
+ const sortBy = id;
9429
+ if (!(formState.tableForm.sortBy === sortBy && formState.tableForm.sortOrder === sortOrder)) {
9430
+ dispatch({
9431
+ action: "mutateTableForm",
9432
+ data: _extends({}, formState.tableForm, {
9433
+ sortBy: id,
9434
+ sortOrder: desc ? "DESC" : "ASC"
9435
+ }),
9436
+ checkPathName
9437
+ });
8834
9438
  }
8835
- }, t("NO_SUPERVISOR_FOUND")));
8836
- }
8837
- return /*#__PURE__*/React.createElement(Card, {
8838
- className: "surveyor-dashboard"
8839
- }, /*#__PURE__*/React.createElement("div", {
8840
- className: "ekyc-dashboard-section"
8841
- }, /*#__PURE__*/React.createElement("div", {
8842
- className: "ekyc-dashboard-header"
8843
- }, /*#__PURE__*/React.createElement("div", {
8844
- className: "avatar"
8845
- }, fullName === null || fullName === void 0 ? void 0 : (_fullName$charAt = fullName.charAt(0)) === null || _fullName$charAt === void 0 ? void 0 : _fullName$charAt.toUpperCase()), /*#__PURE__*/React.createElement("div", {
8846
- className: "header-content"
8847
- }, /*#__PURE__*/React.createElement("h2", {
8848
- className: "name"
8849
- }, fullName), /*#__PURE__*/React.createElement("div", {
8850
- className: "designation"
8851
- }, t("FIELD_SUPERVISOR") || "Field Supervisor"))), /*#__PURE__*/React.createElement("div", {
8852
- className: "report-download",
8853
- ref: reportMenuRef
8854
- }, /*#__PURE__*/React.createElement("button", {
8855
- className: "download-btn",
8856
- disabled: reportLoading,
8857
- onClick: () => {
8858
- setShowReportMenu(p => !p);
8859
- setShowCustomPicker(false);
8860
9439
  }
8861
- }, reportLoading ? t("DOWNLOADING") || "Downloading..." : t("DOWNLOAD_REPORT") || "Download Report"), showReportMenu && /*#__PURE__*/React.createElement("div", {
8862
- className: "report-menu"
8863
- }, [{
8864
- label: t("TODAY") || "Today",
8865
- key: "today"
8866
- }, {
8867
- label: t("THIS_WEEK") || "This Week",
8868
- key: "week"
8869
- }, {
8870
- label: t("THIS_MONTH") || "This Month",
8871
- key: "month"
8872
- }].map(_ref3 => {
8873
- let label = _ref3.label,
8874
- key = _ref3.key;
8875
- return /*#__PURE__*/React.createElement("div", {
8876
- key: key,
8877
- className: "menu-item",
8878
- onClick: () => handlePresetDownload()
8879
- }, label);
8880
- }), /*#__PURE__*/React.createElement("div", {
8881
- className: "custom-date-trigger",
8882
- onClick: () => setShowCustomPicker(p => !p)
8883
- }, t("CUSTOM_DATE") || "Custom Date"), showCustomPicker && /*#__PURE__*/React.createElement("div", {
8884
- className: "custom-picker"
8885
- }, /*#__PURE__*/React.createElement("div", {
8886
- className: "date-field"
8887
- }, /*#__PURE__*/React.createElement("label", {
8888
- className: "date-label"
8889
- }, t("FROM_DATE") || "From"), /*#__PURE__*/React.createElement("input", {
8890
- type: "date",
8891
- className: "date-input",
8892
- value: customDate.from,
8893
- onChange: e => setCustomDate(d => _extends({}, d, {
8894
- from: e.target.value
8895
- }))
8896
- })), /*#__PURE__*/React.createElement("div", {
8897
- className: "date-field"
8898
- }, /*#__PURE__*/React.createElement("label", {
8899
- className: "date-label"
8900
- }, t("TO_DATE") || "To"), /*#__PURE__*/React.createElement("input", {
8901
- type: "date",
8902
- className: "date-input",
8903
- value: customDate.to,
8904
- onChange: e => setCustomDate(d => _extends({}, d, {
8905
- to: e.target.value
8906
- }))
8907
- })), /*#__PURE__*/React.createElement("button", {
8908
- className: "download-action-btn",
8909
- onClick: handleCustomDownload
8910
- }, t("DOWNLOAD") || "Download"))))), /*#__PURE__*/React.createElement("div", {
8911
- className: "ekyc-dashboard-section"
8912
- }, /*#__PURE__*/React.createElement("div", {
8913
- className: "ekyc-details-wrapper"
8914
- }, /*#__PURE__*/React.createElement("div", {
8915
- className: "details-left"
8916
- }, /*#__PURE__*/React.createElement("div", {
8917
- className: "details-grid"
8918
- }, /*#__PURE__*/React.createElement("div", {
8919
- className: "detail-item"
8920
- }, /*#__PURE__*/React.createElement("span", {
8921
- className: "label"
8922
- }, t("MOBILE")), /*#__PURE__*/React.createElement("span", {
8923
- className: "value"
8924
- }, mobileNumber)), /*#__PURE__*/React.createElement("div", {
8925
- className: "detail-item"
8926
- }, /*#__PURE__*/React.createElement("span", {
8927
- className: "label"
8928
- }, t("EMAIL")), /*#__PURE__*/React.createElement("span", {
8929
- className: "value"
8930
- }, email)), /*#__PURE__*/React.createElement("div", {
8931
- className: "detail-item"
8932
- }, /*#__PURE__*/React.createElement("span", {
8933
- className: "label"
8934
- }, t("GENDER")), /*#__PURE__*/React.createElement("span", {
8935
- className: "value"
8936
- }, gender)), /*#__PURE__*/React.createElement("div", {
8937
- className: "detail-item"
8938
- }, /*#__PURE__*/React.createElement("span", {
8939
- className: "label"
8940
- }, t("STATUS")), /*#__PURE__*/React.createElement("span", {
8941
- className: "value"
8942
- }, status)), /*#__PURE__*/React.createElement("div", {
8943
- className: "detail-item"
8944
- }, /*#__PURE__*/React.createElement("span", {
8945
- className: "label"
8946
- }, t("ASSIGNED_ZONE") || "Assigned Zone"), /*#__PURE__*/React.createElement("span", {
8947
- className: "value"
8948
- }, assignedZone)), /*#__PURE__*/React.createElement("div", {
8949
- className: "detail-item"
8950
- }, /*#__PURE__*/React.createElement("span", {
8951
- className: "label"
8952
- }, t("VENDOR_NAME") || "Vendor Name"), /*#__PURE__*/React.createElement("span", {
8953
- className: "value"
8954
- }, vendorName)))), /*#__PURE__*/React.createElement("div", {
8955
- className: "details-right"
8956
- }, /*#__PURE__*/React.createElement("div", {
8957
- className: "download-card"
8958
- }, /*#__PURE__*/React.createElement("h4", null, t("DOWNLOAD_EKYC_DATA") || "Download eKYC Data"), /*#__PURE__*/React.createElement("p", null, t("DOWNLOAD_EKYC_DATA_DESC") || "Export the complete eKYC verification records for your assigned jurisdiction into Excel format."), /*#__PURE__*/React.createElement("button", {
8959
- className: "download-excel-btn",
8960
- disabled: ekycDownloadLoading,
8961
- onClick: handleDownloadEkycData
8962
- }, /*#__PURE__*/React.createElement("svg", {
8963
- width: "16",
8964
- height: "16",
8965
- viewBox: "0 0 24 24",
8966
- fill: "none",
8967
- stroke: "currentColor",
8968
- strokeWidth: "2.5",
8969
- strokeLinecap: "round",
8970
- strokeLinejoin: "round"
8971
- }, /*#__PURE__*/React.createElement("path", {
8972
- d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"
8973
- }), /*#__PURE__*/React.createElement("polyline", {
8974
- points: "7 10 12 15 17 10"
8975
- }), /*#__PURE__*/React.createElement("line", {
8976
- x1: "12",
8977
- y1: "15",
8978
- x2: "12",
8979
- y2: "3"
8980
- })), ekycDownloadLoading ? t("DOWNLOADING") || "Downloading..." : t("DOWNLOAD_EXCEL") || "Download Excel"))))), /*#__PURE__*/React.createElement(Card, {
8981
- className: "dashboard-card"
8982
- }, /*#__PURE__*/React.createElement(Table, {
8983
- t: t,
8984
- tableTitle: t("CONNECTED_SURVEYORS") || "Connected Surveyors",
8985
- tableClass: "ekycTable",
8986
- data: paginatedSurveyors,
8987
- columns: surveyorColumns,
8988
- isLoading: isProgressLoading,
8989
- totalRecords: surveyors.length,
8990
- currentPage: currentPage,
8991
- pageSizeLimit: pageSize,
8992
- isPaginationRequired: true,
8993
- onNextPage: () => {
8994
- if (currentPage < Math.ceil(surveyors.length / pageSize) - 1) {
8995
- setCurrentPage(prev => prev + 1);
8996
- }
8997
- },
8998
- onPrevPage: () => {
8999
- if (currentPage > 0) {
9000
- setCurrentPage(prev => prev - 1);
9001
- }
9002
- },
9003
- onFirstPage: () => {
9004
- setCurrentPage(0);
9005
- },
9006
- onLastPage: () => {
9007
- setCurrentPage(Math.max(Math.ceil(surveyors.length / pageSize) - 1, 0));
9440
+ };
9441
+ const propsForInboxTable = useInboxTableConfig(_extends({}, {
9442
+ parentRoute,
9443
+ onPageSizeChange,
9444
+ formState,
9445
+ totalCount: totalRecords,
9446
+ table: filteredData,
9447
+ dispatch,
9448
+ onSortingByData,
9449
+ tenantId,
9450
+ checkPathName,
9451
+ inboxStyles: {
9452
+ overflowX: "scroll",
9453
+ overflowY: "hidden"
9008
9454
  },
9009
- onPageSizeChange: e => {
9010
- setPageSize(Number(e.target.value));
9011
- setCurrentPage(0);
9455
+ tableStyle: {
9456
+ width: "70%"
9012
9457
  }
9458
+ }));
9459
+ const onMobileSortOrderData = data => {
9460
+ const sortOrder = data.sortOrder;
9461
+ dispatch({
9462
+ action: "mutateTableForm",
9463
+ data: _extends({}, formState.tableForm, {
9464
+ sortOrder
9465
+ })
9466
+ });
9467
+ };
9468
+ const onSortFormReset = setSortFormValue => {
9469
+ setSortFormValue("sortOrder", "DESC");
9470
+ dispatch({
9471
+ action: "mutateTableForm",
9472
+ data: tableOrderFormDefaultValues
9473
+ });
9474
+ };
9475
+ const propsForMobileSortForm = {
9476
+ onMobileSortOrderData,
9477
+ sortFormDefaultValues: formState === null || formState === void 0 ? void 0 : formState.tableForm,
9478
+ onSortFormReset
9479
+ };
9480
+ const propsForInboxMobileCards = useInboxMobileCardsData({
9481
+ table: filteredData,
9482
+ tenantId
9483
+ });
9484
+ const isInboxLoading = isLoading || isSearchLoading;
9485
+ return /*#__PURE__*/React.createElement("div", {
9486
+ className: "app-container"
9487
+ }, /*#__PURE__*/React.createElement(InboxComposer, _extends({
9488
+ isInboxLoading
9489
+ }, propsForSearchForm, propsForMobileSortForm, {
9490
+ propsForInboxTable,
9491
+ propsForInboxMobileCards,
9492
+ formState
9013
9493
  })));
9014
9494
  };
9015
9495
 
@@ -9390,7 +9870,7 @@ const CitizenApp = () => {
9390
9870
  layoutClass: "normal"
9391
9871
  }, /*#__PURE__*/React.createElement(Home, null))
9392
9872
  }), /*#__PURE__*/React.createElement(PrivateRoute, {
9393
- path: [path + "/vendor-dashboard/:vendorId", path + "/vendor-dashboard", path + "/dashboard"],
9873
+ path: [path + "/vendor-dashboard/:vendorId", path + "/vendor-dashboard"],
9394
9874
  component: () => /*#__PURE__*/React.createElement(LayoutWrapper, {
9395
9875
  layoutClass: "normal"
9396
9876
  }, /*#__PURE__*/React.createElement(VendorDetailsCard, null))
@@ -9447,7 +9927,7 @@ const CitizenApp = () => {
9447
9927
  layoutClass: "normal"
9448
9928
  }, /*#__PURE__*/React.createElement(Review, null))
9449
9929
  }), /*#__PURE__*/React.createElement(PrivateRoute, {
9450
- path: path + "/supervisor-dashboard",
9930
+ path: [path + "/supervisor-dashboard/:id", path + "/supervisor-dashboard"],
9451
9931
  component: () => /*#__PURE__*/React.createElement(LayoutWrapper, {
9452
9932
  layoutClass: "normal"
9453
9933
  }, /*#__PURE__*/React.createElement(SupervisorDetailsCard, null))