@djb25/digit-ui-module-vendor 1.0.63 → 1.0.65

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,7 +1,7 @@
1
- import React, { useState, useEffect, useCallback, useReducer, useMemo, useRef } from 'react';
1
+ import React, { useState, useMemo, useEffect, useCallback, useReducer, useRef } from 'react';
2
2
  import { useHistory, Link, useLocation, useParams, useRouteMatch, Switch, Route, Redirect } from 'react-router-dom';
3
3
  import { useTranslation } from 'react-i18next';
4
- import { VerticalTimeline, FormComposer, Toast, Card, ShippingTruck, Table, CheckBox, Loader, RadioButtons, CloseSvg, Localities, RemoveableTag, ActionBar, ApplyFilterBar, Dropdown, AddIcon, Menu, LinkLabel, SubmitBar, TextInput, DatePicker as DatePicker$4, ViewsIcon, ToggleSwitch, Modal, MdClose, CardSectionHeader, CardText, Row, EditIcon, DeleteIcon, Header, SearchForm, SearchField, MobileNumber, CardLabelError, AppContainer, ModuleHeader, ArrowLeft, PrivateRoute, LayoutWrapper, HomeIcon, PropertyHouse, EmployeeModuleCard, FormStep, LabelFieldPair, CardLabel, UploadFile, RadioOrSelect, MultiSelectDropdown, CitizenHomeCard, CardHeader, CardSubHeader, StatusTable, LinkButton, Banner, InfoIcon, CustomTooltip } from '@djb25/digit-ui-react-components';
4
+ import { Loader, VerticalTimeline, FormComposer, Toast, Card, ShippingTruck, Table, CheckBox, RadioButtons, CloseSvg, Localities, RemoveableTag, ActionBar, ApplyFilterBar, Dropdown, AddIcon, Menu, LinkLabel, SubmitBar, TextInput, DatePicker as DatePicker$4, ViewsIcon, ToggleSwitch, Modal, MdClose, CardSectionHeader, CardText, Row, EditIcon, DeleteIcon, Header, SearchForm, SearchField, MobileNumber, CardLabelError, AppContainer, ModuleHeader, ArrowLeft, PrivateRoute, LayoutWrapper, HomeIcon, PropertyHouse, EmployeeModuleCard, FormStep, LabelFieldPair, CardLabel, UploadFile, RadioOrSelect, MultiSelectDropdown, CitizenHomeCard, CardHeader, CardSubHeader, StatusTable, LinkButton, Banner, InfoIcon, CustomTooltip } from '@djb25/digit-ui-react-components';
5
5
  import { useQueryClient } from 'react-query';
6
6
  import { useForm, Controller } from 'react-hook-form';
7
7
 
@@ -50,10 +50,20 @@ const SurveyorConfig = function (t, agencies, reportingManagers, disabled) {
50
50
  populators: {
51
51
  name: "fullName",
52
52
  validation: {
53
- required: true,
54
- pattern: /^[A-Za-z\s]+$/
53
+ required: {
54
+ value: true,
55
+ message: t("ES_VENDOR_INVALID_NAME")
56
+ },
57
+ maxLength: {
58
+ value: 49,
59
+ message: t("ES_VENDOR_NAME_MAX_50_CHARACTERS")
60
+ },
61
+ pattern: {
62
+ value: /^[A-Za-z\s]+$/,
63
+ message: t("ES_VENDOR_INVALID_NAME")
64
+ }
55
65
  },
56
- error: t("ES_VENDOR_INVALID_NAME")
66
+ maxlength: 50
57
67
  }
58
68
  }, {
59
69
  label: "ES_VENDOR_SURVEYOR_MOBILE_NUMBER",
@@ -113,6 +123,22 @@ const SurveyorConfig = function (t, agencies, reportingManagers, disabled) {
113
123
  },
114
124
  className: "payment-form-text-input-correction"
115
125
  }
126
+ }, {
127
+ label: t("ES_VENDOR_ZONE"),
128
+ isMandatory: true,
129
+ type: "component",
130
+ key: "zoneIds",
131
+ populators: {
132
+ name: "zoneIds",
133
+ validation: {
134
+ required: true
135
+ },
136
+ className: "mb-16"
137
+ },
138
+ props: {
139
+ isMultiSelect: false
140
+ },
141
+ component: "SelectEkycZones"
116
142
  }, {
117
143
  label: t("ES_VENDOR_SURVEYOR_DESCRIPTION"),
118
144
  isMandatory: false,
@@ -126,7 +152,7 @@ const SurveyorConfig = function (t, agencies, reportingManagers, disabled) {
126
152
  };
127
153
 
128
154
  const AddSurveyor = _ref => {
129
- var _Digit$UserService$ge;
155
+ var _Digit$UserService$ge, _userInfo$roles;
130
156
  const _useTranslation = useTranslation(),
131
157
  t = _useTranslation.t;
132
158
  const history = useHistory();
@@ -143,14 +169,63 @@ const AddSurveyor = _ref => {
143
169
  setCanSubmit = _useState2[1];
144
170
  const _Digit$Hooks$fsm$useS = Digit.Hooks.fsm.useSurveyorCreate(tenantId),
145
171
  mutateAsync = _Digit$Hooks$fsm$useS.mutateAsync;
146
- const Config = SurveyorConfig(t);
147
- const defaultValues = {
148
- role: {
149
- code: "SURVEYOR",
150
- name: "Surveyor"
151
- },
152
- mobileNumber: ""
153
- };
172
+ const isSupervisor = userInfo === null || userInfo === void 0 ? void 0 : (_userInfo$roles = userInfo.roles) === null || _userInfo$roles === void 0 ? void 0 : _userInfo$roles.some(role => role.code === "EKYC_SUPERVISOR");
173
+ const _Digit$Hooks$fsm$useS2 = Digit.Hooks.fsm.useSupervisorSearch(tenantId, {
174
+ status: "ACTIVE"
175
+ }, {
176
+ enabled: isSupervisor,
177
+ staleTime: Infinity
178
+ }),
179
+ supervisorSearchResponse = _Digit$Hooks$fsm$useS2.data,
180
+ isSupervisorSearchLoading = _Digit$Hooks$fsm$useS2.isLoading;
181
+ const matchedSupervisor = useMemo(() => {
182
+ if (!(supervisorSearchResponse !== null && supervisorSearchResponse !== void 0 && supervisorSearchResponse.supervisors)) return null;
183
+ return supervisorSearchResponse.supervisors.find(s => {
184
+ var _s$id, _userInfo$uuid, _s$owner, _s$owner$uuid, _userInfo$uuid2, _s$owner2;
185
+ return ((_s$id = s.id) === null || _s$id === void 0 ? void 0 : _s$id.toLowerCase()) === (userInfo === null || userInfo === void 0 ? void 0 : (_userInfo$uuid = userInfo.uuid) === null || _userInfo$uuid === void 0 ? void 0 : _userInfo$uuid.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()) === (userInfo === null || userInfo === void 0 ? void 0 : (_userInfo$uuid2 = userInfo.uuid) === null || _userInfo$uuid2 === void 0 ? void 0 : _userInfo$uuid2.toLowerCase()) || ((_s$owner2 = s.owner) === null || _s$owner2 === void 0 ? void 0 : _s$owner2.mobileNumber) === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.mobileNumber) || s.mobileNo === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.mobileNumber);
186
+ });
187
+ }, [supervisorSearchResponse, userInfo]);
188
+ const _useState3 = useState(null),
189
+ defaultValues = _useState3[0],
190
+ setDefaultValues = _useState3[1];
191
+ useEffect(() => {
192
+ if (!isSupervisor) {
193
+ setDefaultValues({
194
+ role: {
195
+ code: "SURVEYOR",
196
+ name: "Surveyor"
197
+ },
198
+ mobileNumber: ""
199
+ });
200
+ } else if (supervisorSearchResponse && !isSupervisorSearchLoading) {
201
+ setDefaultValues({
202
+ role: {
203
+ code: "SURVEYOR",
204
+ name: "Surveyor"
205
+ },
206
+ mobileNumber: "",
207
+ zoneIds: (matchedSupervisor === null || matchedSupervisor === void 0 ? void 0 : matchedSupervisor.assignedZoneId) || ""
208
+ });
209
+ }
210
+ }, [isSupervisor, supervisorSearchResponse, isSupervisorSearchLoading, matchedSupervisor]);
211
+ const Config = useMemo(() => {
212
+ const baseConfig = SurveyorConfig(t);
213
+ if (isSupervisor) {
214
+ return baseConfig.map(section => _extends({}, section, {
215
+ body: section.body.map(field => {
216
+ if (field.key === "zoneIds") {
217
+ return _extends({}, field, {
218
+ props: _extends({}, field.props, {
219
+ disable: true
220
+ })
221
+ });
222
+ }
223
+ return field;
224
+ })
225
+ }));
226
+ }
227
+ return baseConfig;
228
+ }, [t, isSupervisor]);
154
229
  const isValidAge = dateStr => {
155
230
  if (!dateStr) return false;
156
231
  const today = new Date();
@@ -175,8 +250,8 @@ const AddSurveyor = _ref => {
175
250
  };
176
251
  const onSubmit = function (data) {
177
252
  try {
178
- var _userInfo$roles, _Digit$UserService$ge2, _data$gender;
179
- const isSupervisor = userInfo === null || userInfo === void 0 ? void 0 : (_userInfo$roles = userInfo.roles) === null || _userInfo$roles === void 0 ? void 0 : _userInfo$roles.some(role => role.code === "EKYC_SUPERVISOR");
253
+ var _data$zoneIds, _Digit$UserService$ge2, _data$gender;
254
+ const assignedZone = Array.isArray(data === null || data === void 0 ? void 0 : data.zoneIds) ? (data === null || data === void 0 ? void 0 : (_data$zoneIds = data.zoneIds) === null || _data$zoneIds === void 0 ? void 0 : _data$zoneIds.map(ele => ele.code).join(",")) || "" : (data === null || data === void 0 ? void 0 : data.zoneIds) || "";
180
255
  const formData = {
181
256
  RequestInfo: _extends({
182
257
  apiId: "Rainmaker",
@@ -198,6 +273,9 @@ const AddSurveyor = _ref => {
198
273
  }),
199
274
  surveyor: {
200
275
  tenantId: tenantId,
276
+ vendorId: isSupervisor ? matchedSupervisor === null || matchedSupervisor === void 0 ? void 0 : matchedSupervisor.vendorId : undefined,
277
+ supervisorId: isSupervisor ? matchedSupervisor === null || matchedSupervisor === void 0 ? void 0 : matchedSupervisor.id : undefined,
278
+ assignedZoneId: assignedZone,
201
279
  description: (data === null || data === void 0 ? void 0 : data.description) || "",
202
280
  correspondenceAddress: data === null || data === void 0 ? void 0 : data.correspondenceAddress,
203
281
  additionalDetails: {
@@ -240,6 +318,9 @@ const AddSurveyor = _ref => {
240
318
  return Promise.reject(e);
241
319
  }
242
320
  };
321
+ if (isSupervisor && (isSupervisorSearchLoading || !defaultValues)) {
322
+ return /*#__PURE__*/React.createElement(Loader, null);
323
+ }
243
324
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(VerticalTimeline, {
244
325
  config: [{
245
326
  route: "surveyor-details",
@@ -632,7 +713,7 @@ const DropdownStatus = _ref => {
632
713
  };
633
714
 
634
715
  const RegisteredVendorSearch = _ref => {
635
- var _matchedRoles$wt, _matchedRoles$wt2, _matchedRoles$ekyc, _matchedRoles$ekyc2, _matchedRoles$wt3, _matchedRoles$wt4, _matchedRoles$wt5, _matchedRoles$ekyc3, _matchedRoles$ekyc4, _matchedRoles$ekyc5, _matchedRoles$ekyc6, _matchedRoles$ekyc7;
716
+ var _matchedRoles$wt, _matchedRoles$wt2, _matchedRoles$ekyc, _matchedRoles$ekyc2, _matchedRoles$wt3, _matchedRoles$ekyc3, _matchedRoles$wt4, _matchedRoles$wt5, _matchedRoles$ekyc4, _matchedRoles$ekyc5, _matchedRoles$ekyc6, _matchedRoles$ekyc7, _matchedRoles$ekyc8;
636
717
  let onSearch = _ref.onSearch,
637
718
  type = _ref.type,
638
719
  onClose = _ref.onClose,
@@ -778,7 +859,7 @@ const RegisteredVendorSearch = _ref => {
778
859
  onClick: onClose
779
860
  }, /*#__PURE__*/React.createElement(CloseSvg, null))), /*#__PURE__*/React.createElement("div", {
780
861
  className: "search-tabs-container"
781
- }, /*#__PURE__*/React.createElement("div", null, (matchedRoles === null || matchedRoles === void 0 ? void 0 : (_matchedRoles$wt3 = matchedRoles.wt) === null || _matchedRoles$wt3 === void 0 ? void 0 : _matchedRoles$wt3.includes("WT_VENDOR")) && /*#__PURE__*/React.createElement("button", {
862
+ }, /*#__PURE__*/React.createElement("div", null, ((matchedRoles === null || matchedRoles === void 0 ? void 0 : (_matchedRoles$wt3 = matchedRoles.wt) === null || _matchedRoles$wt3 === void 0 ? void 0 : _matchedRoles$wt3.includes("WT_VENDOR")) || (matchedRoles === null || matchedRoles === void 0 ? void 0 : (_matchedRoles$ekyc3 = matchedRoles.ekyc) === null || _matchedRoles$ekyc3 === void 0 ? void 0 : _matchedRoles$ekyc3.includes("EKYC_VENDOR"))) && /*#__PURE__*/React.createElement("button", {
782
863
  className: selectedTab === "VENDOR" ? "search-tab-head-selected" : "search-tab-head",
783
864
  onClick: () => {
784
865
  clearSearch();
@@ -796,13 +877,13 @@ const RegisteredVendorSearch = _ref => {
796
877
  clearSearch();
797
878
  onTabChange("DRIVER");
798
879
  }
799
- }, t("ES_FSM_REGISTRY_INBOX_TAB_DRIVER")), ((matchedRoles === null || matchedRoles === void 0 ? void 0 : (_matchedRoles$ekyc3 = matchedRoles.ekyc) === null || _matchedRoles$ekyc3 === void 0 ? void 0 : _matchedRoles$ekyc3.includes("EKYC_VENDOR")) || (matchedRoles === null || matchedRoles === void 0 ? void 0 : (_matchedRoles$ekyc4 = matchedRoles.ekyc) === null || _matchedRoles$ekyc4 === void 0 ? void 0 : _matchedRoles$ekyc4.includes("EMPLOYEE"))) && /*#__PURE__*/React.createElement("button", {
880
+ }, t("ES_FSM_REGISTRY_INBOX_TAB_DRIVER")), ((matchedRoles === null || matchedRoles === void 0 ? void 0 : (_matchedRoles$ekyc4 = matchedRoles.ekyc) === null || _matchedRoles$ekyc4 === void 0 ? void 0 : _matchedRoles$ekyc4.includes("EKYC_VENDOR")) || (matchedRoles === null || matchedRoles === void 0 ? void 0 : (_matchedRoles$ekyc5 = matchedRoles.ekyc) === null || _matchedRoles$ekyc5 === void 0 ? void 0 : _matchedRoles$ekyc5.includes("EMPLOYEE"))) && /*#__PURE__*/React.createElement("button", {
800
881
  className: selectedTab === "SUPERVISOR" ? "search-tab-head-selected" : "search-tab-head",
801
882
  onClick: () => {
802
883
  clearSearch();
803
884
  onTabChange("SUPERVISOR");
804
885
  }
805
- }, t("ES_FSM_REGISTRY_INBOX_TAB_SUPERVISOR")), ((matchedRoles === null || matchedRoles === void 0 ? void 0 : (_matchedRoles$ekyc5 = matchedRoles.ekyc) === null || _matchedRoles$ekyc5 === void 0 ? void 0 : _matchedRoles$ekyc5.includes("EKYC_SUPERVISOR")) || (matchedRoles === null || matchedRoles === void 0 ? void 0 : (_matchedRoles$ekyc6 = matchedRoles.ekyc) === null || _matchedRoles$ekyc6 === void 0 ? void 0 : _matchedRoles$ekyc6.includes("EKYC_VENDOR")) || (matchedRoles === null || matchedRoles === void 0 ? void 0 : (_matchedRoles$ekyc7 = matchedRoles.ekyc) === null || _matchedRoles$ekyc7 === void 0 ? void 0 : _matchedRoles$ekyc7.includes("EMPLOYEE"))) && /*#__PURE__*/React.createElement("button", {
886
+ }, t("ES_FSM_REGISTRY_INBOX_TAB_SUPERVISOR")), ((matchedRoles === null || matchedRoles === void 0 ? void 0 : (_matchedRoles$ekyc6 = matchedRoles.ekyc) === null || _matchedRoles$ekyc6 === void 0 ? void 0 : _matchedRoles$ekyc6.includes("EKYC_SUPERVISOR")) || (matchedRoles === null || matchedRoles === void 0 ? void 0 : (_matchedRoles$ekyc7 = matchedRoles.ekyc) === null || _matchedRoles$ekyc7 === void 0 ? void 0 : _matchedRoles$ekyc7.includes("EKYC_VENDOR")) || (matchedRoles === null || matchedRoles === void 0 ? void 0 : (_matchedRoles$ekyc8 = matchedRoles.ekyc) === null || _matchedRoles$ekyc8 === void 0 ? void 0 : _matchedRoles$ekyc8.includes("EMPLOYEE"))) && /*#__PURE__*/React.createElement("button", {
806
887
  className: selectedTab === "SURVEYOR" ? "search-tab-head-selected" : "search-tab-head",
807
888
  onClick: () => {
808
889
  clearSearch();
@@ -1007,7 +1088,7 @@ const VendorInbox = props => {
1007
1088
  const userInfo = Digit.SessionStorage.get("User");
1008
1089
  const userRoles = userInfo.info.roles;
1009
1090
  const userType = (_userInfo$info$type = userInfo.info.type) === null || _userInfo$info$type === void 0 ? void 0 : _userInfo$info$type.toLowerCase();
1010
- const EKYC_ROLES = ["EKYC_VENDOR", "EKYC_SUPERVISOR", "EKYC_SURVEYOR"];
1091
+ const EKYC_ROLES = ["EKYC_SUPERVISOR", "EKYC_SURVEYOR"];
1011
1092
  const isEkycRole = userRoles === null || userRoles === void 0 ? void 0 : userRoles.some(role => EKYC_ROLES.includes((role === null || role === void 0 ? void 0 : role.code) || role));
1012
1093
  const openWorkOrderModal = vendorDetails => {
1013
1094
  setSelectedVendorForWorkOrder(vendorDetails);
@@ -1332,9 +1413,11 @@ const VendorInbox = props => {
1332
1413
  });
1333
1414
  },
1334
1415
  onSuccess: (data, variables) => {
1416
+ console.log("newStatus:", newStatus, "isDisable:", newStatus === "DISABLED");
1335
1417
  setShowToast({
1336
1418
  key: "success",
1337
- action: "SUPERVISOR"
1419
+ action: "SUPERVISOR",
1420
+ isDisable: newStatus === "DISABLED"
1338
1421
  });
1339
1422
  queryClient.invalidateQueries("FSM_SUPERVISOR_SEARCH");
1340
1423
  queryClient.invalidateQueries("SUPERVISOR_SEARCH");
@@ -1368,9 +1451,11 @@ const VendorInbox = props => {
1368
1451
  });
1369
1452
  },
1370
1453
  onSuccess: (data, variables) => {
1454
+ console.log("newStatus:", newStatus, "isDisable:", newStatus === "DISABLED");
1371
1455
  setShowToast({
1372
1456
  key: "success",
1373
- action: "SURVEYOR"
1457
+ action: "SURVEYOR",
1458
+ isDisable: newStatus === "DISABLED"
1374
1459
  });
1375
1460
  queryClient.invalidateQueries("FSM_SURVEYOR_SEARCH");
1376
1461
  queryClient.invalidateQueries("SURVEYOR_SEARCH");
@@ -2524,7 +2609,7 @@ const SearchVendor = () => {
2524
2609
  const userInfo = Digit.UserService.getUser();
2525
2610
  const roles = ((_Digit$UserService$ge = Digit.UserService.getUser()) === null || _Digit$UserService$ge === void 0 ? void 0 : (_Digit$UserService$ge2 = _Digit$UserService$ge.info) === null || _Digit$UserService$ge2 === void 0 ? void 0 : (_Digit$UserService$ge3 = _Digit$UserService$ge2.roles) === null || _Digit$UserService$ge3 === void 0 ? void 0 : _Digit$UserService$ge3.map(r => r.code)) || [];
2526
2611
  const location = useLocation();
2527
- const initialPage = roles.includes("WT_VENDOR") ? "VENDOR" : roles.includes("EKYC_VENDOR") ? "SUPERVISOR" : roles.includes("EKYC_SUPERVISOR") ? "SURVEYOR" : roles.includes("EKYC_SURVEYOR") ? "SURVEYOR" : roles.includes("EMPLOYEE") ? "SUPERVISOR" : "";
2612
+ const initialPage = roles.includes("EKYC_VENDOR") || roles.includes("WT_VENDOR") ? "VENDOR" : roles.includes("EKYC_SUPERVISOR") ? "SURVEYOR" : roles.includes("EKYC_SURVEYOR") ? "SURVEYOR" : roles.includes("EMPLOYEE") ? "SUPERVISOR" : "";
2528
2613
  const _Digit$Hooks$useQuery = Digit.Hooks.useQueryParams(),
2529
2614
  selectedTabs = _Digit$Hooks$useQuery.selectedTabs;
2530
2615
  const _useState = useState(selectedTabs || initialPage),
@@ -3353,15 +3438,22 @@ const SupervisorConfig = function (t, agencies, reportingManagers, disabled) {
3353
3438
  populators: {
3354
3439
  name: "fullName",
3355
3440
  validation: {
3356
- required: true,
3441
+ required: {
3442
+ value: true,
3443
+ message: t("ES_VENDOR_INVALID_NAME")
3444
+ },
3445
+ maxLength: {
3446
+ value: 49,
3447
+ message: t("ES_VENDOR_NAME_MAX_50_CHARACTERS")
3448
+ },
3357
3449
  pattern: {
3358
3450
  value: /^[A-Za-z\s]+$/,
3359
3451
  message: t("ES_VENDOR_INVALID_NAME")
3360
3452
  }
3361
3453
  },
3362
- error: t("ES_VENDOR_INVALID_NAME"),
3363
3454
  defaultValue: "",
3364
- className: "payment-form-text-input-correction"
3455
+ className: "payment-form-text-input-correction",
3456
+ maxlength: 50
3365
3457
  }
3366
3458
  }, {
3367
3459
  label: t("ES_VENDOR_SUPERVISOR_MOBILE_NUMBER"),
@@ -3894,7 +3986,7 @@ const formatLabel = key => {
3894
3986
  return result.charAt(0).toUpperCase() + result.slice(1);
3895
3987
  };
3896
3988
  const VendorDetails = () => {
3897
- var _dsoData$, _dsoData$$dsoDetails, _vendorAdditionalData, _vendorAdditionalData2, _vendorAdditionalData3, _parsedAdditionalDeta, _userInfo$info$type, _dsoData$5, _dsoData$5$employeeRe, _supervisorData$super, _surveyorData$surveyo;
3989
+ var _dsoData$, _dsoData$$dsoDetails, _vendorAdditionalData, _vendorAdditionalData2, _vendorAdditionalData3, _parsedAdditionalDeta, _userInfo$info$type, _userInfo$info, _userInfo$info$roles, _dsoData$5, _dsoData$5$employeeRe, _supervisorData$super, _surveyorData$surveyo;
3898
3990
  const tenantId = Digit.ULBService.getCurrentTenantId();
3899
3991
  const _useTranslation = useTranslation(),
3900
3992
  t = _useTranslation.t;
@@ -4000,6 +4092,8 @@ const VendorDetails = () => {
4000
4092
  }
4001
4093
  const userInfo = Digit.SessionStorage.get("User");
4002
4094
  const userType = (_userInfo$info$type = userInfo.info.type) === null || _userInfo$info$type === void 0 ? void 0 : _userInfo$info$type.toLowerCase();
4095
+ const userRoles = (userInfo === null || userInfo === void 0 ? void 0 : (_userInfo$info = userInfo.info) === null || _userInfo$info === void 0 ? void 0 : (_userInfo$info$roles = _userInfo$info.roles) === null || _userInfo$info$roles === void 0 ? void 0 : _userInfo$info$roles.map(r => r.code)) || [];
4096
+ const isEkycVendor = userRoles.includes("EKYC_VENDOR");
4003
4097
  useEffect(() => {
4004
4098
  switch (selectedAction) {
4005
4099
  case "DELETE":
@@ -4375,7 +4469,7 @@ const VendorDetails = () => {
4375
4469
  manualPagination: false,
4376
4470
  pageSizeLimit: 10,
4377
4471
  t: t
4378
- }), /*#__PURE__*/React.createElement("div", {
4472
+ }), isEkycVendor && /*#__PURE__*/React.createElement("div", {
4379
4473
  className: "add-details-link hover-button",
4380
4474
  onClick: () => history.push("/digit-ui/" + userType + "/vendor/registry/new-supervisor?vendorId=" + (dsoId || vendorId))
4381
4475
  }, t("ES_VENDOR_ADD_SUPERVISOR"))), /*#__PURE__*/React.createElement(CardSectionHeader, {
@@ -4391,7 +4485,10 @@ const VendorDetails = () => {
4391
4485
  manualPagination: false,
4392
4486
  pageSizeLimit: 10,
4393
4487
  t: t
4394
- })))), showModal && /*#__PURE__*/React.createElement(Modal, {
4488
+ }), isEkycVendor && /*#__PURE__*/React.createElement("div", {
4489
+ className: "add-details-link hover-button",
4490
+ onClick: () => history.push("/digit-ui/" + userType + "/vendor/registry/new-surveyor?vendorId=" + (dsoId || vendorId))
4491
+ }, t("ES_VENDOR_ADD_SURVEYOR"))))), showModal && /*#__PURE__*/React.createElement(Modal, {
4395
4492
  headerBarMain: /*#__PURE__*/React.createElement("h1", {
4396
4493
  className: "heading-m"
4397
4494
  }, t(selectedAction === "DELETE" ? "ES_FSM_REGISTRY_DELETE_POPUP_HEADER" : selectedAction === "ADD_VEHICLE" ? "ES_FSM_REGISTRY_ADD_VEHICLE_POPUP_HEADER" : "ES_FSM_REGISTRY_ADD_DRIVER_POPUP_HEADER")),
@@ -4617,7 +4714,8 @@ const VendorConfig = function (t, module, genderMenu, update) {
4617
4714
  isMandatory: true,
4618
4715
  type: "component",
4619
4716
  key: "zoneIds",
4620
- component: "SelectEkycZones"
4717
+ component: "SelectEkycZones",
4718
+ disable: update
4621
4719
  }, {
4622
4720
  label: "ES_FSM_REGISTRY_NEW_OWNER_NAME",
4623
4721
  isMandatory: true,
@@ -4650,13 +4748,26 @@ const VendorConfig = function (t, module, genderMenu, update) {
4650
4748
  populators: {
4651
4749
  name: "dob",
4652
4750
  validation: {
4653
- required: true
4751
+ required: true,
4752
+ validate: value => {
4753
+ if (!value) return true;
4754
+ const dob = new Date(value);
4755
+ const today = new Date();
4756
+ let age = today.getFullYear() - dob.getFullYear();
4757
+ const m = today.getMonth() - dob.getMonth();
4758
+ if (m < 0 || m === 0 && today.getDate() < dob.getDate()) {
4759
+ age--;
4760
+ }
4761
+ return age >= 18 || t("ES_VENDOR_DOB_MIN_AGE_ERROR") || "Vendor must be 18 years or older";
4762
+ }
4654
4763
  },
4655
4764
  component: (props, customProps) => /*#__PURE__*/React.createElement(DatePicker$4, _extends({
4656
4765
  onChange: props.onChange,
4657
4766
  date: props.value
4658
4767
  }, customProps, {
4659
- max: convertEpochToDate(new Date().setFullYear(new Date().getFullYear()))
4768
+ isDOB: true,
4769
+ minAge: 18,
4770
+ max: convertEpochToDate(new Date().setFullYear(new Date().getFullYear() - 18))
4660
4771
  }))
4661
4772
  }
4662
4773
  }] : [])]
@@ -5663,12 +5774,19 @@ const VENDORCreate = _ref => {
5663
5774
  React.useEffect(() => {
5664
5775
  const searchParams = new URLSearchParams(search || window.location.search);
5665
5776
  const vendorId = searchParams.get("vendorId");
5666
- if (vendorId && params.vendor_id !== vendorId) {
5667
- setParams(_extends({}, params, {
5668
- vendor_id: vendorId
5669
- }));
5777
+ if (vendorId) {
5778
+ if (params.vendor_id !== vendorId) {
5779
+ setParams(_extends({}, params, {
5780
+ vendor_id: vendorId
5781
+ }));
5782
+ }
5783
+ } else {
5784
+ if (params && Object.keys(params).length > 0 && window.location.href.includes("/info") && sessionStorage.getItem("docReqScreenByBack") !== "true") {
5785
+ clearParams();
5786
+ queryClient.invalidateQueries("VENDOR_CREATE");
5787
+ }
5670
5788
  }
5671
- }, [search, window.location.search, params, setParams]);
5789
+ }, [search, pathname, params, setParams, clearParams, queryClient]);
5672
5790
  const goNext = (skipStep, index, isAddMultiple, key) => {
5673
5791
  let currentPath = pathname.split("/").pop(),
5674
5792
  lastchar = currentPath.charAt(currentPath.length - 1),
@@ -5710,10 +5828,6 @@ const VENDORCreate = _ref => {
5710
5828
  }
5711
5829
  redirectWithHistory(nextPage);
5712
5830
  };
5713
- if (params && Object.keys(params).length > 0 && window.location.href.includes("/info") && sessionStorage.getItem("docReqScreenByBack") !== "true") {
5714
- clearParams();
5715
- queryClient.invalidateQueries("VENDOR_CREATE");
5716
- }
5717
5831
  const vendorcreate = function () {
5718
5832
  try {
5719
5833
  history.push(match.path + "/acknowledgement");
@@ -9438,12 +9552,15 @@ const VehicleDetails = props => {
9438
9552
  };
9439
9553
 
9440
9554
  const SelectEkycZones = _ref => {
9555
+ var _Digit$SessionStorage, _loggedInUser$roles, _config$props;
9441
9556
  let config = _ref.config,
9442
9557
  onSelect = _ref.onSelect,
9443
9558
  t = _ref.t,
9444
9559
  formData = _ref.formData,
9445
9560
  _ref$isMultiSelect = _ref.isMultiSelect,
9446
- isMultiSelect = _ref$isMultiSelect === void 0 ? true : _ref$isMultiSelect;
9561
+ isMultiSelect = _ref$isMultiSelect === void 0 ? true : _ref$isMultiSelect,
9562
+ _ref$disable = _ref.disable,
9563
+ disable = _ref$disable === void 0 ? false : _ref$disable;
9447
9564
  const tenantId = Digit.ULBService.getCurrentTenantId();
9448
9565
  const _useState = useState([]),
9449
9566
  zones = _useState[0],
@@ -9452,6 +9569,45 @@ const SelectEkycZones = _ref => {
9452
9569
  selectedZones = _useState2[0],
9453
9570
  setSelectedZones = _useState2[1];
9454
9571
  const initialized = useRef(false);
9572
+ const isVendorPage = window.location.pathname.includes("/new-vendor") || window.location.pathname.includes("/modify-vendor") || window.location.href.includes("/new-vendor") || window.location.href.includes("/modify-vendor");
9573
+ const loggedInUser = (_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : _Digit$SessionStorage.info;
9574
+ const roles = (loggedInUser === null || loggedInUser === void 0 ? void 0 : (_loggedInUser$roles = loggedInUser.roles) === null || _loggedInUser$roles === void 0 ? void 0 : _loggedInUser$roles.map(r => r.code)) || [];
9575
+ const isEkycVendor = roles.includes("EKYC_VENDOR");
9576
+ const isEkycSupervisor = roles.includes("EKYC_SUPERVISOR");
9577
+ const _Digit$Hooks$fsm$useD = Digit.Hooks.fsm.useDsoSearch(tenantId, {
9578
+ status: "ACTIVE"
9579
+ }, {
9580
+ enabled: isEkycVendor && !isVendorPage
9581
+ }),
9582
+ vendorSearchResponse = _Digit$Hooks$fsm$useD.data,
9583
+ isVendorSearchLoading = _Digit$Hooks$fsm$useD.isLoading;
9584
+ const _Digit$Hooks$fsm$useS = Digit.Hooks.fsm.useSupervisorSearch(tenantId, {
9585
+ status: "ACTIVE"
9586
+ }, {
9587
+ enabled: isEkycSupervisor
9588
+ }),
9589
+ supervisorSearchResponse = _Digit$Hooks$fsm$useS.data,
9590
+ isSupervisorSearchLoading = _Digit$Hooks$fsm$useS.isLoading;
9591
+ const matchedVendor = React.useMemo(() => {
9592
+ var _vendorSearchResponse, _vendorSearchResponse2;
9593
+ if (!vendorSearchResponse) return null;
9594
+ const userUuid = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uuid;
9595
+ const userMobile = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.mobileNumber;
9596
+ return ((_vendorSearchResponse = vendorSearchResponse.find(v => {
9597
+ var _actualVendor$owner, _actualVendor$owner2, _actualVendor$owner3;
9598
+ const actualVendor = v.dsoDetails || v;
9599
+ const ownerUuid = ((_actualVendor$owner = actualVendor.owner) === null || _actualVendor$owner === void 0 ? void 0 : _actualVendor$owner.uuid) || ((_actualVendor$owner2 = actualVendor.owner) === null || _actualVendor$owner2 === void 0 ? void 0 : _actualVendor$owner2.id);
9600
+ const ownerMobile = ((_actualVendor$owner3 = actualVendor.owner) === null || _actualVendor$owner3 === void 0 ? void 0 : _actualVendor$owner3.mobileNumber) || actualVendor.mobileNumber;
9601
+ return userUuid && ownerUuid === userUuid || userMobile && ownerMobile === userMobile;
9602
+ })) === null || _vendorSearchResponse === void 0 ? void 0 : _vendorSearchResponse.dsoDetails) || ((_vendorSearchResponse2 = vendorSearchResponse[0]) === null || _vendorSearchResponse2 === void 0 ? void 0 : _vendorSearchResponse2.dsoDetails) || vendorSearchResponse[0];
9603
+ }, [vendorSearchResponse, loggedInUser]);
9604
+ const matchedSupervisor = React.useMemo(() => {
9605
+ if (!(supervisorSearchResponse !== null && supervisorSearchResponse !== void 0 && supervisorSearchResponse.supervisors)) return null;
9606
+ return supervisorSearchResponse.supervisors.find(s => {
9607
+ var _s$id, _loggedInUser$uuid, _s$owner, _s$owner$uuid, _loggedInUser$uuid2, _s$owner2;
9608
+ return ((_s$id = s.id) === null || _s$id === void 0 ? void 0 : _s$id.toLowerCase()) === (loggedInUser === null || loggedInUser === void 0 ? void 0 : (_loggedInUser$uuid = loggedInUser.uuid) === null || _loggedInUser$uuid === void 0 ? void 0 : _loggedInUser$uuid.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()) === (loggedInUser === null || loggedInUser === void 0 ? void 0 : (_loggedInUser$uuid2 = loggedInUser.uuid) === null || _loggedInUser$uuid2 === void 0 ? void 0 : _loggedInUser$uuid2.toLowerCase()) || ((_s$owner2 = s.owner) === null || _s$owner2 === void 0 ? void 0 : _s$owner2.mobileNumber) === (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.mobileNumber) || s.mobileNo === (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.mobileNumber);
9609
+ });
9610
+ }, [supervisorSearchResponse, loggedInUser]);
9455
9611
  const _Digit$Hooks$useCommo = Digit.Hooks.useCommonMDMS(tenantId, "egov-location", ["TenantBoundary"]),
9456
9612
  boundaryData = _Digit$Hooks$useCommo.data,
9457
9613
  isLoading = _Digit$Hooks$useCommo.isLoading;
@@ -9464,19 +9620,19 @@ const SelectEkycZones = _ref => {
9464
9620
  code: zone.code,
9465
9621
  name: zone.name
9466
9622
  })));
9467
- const zonesList = [...new Map(allZones.map(z => [z.code, z])).values()];
9623
+ let zonesList = [...new Map(allZones.map(z => [z.code, z])).values()];
9468
9624
  setZones(zonesList);
9469
9625
  }
9470
- }, [boundaryData]);
9626
+ }, [boundaryData, isEkycVendor, matchedVendor, isEkycSupervisor, matchedSupervisor, isVendorPage]);
9471
9627
  useEffect(() => {
9472
9628
  if (!zones.length || !(formData !== null && formData !== void 0 && formData.zoneIds)) return;
9473
9629
  if (isMultiSelect) {
9474
9630
  if (!Array.isArray(formData.zoneIds)) return;
9475
- if (formData.zoneIds.length && typeof formData.zoneIds[0] === "object") {
9476
- setSelectedZones(formData.zoneIds);
9631
+ if (formData.zoneIds.length && typeof formData.zoneIds[0] === "object" && formData.zoneIds[0] !== null) {
9632
+ setSelectedZones(formData.zoneIds.filter(Boolean));
9477
9633
  return;
9478
9634
  }
9479
- const selected = zones.filter(zone => formData.zoneIds.includes(zone.name) || formData.zoneIds.includes(zone.code));
9635
+ const selected = zones.filter(zone => zone && (formData.zoneIds.includes(zone.name) || formData.zoneIds.includes(zone.code)));
9480
9636
  setSelectedZones(selected);
9481
9637
  if (!initialized.current) {
9482
9638
  initialized.current = true;
@@ -9488,10 +9644,10 @@ const SelectEkycZones = _ref => {
9488
9644
  var _selectedVal$, _selectedVal$2;
9489
9645
  selectedVal = ((_selectedVal$ = selectedVal[0]) === null || _selectedVal$ === void 0 ? void 0 : _selectedVal$.name) || ((_selectedVal$2 = selectedVal[0]) === null || _selectedVal$2 === void 0 ? void 0 : _selectedVal$2.code) || selectedVal[0] || "";
9490
9646
  }
9491
- if (typeof selectedVal === "object") {
9647
+ if (selectedVal && typeof selectedVal === "object") {
9492
9648
  selectedVal = selectedVal.name || selectedVal.code || "";
9493
9649
  }
9494
- const selected = zones.find(zone => zone.name === selectedVal || zone.code === selectedVal);
9650
+ const selected = zones.find(zone => zone && (zone.name === selectedVal || zone.code === selectedVal));
9495
9651
  setSelectedZones(selected ? [selected] : []);
9496
9652
  if (!initialized.current && selected) {
9497
9653
  initialized.current = true;
@@ -9499,6 +9655,13 @@ const SelectEkycZones = _ref => {
9499
9655
  }
9500
9656
  }
9501
9657
  }, [zones, formData === null || formData === void 0 ? void 0 : formData.zoneIds, config.key, onSelect, isMultiSelect]);
9658
+ useEffect(() => {
9659
+ if (isEkycSupervisor && zones.length > 0 && !(formData !== null && formData !== void 0 && formData.zoneIds) && !initialized.current) {
9660
+ initialized.current = true;
9661
+ setSelectedZones([zones[0]]);
9662
+ onSelect(config.key, zones[0].name || "");
9663
+ }
9664
+ }, [isEkycSupervisor, zones, formData === null || formData === void 0 ? void 0 : formData.zoneIds, config.key, onSelect]);
9502
9665
  const handleSelect = value => {
9503
9666
  if (isMultiSelect) {
9504
9667
  const selected = Array.isArray(value) ? value.map(v => Array.isArray(v) ? v[1] : v).filter(Boolean) : [];
@@ -9510,7 +9673,7 @@ const SelectEkycZones = _ref => {
9510
9673
  onSelect(config.key, (selectedZone === null || selectedZone === void 0 ? void 0 : selectedZone.name) || "");
9511
9674
  }
9512
9675
  };
9513
- if (isLoading) return /*#__PURE__*/React.createElement(Loader, null);
9676
+ if (isLoading || isEkycVendor && !isVendorPage && isVendorSearchLoading || isEkycSupervisor && isSupervisorSearchLoading) return /*#__PURE__*/React.createElement(Loader, null);
9514
9677
  return /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t(config.label), config.isMandatory ? /*#__PURE__*/React.createElement("span", {
9515
9678
  className: "check-page-link-button"
9516
9679
  }, " * ") : ""), /*#__PURE__*/React.createElement("div", {
@@ -9531,10 +9694,11 @@ const SelectEkycZones = _ref => {
9531
9694
  ServerStyle: {
9532
9695
  backgroundColor: "#fff"
9533
9696
  },
9534
- defaultLabel: isMultiSelect ? selectedZones.length + " Selected" : ""
9697
+ defaultLabel: isMultiSelect ? selectedZones.length + " Selected" : "",
9698
+ disable: disable || isEkycSupervisor || ((_config$props = config.props) === null || _config$props === void 0 ? void 0 : _config$props.disable) || config.disable
9535
9699
  })), isMultiSelect && selectedZones.length > 0 && /*#__PURE__*/React.createElement("div", {
9536
9700
  className: "selected-zones"
9537
- }, selectedZones.map(zone => /*#__PURE__*/React.createElement("span", {
9701
+ }, selectedZones.filter(zone => zone && zone.code).map(zone => /*#__PURE__*/React.createElement("span", {
9538
9702
  key: zone.code,
9539
9703
  className: "selected-zone-chip"
9540
9704
  }, zone.name))));