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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -53,10 +53,20 @@ const SurveyorConfig = function (t, agencies, reportingManagers, disabled) {
53
53
  populators: {
54
54
  name: "fullName",
55
55
  validation: {
56
- required: true,
57
- pattern: /^[A-Za-z\s]+$/
56
+ required: {
57
+ value: true,
58
+ message: t("ES_VENDOR_INVALID_NAME")
59
+ },
60
+ maxLength: {
61
+ value: 49,
62
+ message: t("ES_VENDOR_NAME_MAX_50_CHARACTERS")
63
+ },
64
+ pattern: {
65
+ value: /^[A-Za-z\s]+$/,
66
+ message: t("ES_VENDOR_INVALID_NAME")
67
+ }
58
68
  },
59
- error: t("ES_VENDOR_INVALID_NAME")
69
+ maxlength: 50
60
70
  }
61
71
  }, {
62
72
  label: "ES_VENDOR_SURVEYOR_MOBILE_NUMBER",
@@ -635,7 +645,7 @@ const DropdownStatus = _ref => {
635
645
  };
636
646
 
637
647
  const RegisteredVendorSearch = _ref => {
638
- 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;
648
+ 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;
639
649
  let onSearch = _ref.onSearch,
640
650
  type = _ref.type,
641
651
  onClose = _ref.onClose,
@@ -781,7 +791,7 @@ const RegisteredVendorSearch = _ref => {
781
791
  onClick: onClose
782
792
  }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.CloseSvg, null))), /*#__PURE__*/React__default.createElement("div", {
783
793
  className: "search-tabs-container"
784
- }, /*#__PURE__*/React__default.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__default.createElement("button", {
794
+ }, /*#__PURE__*/React__default.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__default.createElement("button", {
785
795
  className: selectedTab === "VENDOR" ? "search-tab-head-selected" : "search-tab-head",
786
796
  onClick: () => {
787
797
  clearSearch();
@@ -799,13 +809,13 @@ const RegisteredVendorSearch = _ref => {
799
809
  clearSearch();
800
810
  onTabChange("DRIVER");
801
811
  }
802
- }, 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__default.createElement("button", {
812
+ }, 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__default.createElement("button", {
803
813
  className: selectedTab === "SUPERVISOR" ? "search-tab-head-selected" : "search-tab-head",
804
814
  onClick: () => {
805
815
  clearSearch();
806
816
  onTabChange("SUPERVISOR");
807
817
  }
808
- }, 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__default.createElement("button", {
818
+ }, 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__default.createElement("button", {
809
819
  className: selectedTab === "SURVEYOR" ? "search-tab-head-selected" : "search-tab-head",
810
820
  onClick: () => {
811
821
  clearSearch();
@@ -2527,7 +2537,7 @@ const SearchVendor = () => {
2527
2537
  const userInfo = Digit.UserService.getUser();
2528
2538
  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)) || [];
2529
2539
  const location = reactRouterDom.useLocation();
2530
- 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" : "";
2540
+ 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" : "";
2531
2541
  const _Digit$Hooks$useQuery = Digit.Hooks.useQueryParams(),
2532
2542
  selectedTabs = _Digit$Hooks$useQuery.selectedTabs;
2533
2543
  const _useState = React.useState(selectedTabs || initialPage),
@@ -3356,15 +3366,22 @@ const SupervisorConfig = function (t, agencies, reportingManagers, disabled) {
3356
3366
  populators: {
3357
3367
  name: "fullName",
3358
3368
  validation: {
3359
- required: true,
3369
+ required: {
3370
+ value: true,
3371
+ message: t("ES_VENDOR_INVALID_NAME")
3372
+ },
3373
+ maxLength: {
3374
+ value: 49,
3375
+ message: t("ES_VENDOR_NAME_MAX_50_CHARACTERS")
3376
+ },
3360
3377
  pattern: {
3361
3378
  value: /^[A-Za-z\s]+$/,
3362
3379
  message: t("ES_VENDOR_INVALID_NAME")
3363
3380
  }
3364
3381
  },
3365
- error: t("ES_VENDOR_INVALID_NAME"),
3366
3382
  defaultValue: "",
3367
- className: "payment-form-text-input-correction"
3383
+ className: "payment-form-text-input-correction",
3384
+ maxlength: 50
3368
3385
  }
3369
3386
  }, {
3370
3387
  label: t("ES_VENDOR_SUPERVISOR_MOBILE_NUMBER"),
@@ -3897,7 +3914,7 @@ const formatLabel = key => {
3897
3914
  return result.charAt(0).toUpperCase() + result.slice(1);
3898
3915
  };
3899
3916
  const VendorDetails = () => {
3900
- var _dsoData$, _dsoData$$dsoDetails, _vendorAdditionalData, _vendorAdditionalData2, _vendorAdditionalData3, _parsedAdditionalDeta, _userInfo$info$type, _dsoData$5, _dsoData$5$employeeRe, _supervisorData$super, _surveyorData$surveyo;
3917
+ 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;
3901
3918
  const tenantId = Digit.ULBService.getCurrentTenantId();
3902
3919
  const _useTranslation = reactI18next.useTranslation(),
3903
3920
  t = _useTranslation.t;
@@ -4003,6 +4020,8 @@ const VendorDetails = () => {
4003
4020
  }
4004
4021
  const userInfo = Digit.SessionStorage.get("User");
4005
4022
  const userType = (_userInfo$info$type = userInfo.info.type) === null || _userInfo$info$type === void 0 ? void 0 : _userInfo$info$type.toLowerCase();
4023
+ 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)) || [];
4024
+ const isEkycVendor = userRoles.includes("EKYC_VENDOR");
4006
4025
  React.useEffect(() => {
4007
4026
  switch (selectedAction) {
4008
4027
  case "DELETE":
@@ -4378,7 +4397,7 @@ const VendorDetails = () => {
4378
4397
  manualPagination: false,
4379
4398
  pageSizeLimit: 10,
4380
4399
  t: t
4381
- }), /*#__PURE__*/React__default.createElement("div", {
4400
+ }), isEkycVendor && /*#__PURE__*/React__default.createElement("div", {
4382
4401
  className: "add-details-link hover-button",
4383
4402
  onClick: () => history.push("/digit-ui/" + userType + "/vendor/registry/new-supervisor?vendorId=" + (dsoId || vendorId))
4384
4403
  }, t("ES_VENDOR_ADD_SUPERVISOR"))), /*#__PURE__*/React__default.createElement(digitUiReactComponents.CardSectionHeader, {
@@ -4394,7 +4413,10 @@ const VendorDetails = () => {
4394
4413
  manualPagination: false,
4395
4414
  pageSizeLimit: 10,
4396
4415
  t: t
4397
- })))), showModal && /*#__PURE__*/React__default.createElement(digitUiReactComponents.Modal, {
4416
+ }), isEkycVendor && /*#__PURE__*/React__default.createElement("div", {
4417
+ className: "add-details-link hover-button",
4418
+ onClick: () => history.push("/digit-ui/" + userType + "/vendor/registry/new-surveyor?vendorId=" + (dsoId || vendorId))
4419
+ }, t("ES_VENDOR_ADD_SURVEYOR"))))), showModal && /*#__PURE__*/React__default.createElement(digitUiReactComponents.Modal, {
4398
4420
  headerBarMain: /*#__PURE__*/React__default.createElement("h1", {
4399
4421
  className: "heading-m"
4400
4422
  }, 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")),
@@ -9441,6 +9463,7 @@ const VehicleDetails = props => {
9441
9463
  };
9442
9464
 
9443
9465
  const SelectEkycZones = _ref => {
9466
+ var _Digit$SessionStorage, _loggedInUser$roles;
9444
9467
  let config = _ref.config,
9445
9468
  onSelect = _ref.onSelect,
9446
9469
  t = _ref.t,
@@ -9455,6 +9478,29 @@ const SelectEkycZones = _ref => {
9455
9478
  selectedZones = _useState2[0],
9456
9479
  setSelectedZones = _useState2[1];
9457
9480
  const initialized = React.useRef(false);
9481
+ const loggedInUser = (_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : _Digit$SessionStorage.info;
9482
+ 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)) || [];
9483
+ const isEkycVendor = roles.includes("EKYC_VENDOR");
9484
+ const _Digit$Hooks$fsm$useD = Digit.Hooks.fsm.useDsoSearch(tenantId, {
9485
+ status: "ACTIVE"
9486
+ }, {
9487
+ enabled: isEkycVendor
9488
+ }),
9489
+ vendorSearchResponse = _Digit$Hooks$fsm$useD.data,
9490
+ isVendorSearchLoading = _Digit$Hooks$fsm$useD.isLoading;
9491
+ const matchedVendor = React__default.useMemo(() => {
9492
+ var _vendorSearchResponse, _vendorSearchResponse2;
9493
+ if (!vendorSearchResponse) return null;
9494
+ const userUuid = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uuid;
9495
+ const userMobile = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.mobileNumber;
9496
+ return ((_vendorSearchResponse = vendorSearchResponse.find(v => {
9497
+ var _actualVendor$owner, _actualVendor$owner2, _actualVendor$owner3;
9498
+ const actualVendor = v.dsoDetails || v;
9499
+ 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);
9500
+ const ownerMobile = ((_actualVendor$owner3 = actualVendor.owner) === null || _actualVendor$owner3 === void 0 ? void 0 : _actualVendor$owner3.mobileNumber) || actualVendor.mobileNumber;
9501
+ return userUuid && ownerUuid === userUuid || userMobile && ownerMobile === userMobile;
9502
+ })) === null || _vendorSearchResponse === void 0 ? void 0 : _vendorSearchResponse.dsoDetails) || ((_vendorSearchResponse2 = vendorSearchResponse[0]) === null || _vendorSearchResponse2 === void 0 ? void 0 : _vendorSearchResponse2.dsoDetails) || vendorSearchResponse[0];
9503
+ }, [vendorSearchResponse, loggedInUser]);
9458
9504
  const _Digit$Hooks$useCommo = Digit.Hooks.useCommonMDMS(tenantId, "egov-location", ["TenantBoundary"]),
9459
9505
  boundaryData = _Digit$Hooks$useCommo.data,
9460
9506
  isLoading = _Digit$Hooks$useCommo.isLoading;
@@ -9467,10 +9513,14 @@ const SelectEkycZones = _ref => {
9467
9513
  code: zone.code,
9468
9514
  name: zone.name
9469
9515
  })));
9470
- const zonesList = [...new Map(allZones.map(z => [z.code, z])).values()];
9516
+ let zonesList = [...new Map(allZones.map(z => [z.code, z])).values()];
9517
+ if (isEkycVendor && matchedVendor !== null && matchedVendor !== void 0 && matchedVendor.zoneIds) {
9518
+ const assignedZoneCodes = matchedVendor.zoneIds.map(z => String(z).toUpperCase());
9519
+ zonesList = zonesList.filter(z => assignedZoneCodes.includes(String(z.code).toUpperCase()) || assignedZoneCodes.includes(String(z.name).toUpperCase()));
9520
+ }
9471
9521
  setZones(zonesList);
9472
9522
  }
9473
- }, [boundaryData]);
9523
+ }, [boundaryData, isEkycVendor, matchedVendor]);
9474
9524
  React.useEffect(() => {
9475
9525
  if (!zones.length || !(formData !== null && formData !== void 0 && formData.zoneIds)) return;
9476
9526
  if (isMultiSelect) {
@@ -9513,7 +9563,7 @@ const SelectEkycZones = _ref => {
9513
9563
  onSelect(config.key, (selectedZone === null || selectedZone === void 0 ? void 0 : selectedZone.name) || "");
9514
9564
  }
9515
9565
  };
9516
- if (isLoading) return /*#__PURE__*/React__default.createElement(digitUiReactComponents.Loader, null);
9566
+ if (isLoading || isEkycVendor && isVendorSearchLoading) return /*#__PURE__*/React__default.createElement(digitUiReactComponents.Loader, null);
9517
9567
  return /*#__PURE__*/React__default.createElement(digitUiReactComponents.LabelFieldPair, null, /*#__PURE__*/React__default.createElement(digitUiReactComponents.CardLabel, null, t(config.label), config.isMandatory ? /*#__PURE__*/React__default.createElement("span", {
9518
9568
  className: "check-page-link-button"
9519
9569
  }, " * ") : ""), /*#__PURE__*/React__default.createElement("div", {