@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.
@@ -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",
@@ -632,7 +642,7 @@ const DropdownStatus = _ref => {
632
642
  };
633
643
 
634
644
  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;
645
+ 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
646
  let onSearch = _ref.onSearch,
637
647
  type = _ref.type,
638
648
  onClose = _ref.onClose,
@@ -778,7 +788,7 @@ const RegisteredVendorSearch = _ref => {
778
788
  onClick: onClose
779
789
  }, /*#__PURE__*/React.createElement(CloseSvg, null))), /*#__PURE__*/React.createElement("div", {
780
790
  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", {
791
+ }, /*#__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
792
  className: selectedTab === "VENDOR" ? "search-tab-head-selected" : "search-tab-head",
783
793
  onClick: () => {
784
794
  clearSearch();
@@ -796,13 +806,13 @@ const RegisteredVendorSearch = _ref => {
796
806
  clearSearch();
797
807
  onTabChange("DRIVER");
798
808
  }
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", {
809
+ }, 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
810
  className: selectedTab === "SUPERVISOR" ? "search-tab-head-selected" : "search-tab-head",
801
811
  onClick: () => {
802
812
  clearSearch();
803
813
  onTabChange("SUPERVISOR");
804
814
  }
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", {
815
+ }, 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
816
  className: selectedTab === "SURVEYOR" ? "search-tab-head-selected" : "search-tab-head",
807
817
  onClick: () => {
808
818
  clearSearch();
@@ -2524,7 +2534,7 @@ const SearchVendor = () => {
2524
2534
  const userInfo = Digit.UserService.getUser();
2525
2535
  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
2536
  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" : "";
2537
+ 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
2538
  const _Digit$Hooks$useQuery = Digit.Hooks.useQueryParams(),
2529
2539
  selectedTabs = _Digit$Hooks$useQuery.selectedTabs;
2530
2540
  const _useState = useState(selectedTabs || initialPage),
@@ -3353,15 +3363,22 @@ const SupervisorConfig = function (t, agencies, reportingManagers, disabled) {
3353
3363
  populators: {
3354
3364
  name: "fullName",
3355
3365
  validation: {
3356
- required: true,
3366
+ required: {
3367
+ value: true,
3368
+ message: t("ES_VENDOR_INVALID_NAME")
3369
+ },
3370
+ maxLength: {
3371
+ value: 49,
3372
+ message: t("ES_VENDOR_NAME_MAX_50_CHARACTERS")
3373
+ },
3357
3374
  pattern: {
3358
3375
  value: /^[A-Za-z\s]+$/,
3359
3376
  message: t("ES_VENDOR_INVALID_NAME")
3360
3377
  }
3361
3378
  },
3362
- error: t("ES_VENDOR_INVALID_NAME"),
3363
3379
  defaultValue: "",
3364
- className: "payment-form-text-input-correction"
3380
+ className: "payment-form-text-input-correction",
3381
+ maxlength: 50
3365
3382
  }
3366
3383
  }, {
3367
3384
  label: t("ES_VENDOR_SUPERVISOR_MOBILE_NUMBER"),
@@ -3894,7 +3911,7 @@ const formatLabel = key => {
3894
3911
  return result.charAt(0).toUpperCase() + result.slice(1);
3895
3912
  };
3896
3913
  const VendorDetails = () => {
3897
- var _dsoData$, _dsoData$$dsoDetails, _vendorAdditionalData, _vendorAdditionalData2, _vendorAdditionalData3, _parsedAdditionalDeta, _userInfo$info$type, _dsoData$5, _dsoData$5$employeeRe, _supervisorData$super, _surveyorData$surveyo;
3914
+ 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
3915
  const tenantId = Digit.ULBService.getCurrentTenantId();
3899
3916
  const _useTranslation = useTranslation(),
3900
3917
  t = _useTranslation.t;
@@ -4000,6 +4017,8 @@ const VendorDetails = () => {
4000
4017
  }
4001
4018
  const userInfo = Digit.SessionStorage.get("User");
4002
4019
  const userType = (_userInfo$info$type = userInfo.info.type) === null || _userInfo$info$type === void 0 ? void 0 : _userInfo$info$type.toLowerCase();
4020
+ 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)) || [];
4021
+ const isEkycVendor = userRoles.includes("EKYC_VENDOR");
4003
4022
  useEffect(() => {
4004
4023
  switch (selectedAction) {
4005
4024
  case "DELETE":
@@ -4375,7 +4394,7 @@ const VendorDetails = () => {
4375
4394
  manualPagination: false,
4376
4395
  pageSizeLimit: 10,
4377
4396
  t: t
4378
- }), /*#__PURE__*/React.createElement("div", {
4397
+ }), isEkycVendor && /*#__PURE__*/React.createElement("div", {
4379
4398
  className: "add-details-link hover-button",
4380
4399
  onClick: () => history.push("/digit-ui/" + userType + "/vendor/registry/new-supervisor?vendorId=" + (dsoId || vendorId))
4381
4400
  }, t("ES_VENDOR_ADD_SUPERVISOR"))), /*#__PURE__*/React.createElement(CardSectionHeader, {
@@ -4391,7 +4410,10 @@ const VendorDetails = () => {
4391
4410
  manualPagination: false,
4392
4411
  pageSizeLimit: 10,
4393
4412
  t: t
4394
- })))), showModal && /*#__PURE__*/React.createElement(Modal, {
4413
+ }), isEkycVendor && /*#__PURE__*/React.createElement("div", {
4414
+ className: "add-details-link hover-button",
4415
+ onClick: () => history.push("/digit-ui/" + userType + "/vendor/registry/new-surveyor?vendorId=" + (dsoId || vendorId))
4416
+ }, t("ES_VENDOR_ADD_SURVEYOR"))))), showModal && /*#__PURE__*/React.createElement(Modal, {
4395
4417
  headerBarMain: /*#__PURE__*/React.createElement("h1", {
4396
4418
  className: "heading-m"
4397
4419
  }, 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")),
@@ -9438,6 +9460,7 @@ const VehicleDetails = props => {
9438
9460
  };
9439
9461
 
9440
9462
  const SelectEkycZones = _ref => {
9463
+ var _Digit$SessionStorage, _loggedInUser$roles;
9441
9464
  let config = _ref.config,
9442
9465
  onSelect = _ref.onSelect,
9443
9466
  t = _ref.t,
@@ -9452,6 +9475,29 @@ const SelectEkycZones = _ref => {
9452
9475
  selectedZones = _useState2[0],
9453
9476
  setSelectedZones = _useState2[1];
9454
9477
  const initialized = useRef(false);
9478
+ const loggedInUser = (_Digit$SessionStorage = Digit.SessionStorage.get("User")) === null || _Digit$SessionStorage === void 0 ? void 0 : _Digit$SessionStorage.info;
9479
+ 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)) || [];
9480
+ const isEkycVendor = roles.includes("EKYC_VENDOR");
9481
+ const _Digit$Hooks$fsm$useD = Digit.Hooks.fsm.useDsoSearch(tenantId, {
9482
+ status: "ACTIVE"
9483
+ }, {
9484
+ enabled: isEkycVendor
9485
+ }),
9486
+ vendorSearchResponse = _Digit$Hooks$fsm$useD.data,
9487
+ isVendorSearchLoading = _Digit$Hooks$fsm$useD.isLoading;
9488
+ const matchedVendor = React.useMemo(() => {
9489
+ var _vendorSearchResponse, _vendorSearchResponse2;
9490
+ if (!vendorSearchResponse) return null;
9491
+ const userUuid = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uuid;
9492
+ const userMobile = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.mobileNumber;
9493
+ return ((_vendorSearchResponse = vendorSearchResponse.find(v => {
9494
+ var _actualVendor$owner, _actualVendor$owner2, _actualVendor$owner3;
9495
+ const actualVendor = v.dsoDetails || v;
9496
+ 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);
9497
+ const ownerMobile = ((_actualVendor$owner3 = actualVendor.owner) === null || _actualVendor$owner3 === void 0 ? void 0 : _actualVendor$owner3.mobileNumber) || actualVendor.mobileNumber;
9498
+ return userUuid && ownerUuid === userUuid || userMobile && ownerMobile === userMobile;
9499
+ })) === null || _vendorSearchResponse === void 0 ? void 0 : _vendorSearchResponse.dsoDetails) || ((_vendorSearchResponse2 = vendorSearchResponse[0]) === null || _vendorSearchResponse2 === void 0 ? void 0 : _vendorSearchResponse2.dsoDetails) || vendorSearchResponse[0];
9500
+ }, [vendorSearchResponse, loggedInUser]);
9455
9501
  const _Digit$Hooks$useCommo = Digit.Hooks.useCommonMDMS(tenantId, "egov-location", ["TenantBoundary"]),
9456
9502
  boundaryData = _Digit$Hooks$useCommo.data,
9457
9503
  isLoading = _Digit$Hooks$useCommo.isLoading;
@@ -9464,10 +9510,14 @@ const SelectEkycZones = _ref => {
9464
9510
  code: zone.code,
9465
9511
  name: zone.name
9466
9512
  })));
9467
- const zonesList = [...new Map(allZones.map(z => [z.code, z])).values()];
9513
+ let zonesList = [...new Map(allZones.map(z => [z.code, z])).values()];
9514
+ if (isEkycVendor && matchedVendor !== null && matchedVendor !== void 0 && matchedVendor.zoneIds) {
9515
+ const assignedZoneCodes = matchedVendor.zoneIds.map(z => String(z).toUpperCase());
9516
+ zonesList = zonesList.filter(z => assignedZoneCodes.includes(String(z.code).toUpperCase()) || assignedZoneCodes.includes(String(z.name).toUpperCase()));
9517
+ }
9468
9518
  setZones(zonesList);
9469
9519
  }
9470
- }, [boundaryData]);
9520
+ }, [boundaryData, isEkycVendor, matchedVendor]);
9471
9521
  useEffect(() => {
9472
9522
  if (!zones.length || !(formData !== null && formData !== void 0 && formData.zoneIds)) return;
9473
9523
  if (isMultiSelect) {
@@ -9510,7 +9560,7 @@ const SelectEkycZones = _ref => {
9510
9560
  onSelect(config.key, (selectedZone === null || selectedZone === void 0 ? void 0 : selectedZone.name) || "");
9511
9561
  }
9512
9562
  };
9513
- if (isLoading) return /*#__PURE__*/React.createElement(Loader, null);
9563
+ if (isLoading || isEkycVendor && isVendorSearchLoading) return /*#__PURE__*/React.createElement(Loader, null);
9514
9564
  return /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t(config.label), config.isMandatory ? /*#__PURE__*/React.createElement("span", {
9515
9565
  className: "check-page-link-button"
9516
9566
  }, " * ") : ""), /*#__PURE__*/React.createElement("div", {