@djb25/digit-ui-module-vendor 1.0.81 → 1.0.83

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.
@@ -764,6 +764,9 @@ const RegisteredVendorSearch = _ref => {
764
764
  const _useState = useState(false),
765
765
  showAddMenu = _useState[0],
766
766
  setShowAddMenu = _useState[1];
767
+ const _useState2 = useState(null),
768
+ showToast = _useState2[0],
769
+ setShowToast = _useState2[1];
767
770
  const mobileView = window.Digit.Utils.browser.isMobile();
768
771
  const FSTP = Digit.UserService.hasAccess("FSM_EMP_FSTPO") || false;
769
772
  const onSubmitInput = data => {
@@ -818,6 +821,9 @@ const RegisteredVendorSearch = _ref => {
818
821
  return history.push("/digit-ui/" + userPath + "/vendor/registry/new-surveyor");
819
822
  }
820
823
  }
824
+ const closeToast = () => {
825
+ setShowToast(null);
826
+ };
821
827
  const getFields = input => {
822
828
  switch (input.type) {
823
829
  case "date":
@@ -952,7 +958,12 @@ const RegisteredVendorSearch = _ref => {
952
958
  className: "submit-bar-search",
953
959
  label: t("ES_COMMON_SEARCH"),
954
960
  submit: true
955
- })))))));
961
+ })))))), showToast && /*#__PURE__*/React.createElement(Toast, {
962
+ error: (showToast === null || showToast === void 0 ? void 0 : showToast.key) === "error",
963
+ label: t(showToast === null || showToast === void 0 ? void 0 : showToast.action),
964
+ onClose: closeToast,
965
+ duration: 5000
966
+ }));
956
967
  };
957
968
 
958
969
  const _excluded$2 = ["id"];
@@ -1114,6 +1125,8 @@ const VendorInbox = props => {
1114
1125
  const userInfo = Digit.SessionStorage.get("User");
1115
1126
  const userRoles = userInfo.info.roles;
1116
1127
  const userType = (_userInfo$info$type = userInfo.info.type) === null || _userInfo$info$type === void 0 ? void 0 : _userInfo$info$type.toLowerCase();
1128
+ const isEmployee = userType === "employee";
1129
+ const isEkycSupervisor = userRoles.some(role => role.code === "EKYC_SUPERVISOR");
1117
1130
  const isVendor = Digit.Utils.vendorAccess() || Digit.UserService.hasAccess(["WT_VENDOR", "EKYC_VENDOR", "VENDOR", "FSM_VENDOR", "DSO", "FSM_DSO"]) || (userRoles === null || userRoles === void 0 ? void 0 : userRoles.some(role => ["FSM_VENDOR", "VENDOR", "EKYC_VENDOR", "WT_VENDOR", "DSO", "FSM_DSO"].includes(typeof role === "string" ? role : role === null || role === void 0 ? void 0 : role.code))) || userType === "vendor";
1118
1131
  const EKYC_ROLES = ["EKYC_SUPERVISOR", "EKYC_SURVEYOR"];
1119
1132
  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));
@@ -1224,7 +1237,8 @@ const VendorInbox = props => {
1224
1237
  mutateVehicle = _Digit$Hooks$fsm$useU.mutate;
1225
1238
  const _Digit$Hooks$fsm$useD3 = Digit.Hooks.fsm.useDriverUpdate(tenantId),
1226
1239
  mutateDriver = _Digit$Hooks$fsm$useD3.mutate;
1227
- const _Digit$Hooks$fsm$useS = Digit.Hooks.fsm.useSupervisorUpdate(tenantId);
1240
+ const _Digit$Hooks$fsm$useS = Digit.Hooks.fsm.useSupervisorUpdate(tenantId),
1241
+ mutateSupervisor = _Digit$Hooks$fsm$useS.mutate;
1228
1242
  const _Digit$Hooks$fsm$useS2 = Digit.Hooks.fsm.useSurveyorUpdate(tenantId),
1229
1243
  mutateSurveyor = _Digit$Hooks$fsm$useS2.mutate;
1230
1244
  useEffect(() => {
@@ -1413,6 +1427,80 @@ const VendorInbox = props => {
1413
1427
  }
1414
1428
  });
1415
1429
  };
1430
+ const onSupervisorUpdate = row => {
1431
+ var _formDetails$owner9, _formDetails$owner0, _formDetails$owner1, _formDetails$owner10;
1432
+ let formDetails = row.original;
1433
+ const newStatus = (formDetails === null || formDetails === void 0 ? void 0 : formDetails.status) === "ACTIVE" ? "DISABLED" : "ACTIVE";
1434
+ const newActive = newStatus === "ACTIVE";
1435
+ const formData = {
1436
+ supervisor: _extends({}, formDetails, {
1437
+ status: newStatus,
1438
+ active: newActive,
1439
+ owner: _extends({}, formDetails === null || formDetails === void 0 ? void 0 : formDetails.owner, {
1440
+ active: newActive,
1441
+ gender: (formDetails === null || formDetails === void 0 ? void 0 : (_formDetails$owner9 = formDetails.owner) === null || _formDetails$owner9 === void 0 ? void 0 : _formDetails$owner9.gender) || "OTHERS",
1442
+ dob: (formDetails === null || formDetails === void 0 ? void 0 : (_formDetails$owner0 = formDetails.owner) === null || _formDetails$owner0 === void 0 ? void 0 : _formDetails$owner0.dob) || new Date("1/1/1970").getTime(),
1443
+ emailId: (formDetails === null || formDetails === void 0 ? void 0 : (_formDetails$owner1 = formDetails.owner) === null || _formDetails$owner1 === void 0 ? void 0 : _formDetails$owner1.emailId) || "abc@egov.com",
1444
+ relationship: (formDetails === null || formDetails === void 0 ? void 0 : (_formDetails$owner10 = formDetails.owner) === null || _formDetails$owner10 === void 0 ? void 0 : _formDetails$owner10.relationship) || "OTHER"
1445
+ })
1446
+ })
1447
+ };
1448
+ mutateSupervisor(formData, {
1449
+ onError: (error, variables) => {
1450
+ setShowToast({
1451
+ key: "error",
1452
+ action: (error === null || error === void 0 ? void 0 : error.message) || error
1453
+ });
1454
+ },
1455
+ onSuccess: (data, variables) => {
1456
+ setShowToast({
1457
+ key: "success",
1458
+ action: "SUPERVISOR",
1459
+ isDisable: newStatus === "DISABLED"
1460
+ });
1461
+ queryClient.invalidateQueries("FSM_SUPERVISOR_SEARCH");
1462
+ queryClient.invalidateQueries("SUPERVISOR_SEARCH");
1463
+ props.refetchData();
1464
+ }
1465
+ });
1466
+ };
1467
+ const onSurveyorUpdate = row => {
1468
+ var _formDetails$owner11, _formDetails$owner12, _formDetails$owner13, _formDetails$owner14;
1469
+ let formDetails = row.original;
1470
+ const newStatus = (formDetails === null || formDetails === void 0 ? void 0 : formDetails.status) === "ACTIVE" ? "DISABLED" : "ACTIVE";
1471
+ const newActive = newStatus === "ACTIVE";
1472
+ const formData = {
1473
+ surveyor: _extends({}, formDetails, {
1474
+ status: newStatus,
1475
+ active: newActive,
1476
+ owner: _extends({}, formDetails === null || formDetails === void 0 ? void 0 : formDetails.owner, {
1477
+ active: newActive,
1478
+ gender: (formDetails === null || formDetails === void 0 ? void 0 : (_formDetails$owner11 = formDetails.owner) === null || _formDetails$owner11 === void 0 ? void 0 : _formDetails$owner11.gender) || "OTHERS",
1479
+ dob: (formDetails === null || formDetails === void 0 ? void 0 : (_formDetails$owner12 = formDetails.owner) === null || _formDetails$owner12 === void 0 ? void 0 : _formDetails$owner12.dob) || new Date("1/1/1970").getTime(),
1480
+ emailId: (formDetails === null || formDetails === void 0 ? void 0 : (_formDetails$owner13 = formDetails.owner) === null || _formDetails$owner13 === void 0 ? void 0 : _formDetails$owner13.emailId) || "abc@egov.com",
1481
+ relationship: (formDetails === null || formDetails === void 0 ? void 0 : (_formDetails$owner14 = formDetails.owner) === null || _formDetails$owner14 === void 0 ? void 0 : _formDetails$owner14.relationship) || "OTHER"
1482
+ })
1483
+ })
1484
+ };
1485
+ mutateSurveyor(formData, {
1486
+ onError: (error, variables) => {
1487
+ setShowToast({
1488
+ key: "error",
1489
+ action: (error === null || error === void 0 ? void 0 : error.message) || error
1490
+ });
1491
+ },
1492
+ onSuccess: (data, variables) => {
1493
+ setShowToast({
1494
+ key: "success",
1495
+ action: "SURVEYOR",
1496
+ isDisable: newStatus === "DISABLED"
1497
+ });
1498
+ queryClient.invalidateQueries("FSM_SURVEYOR_SEARCH");
1499
+ queryClient.invalidateQueries("SURVEYOR_SEARCH");
1500
+ props.refetchData();
1501
+ }
1502
+ });
1503
+ };
1416
1504
  const onVendorSelect = (row, selectedOption) => {
1417
1505
  let driverData = row.original;
1418
1506
  let existingVendor = driverData === null || driverData === void 0 ? void 0 : driverData.vendor;
@@ -1767,7 +1855,7 @@ const VendorInbox = props => {
1767
1855
  const serviceType = ((_additionalDetails2 = additionalDetails) === null || _additionalDetails2 === void 0 ? void 0 : _additionalDetails2.serviceType) || "N/A";
1768
1856
  return /*#__PURE__*/React.createElement("div", null, serviceType);
1769
1857
  }
1770
- }, ...(!isVendor ? [{
1858
+ }, ...(isEmployee ? [{
1771
1859
  Header: t("ES_VENDOR_REGISTRY_INBOX_ENABLED"),
1772
1860
  id: "status",
1773
1861
  accessor: row => {
@@ -2142,7 +2230,7 @@ const VendorInbox = props => {
2142
2230
  width: "100%",
2143
2231
  minWidth: "250px"
2144
2232
  },
2145
- disable: !supervisors.length
2233
+ disable: !supervisors.length || isEkycSupervisor
2146
2234
  });
2147
2235
  }
2148
2236
  }] : []), {
@@ -2153,7 +2241,30 @@ const VendorInbox = props => {
2153
2241
  let row = _ref32.row;
2154
2242
  return GetCell((_row$original25 = row.original) !== null && _row$original25 !== void 0 && (_row$original25$audit = _row$original25.auditDetails) !== null && _row$original25$audit !== void 0 && _row$original25$audit.createdTime ? Digit.DateUtils.ConvertEpochToDate((_row$original26 = row.original) === null || _row$original26 === void 0 ? void 0 : (_row$original26$audit = _row$original26.auditDetails) === null || _row$original26$audit === void 0 ? void 0 : _row$original26$audit.createdTime) : "");
2155
2243
  }
2156
- }];
2244
+ }, ...(!isEmployee ? [{
2245
+ Header: t("ES_FSM_REGISTRY_INBOX_ENABLED"),
2246
+ id: "status",
2247
+ accessor: row => row.status || "",
2248
+ Cell: _ref33 => {
2249
+ var _row$original27;
2250
+ let row = _ref33.row;
2251
+ return /*#__PURE__*/React.createElement(ToggleSwitch, {
2252
+ style: {
2253
+ display: "flex",
2254
+ justifyContent: "left"
2255
+ },
2256
+ value: ((_row$original27 = row.original) === null || _row$original27 === void 0 ? void 0 : _row$original27.status) === "DISABLED" ? false : true,
2257
+ onChange: () => {
2258
+ if (props.selectedTab === "SUPERVISOR") {
2259
+ onSupervisorUpdate(row);
2260
+ } else if (props.selectedTab === "SURVEYOR") {
2261
+ onSurveyorUpdate(row);
2262
+ }
2263
+ },
2264
+ name: "switch-" + row.id
2265
+ });
2266
+ }
2267
+ }] : [])];
2157
2268
  default:
2158
2269
  return [];
2159
2270
  }
@@ -2519,7 +2630,8 @@ const VendorInbox = props => {
2519
2630
  searchParams: props.searchParams,
2520
2631
  onTabChange: props.onTabChange,
2521
2632
  selectedTab: props.selectedTab,
2522
- matchedRoles: matchedRoles
2633
+ matchedRoles: matchedRoles,
2634
+ ekycVendorCount: props.ekycVendorCount
2523
2635
  }), /*#__PURE__*/React.createElement("div", {
2524
2636
  className: "result",
2525
2637
  style: {
@@ -2702,6 +2814,11 @@ const SearchVendor = () => {
2702
2814
  vendorData = _Digit$Hooks$fsm$useD2.data,
2703
2815
  isVendorLoading = _Digit$Hooks$fsm$useD2.isLoading,
2704
2816
  refetchVendor = _Digit$Hooks$fsm$useD2.refetch;
2817
+ const ekycVendorCount = vendorData === null || vendorData === void 0 ? void 0 : vendorData.filter(ele => {
2818
+ var _ele$dsoDetails, _ele$dsoDetails$addit, _ele$dsoDetails$addit2;
2819
+ return (ele === null || ele === void 0 ? void 0 : (_ele$dsoDetails = ele.dsoDetails) === null || _ele$dsoDetails === void 0 ? void 0 : (_ele$dsoDetails$addit = _ele$dsoDetails.additionalDetails) === null || _ele$dsoDetails$addit === void 0 ? void 0 : (_ele$dsoDetails$addit2 = _ele$dsoDetails$addit.serviceType) === null || _ele$dsoDetails$addit2 === void 0 ? void 0 : _ele$dsoDetails$addit2.toLowerCase()) === "ekyc";
2820
+ }).length;
2821
+ console.log(ekycVendorCount);
2705
2822
  const inboxTotalCount = (dsoData === null || dsoData === void 0 ? void 0 : dsoData.totalCount) || 50;
2706
2823
  useEffect(() => {
2707
2824
  var _location$state;
@@ -2770,8 +2887,8 @@ const SearchVendor = () => {
2770
2887
  var _dsoData$vehicle;
2771
2888
  const vehicles = dsoData === null || dsoData === void 0 ? void 0 : (_dsoData$vehicle = dsoData.vehicle) === null || _dsoData$vehicle === void 0 ? void 0 : _dsoData$vehicle.map(data => {
2772
2889
  let vendor = vendorData.find(ele => {
2773
- var _ele$dsoDetails, _ele$dsoDetails$vehic;
2774
- return (_ele$dsoDetails = ele.dsoDetails) === null || _ele$dsoDetails === void 0 ? void 0 : (_ele$dsoDetails$vehic = _ele$dsoDetails.vehicles) === null || _ele$dsoDetails$vehic === void 0 ? void 0 : _ele$dsoDetails$vehic.find(vehicle => vehicle.id === data.id);
2890
+ var _ele$dsoDetails2, _ele$dsoDetails2$vehi;
2891
+ return (_ele$dsoDetails2 = ele.dsoDetails) === null || _ele$dsoDetails2 === void 0 ? void 0 : (_ele$dsoDetails2$vehi = _ele$dsoDetails2.vehicles) === null || _ele$dsoDetails2$vehi === void 0 ? void 0 : _ele$dsoDetails2$vehi.find(vehicle => vehicle.id === data.id);
2775
2892
  });
2776
2893
  if (vendor) {
2777
2894
  var _vendor$dsoDetails, _vendor$dsoDetails$ve;
@@ -2793,8 +2910,8 @@ const SearchVendor = () => {
2793
2910
  var _dsoData$driver;
2794
2911
  const drivers = dsoData === null || dsoData === void 0 ? void 0 : (_dsoData$driver = dsoData.driver) === null || _dsoData$driver === void 0 ? void 0 : _dsoData$driver.map(data => {
2795
2912
  let vendor = vendorData.find(ele => {
2796
- var _ele$dsoDetails2, _ele$dsoDetails2$driv;
2797
- return (_ele$dsoDetails2 = ele.dsoDetails) === null || _ele$dsoDetails2 === void 0 ? void 0 : (_ele$dsoDetails2$driv = _ele$dsoDetails2.drivers) === null || _ele$dsoDetails2$driv === void 0 ? void 0 : _ele$dsoDetails2$driv.find(driver => driver.id === data.id);
2913
+ var _ele$dsoDetails3, _ele$dsoDetails3$driv;
2914
+ return (_ele$dsoDetails3 = ele.dsoDetails) === null || _ele$dsoDetails3 === void 0 ? void 0 : (_ele$dsoDetails3$driv = _ele$dsoDetails3.drivers) === null || _ele$dsoDetails3$driv === void 0 ? void 0 : _ele$dsoDetails3$driv.find(driver => driver.id === data.id);
2798
2915
  });
2799
2916
  if (vendor) {
2800
2917
  return _extends({}, data, {
@@ -2919,7 +3036,8 @@ const SearchVendor = () => {
2919
3036
  onTabChange: onTabChange,
2920
3037
  selectedTab: tab,
2921
3038
  refetchData: refetchData,
2922
- refetchVendor: refetchVendorData
3039
+ refetchVendor: refetchVendorData,
3040
+ ekycVendorCount: ekycVendorCount
2923
3041
  }), showToast && /*#__PURE__*/React.createElement(Toast, {
2924
3042
  error: showToast.key === "error",
2925
3043
  label: t(showToast.action),
@@ -4875,7 +4993,7 @@ const AddVendor = () => {
4875
4993
  key: "error",
4876
4994
  action: "INVALID_CONTRACT_DATE"
4877
4995
  });
4878
- } else if (!isInvalid && showToast) {
4996
+ } else if (!isInvalid && (showToast === null || showToast === void 0 ? void 0 : showToast.action) === "INVALID_CONTRACT_DATE") {
4879
4997
  setShowToast(null);
4880
4998
  }
4881
4999
  }
@@ -4913,132 +5031,166 @@ const AddVendor = () => {
4913
5031
  const closeToast = () => {
4914
5032
  setShowToast(null);
4915
5033
  };
4916
- const onSubmit = data => {
4917
- var _address$city, _address$city2, _address$city3, _address$city4, _address$locality, _address$locality2, _address$ward, _address$ward2, _address$subLocality, _mergedData$plotNo, _mergedData$buildingN, _mergedData$serviceTy, _mergedData$address, _mergedData$address2, _mergedData$relations, _mergedData$gender, _mergedData$serviceTy2;
4918
- const mergedData = data;
4919
- const address = mergedData === null || mergedData === void 0 ? void 0 : mergedData.propertyAddress;
4920
- const pincode = address === null || address === void 0 ? void 0 : address.pincode;
4921
- const street = address === null || address === void 0 ? void 0 : address.streetName;
4922
- const doorNo = address === null || address === void 0 ? void 0 : address.houseNo;
4923
- const landmark = address === null || address === void 0 ? void 0 : address.landmark;
4924
- const city = address === null || address === void 0 ? void 0 : (_address$city = address.city) === null || _address$city === void 0 ? void 0 : _address$city.name;
4925
- const state = address === null || address === void 0 ? void 0 : (_address$city2 = address.city) === null || _address$city2 === void 0 ? void 0 : _address$city2.name;
4926
- const district = address === null || address === void 0 ? void 0 : (_address$city3 = address.city) === null || _address$city3 === void 0 ? void 0 : _address$city3.name;
4927
- const region = address === null || address === void 0 ? void 0 : (_address$city4 = address.city) === null || _address$city4 === void 0 ? void 0 : _address$city4.name;
4928
- const localityCode = address === null || address === void 0 ? void 0 : (_address$locality = address.locality) === null || _address$locality === void 0 ? void 0 : _address$locality.code;
4929
- const localityName = address === null || address === void 0 ? void 0 : (_address$locality2 = address.locality) === null || _address$locality2 === void 0 ? void 0 : _address$locality2.name;
4930
- const localityArea = address === null || address === void 0 ? void 0 : address.subLocality;
4931
- const wardCode = address === null || address === void 0 ? void 0 : (_address$ward = address.ward) === null || _address$ward === void 0 ? void 0 : _address$ward.code;
4932
- const wardName = address === null || address === void 0 ? void 0 : (_address$ward2 = address.ward) === null || _address$ward2 === void 0 ? void 0 : _address$ward2.name;
4933
- const subLocality = (address === null || address === void 0 ? void 0 : address.subLocality) || (address === null || address === void 0 ? void 0 : (_address$subLocality = address.subLocality) === null || _address$subLocality === void 0 ? void 0 : _address$subLocality.name) || (address === null || address === void 0 ? void 0 : address.subLocality);
4934
- const addressLine1 = address === null || address === void 0 ? void 0 : address.addressLine1;
4935
- const addressLine2 = address === null || address === void 0 ? void 0 : address.addressLine2;
4936
- const actualAssembly = address === null || address === void 0 ? void 0 : address.actualAssembly;
4937
- const actualWard = address === null || address === void 0 ? void 0 : address.actualWard;
4938
- const actualZone = address === null || address === void 0 ? void 0 : address.actualZone;
4939
- const name = mergedData === null || mergedData === void 0 ? void 0 : mergedData.vendorName;
4940
- const plotNo = mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$plotNo = mergedData.plotNo) === null || _mergedData$plotNo === void 0 ? void 0 : _mergedData$plotNo.trim();
4941
- const buildingName = mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$buildingN = mergedData.buildingName) === null || _mergedData$buildingN === void 0 ? void 0 : _mergedData$buildingN.trim();
4942
- const emailId = mergedData === null || mergedData === void 0 ? void 0 : mergedData.emailId;
4943
- const phone = mergedData === null || mergedData === void 0 ? void 0 : mergedData.phone;
4944
- const isEkyc = (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$serviceTy = mergedData.serviceType) === null || _mergedData$serviceTy === void 0 ? void 0 : _mergedData$serviceTy.code) === "EKYC";
4945
- let vendorData = {
4946
- tenantId: tenantId,
4947
- name,
4948
- agencyType: "ULB",
4949
- paymentPreference: "post-service",
4950
- address: {
4951
- tenantId: tenantId,
4952
- landmark,
4953
- doorNo,
4954
- plotNo,
4955
- street,
4956
- city,
4957
- district,
4958
- region,
4959
- state,
4960
- country: "india",
4961
- pincode,
4962
- buildingName,
4963
- locality: {
4964
- code: localityCode || "",
4965
- name: localityName || "",
4966
- label: "Locality",
4967
- area: localityArea || ""
4968
- },
4969
- subLocality: subLocality,
4970
- addressLine1: addressLine1,
4971
- addressLine2: addressLine2,
4972
- actualAssembly,
4973
- actualWard,
4974
- actualZone,
4975
- ward: wardCode ? {
4976
- code: wardCode,
4977
- name: wardName
4978
- } : undefined,
4979
- geoLocation: {
4980
- latitude: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$address = mergedData.address) === null || _mergedData$address === void 0 ? void 0 : _mergedData$address.latitude) || 28.6139,
4981
- longitude: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$address2 = mergedData.address) === null || _mergedData$address2 === void 0 ? void 0 : _mergedData$address2.longitude) || 77.209
4982
- }
4983
- },
4984
- owner: {
4985
- tenantId: "dl",
4986
- name: (mergedData === null || mergedData === void 0 ? void 0 : mergedData.ownerName) || name,
4987
- fatherOrHusbandName: (mergedData === null || mergedData === void 0 ? void 0 : mergedData.fatherOrHusbandName) || name,
4988
- relationship: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$relations = mergedData.relationship) === null || _mergedData$relations === void 0 ? void 0 : _mergedData$relations.code) || "OTHER",
4989
- gender: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$gender = mergedData.gender) === null || _mergedData$gender === void 0 ? void 0 : _mergedData$gender.code) || "MALE",
4990
- dob: mergedData !== null && mergedData !== void 0 && mergedData.dob ? new Date(mergedData.dob).getTime() : new Date("1/1/1970").getTime(),
4991
- emailId: emailId || "",
4992
- mobileNumber: phone
4993
- },
4994
- additionalDetails: {
4995
- serviceType: isEkyc ? "ekyc" : mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$serviceTy2 = mergedData.serviceType) === null || _mergedData$serviceTy2 === void 0 ? void 0 : _mergedData$serviceTy2.code
4996
- },
4997
- vehicles: [],
4998
- drivers: [],
4999
- source: isEkyc ? "eKYC Portal" : "WhatsApp"
5000
- };
5001
- if (isEkyc) {
5002
- var _mergedData$zoneIds, _mergedData$clusterId;
5003
- vendorData = _extends({}, vendorData, {
5004
- zoneIds: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$zoneIds = mergedData.zoneIds) === null || _mergedData$zoneIds === void 0 ? void 0 : _mergedData$zoneIds.map(z => z === null || z === void 0 ? void 0 : z.code)) || [],
5005
- clusterIds: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$clusterId = mergedData.clusterIds) === null || _mergedData$clusterId === void 0 ? void 0 : _mergedData$clusterId.map(c => {
5006
- var _c$;
5007
- return c === null || c === void 0 ? void 0 : (_c$ = c[1]) === null || _c$ === void 0 ? void 0 : _c$.code;
5008
- })) || [],
5009
- contractStartDate: mergedData.contractStartDate ? new Date(mergedData.contractStartDate).getTime() : null,
5010
- contractEndDate: mergedData.contractEndDate ? new Date(mergedData.contractEndDate).getTime() : null
5011
- });
5012
- }
5013
- const payload = {
5014
- vendor: vendorData
5015
- };
5016
- if (isEkyc) {
5017
- payload.RequestInfo = {
5018
- apiId: "Rainmaker",
5019
- msgId: "ekyc-vendor-create"
5020
- };
5021
- }
5022
- mutate(payload, {
5023
- onError: error => {
5024
- setShowToast({
5025
- key: "error",
5026
- action: (error === null || error === void 0 ? void 0 : error.message) || error
5027
- });
5034
+ const _Digit$Hooks$fsm$useV2 = Digit.Hooks.fsm.useVendorSearch({
5035
+ tenantId,
5036
+ filters: {
5037
+ status: "ACTIVE,DISABLED",
5038
+ serviceType: "ekyc"
5028
5039
  },
5029
- onSuccess: () => {
5030
- history.push({
5031
- pathname: "/digit-ui/" + userType + "/vendor/search-vendor",
5032
- state: {
5033
- showSuccessToast: true,
5034
- message: {
5035
- key: "success",
5036
- action: "ES_VENDOR_ADD_VENDOR"
5037
- }
5040
+ config: {
5041
+ enabled: false
5042
+ }
5043
+ }),
5044
+ refetch = _Digit$Hooks$fsm$useV2.refetch;
5045
+ const onSubmit = function (data) {
5046
+ try {
5047
+ var _address$city, _address$city2, _address$city3, _address$city4, _address$locality, _address$locality2, _address$ward, _address$ward2, _address$subLocality, _mergedData$plotNo, _mergedData$buildingN, _mergedData$serviceTy, _mergedData$address, _mergedData$address2, _mergedData$relations, _mergedData$gender, _mergedData$serviceTy2;
5048
+ let _exit = false;
5049
+ function _temp2(_result) {
5050
+ if (_exit) return _result;
5051
+ const payload = {
5052
+ vendor: vendorData
5053
+ };
5054
+ if (isEkyc) {
5055
+ payload.RequestInfo = {
5056
+ apiId: "Rainmaker",
5057
+ msgId: "ekyc-vendor-create"
5058
+ };
5059
+ }
5060
+ mutate(payload, {
5061
+ onError: error => {
5062
+ setShowToast({
5063
+ key: "error",
5064
+ action: (error === null || error === void 0 ? void 0 : error.message) || error
5065
+ });
5066
+ },
5067
+ onSuccess: () => {
5068
+ history.push({
5069
+ pathname: "/digit-ui/" + userType + "/vendor/search-vendor",
5070
+ state: {
5071
+ showSuccessToast: true,
5072
+ message: {
5073
+ key: "success",
5074
+ action: "ES_VENDOR_ADD_VENDOR"
5075
+ }
5076
+ }
5077
+ });
5038
5078
  }
5039
5079
  });
5040
5080
  }
5041
- });
5081
+ const mergedData = data;
5082
+ const address = mergedData === null || mergedData === void 0 ? void 0 : mergedData.propertyAddress;
5083
+ const pincode = address === null || address === void 0 ? void 0 : address.pincode;
5084
+ const street = address === null || address === void 0 ? void 0 : address.streetName;
5085
+ const doorNo = address === null || address === void 0 ? void 0 : address.houseNo;
5086
+ const landmark = address === null || address === void 0 ? void 0 : address.landmark;
5087
+ const city = address === null || address === void 0 ? void 0 : (_address$city = address.city) === null || _address$city === void 0 ? void 0 : _address$city.name;
5088
+ const state = address === null || address === void 0 ? void 0 : (_address$city2 = address.city) === null || _address$city2 === void 0 ? void 0 : _address$city2.name;
5089
+ const district = address === null || address === void 0 ? void 0 : (_address$city3 = address.city) === null || _address$city3 === void 0 ? void 0 : _address$city3.name;
5090
+ const region = address === null || address === void 0 ? void 0 : (_address$city4 = address.city) === null || _address$city4 === void 0 ? void 0 : _address$city4.name;
5091
+ const localityCode = address === null || address === void 0 ? void 0 : (_address$locality = address.locality) === null || _address$locality === void 0 ? void 0 : _address$locality.code;
5092
+ const localityName = address === null || address === void 0 ? void 0 : (_address$locality2 = address.locality) === null || _address$locality2 === void 0 ? void 0 : _address$locality2.name;
5093
+ const localityArea = address === null || address === void 0 ? void 0 : address.subLocality;
5094
+ const wardCode = address === null || address === void 0 ? void 0 : (_address$ward = address.ward) === null || _address$ward === void 0 ? void 0 : _address$ward.code;
5095
+ const wardName = address === null || address === void 0 ? void 0 : (_address$ward2 = address.ward) === null || _address$ward2 === void 0 ? void 0 : _address$ward2.name;
5096
+ const subLocality = (address === null || address === void 0 ? void 0 : address.subLocality) || (address === null || address === void 0 ? void 0 : (_address$subLocality = address.subLocality) === null || _address$subLocality === void 0 ? void 0 : _address$subLocality.name) || (address === null || address === void 0 ? void 0 : address.subLocality);
5097
+ const addressLine1 = address === null || address === void 0 ? void 0 : address.addressLine1;
5098
+ const addressLine2 = address === null || address === void 0 ? void 0 : address.addressLine2;
5099
+ const actualAssembly = address === null || address === void 0 ? void 0 : address.actualAssembly;
5100
+ const actualWard = address === null || address === void 0 ? void 0 : address.actualWard;
5101
+ const actualZone = address === null || address === void 0 ? void 0 : address.actualZone;
5102
+ const name = mergedData === null || mergedData === void 0 ? void 0 : mergedData.vendorName;
5103
+ const plotNo = mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$plotNo = mergedData.plotNo) === null || _mergedData$plotNo === void 0 ? void 0 : _mergedData$plotNo.trim();
5104
+ const buildingName = mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$buildingN = mergedData.buildingName) === null || _mergedData$buildingN === void 0 ? void 0 : _mergedData$buildingN.trim();
5105
+ const emailId = mergedData === null || mergedData === void 0 ? void 0 : mergedData.emailId;
5106
+ const phone = mergedData === null || mergedData === void 0 ? void 0 : mergedData.phone;
5107
+ const isEkyc = (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$serviceTy = mergedData.serviceType) === null || _mergedData$serviceTy === void 0 ? void 0 : _mergedData$serviceTy.code) === "EKYC";
5108
+ let vendorData = {
5109
+ tenantId: tenantId,
5110
+ name,
5111
+ agencyType: "ULB",
5112
+ paymentPreference: "post-service",
5113
+ address: {
5114
+ tenantId: tenantId,
5115
+ landmark,
5116
+ doorNo,
5117
+ plotNo,
5118
+ street,
5119
+ city,
5120
+ district,
5121
+ region,
5122
+ state,
5123
+ country: "india",
5124
+ pincode,
5125
+ buildingName,
5126
+ locality: {
5127
+ code: localityCode || "",
5128
+ name: localityName || "",
5129
+ label: "Locality",
5130
+ area: localityArea || ""
5131
+ },
5132
+ subLocality: subLocality,
5133
+ addressLine1: addressLine1,
5134
+ addressLine2: addressLine2,
5135
+ actualAssembly,
5136
+ actualWard,
5137
+ actualZone,
5138
+ ward: wardCode ? {
5139
+ code: wardCode,
5140
+ name: wardName
5141
+ } : undefined,
5142
+ geoLocation: {
5143
+ latitude: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$address = mergedData.address) === null || _mergedData$address === void 0 ? void 0 : _mergedData$address.latitude) || 28.6139,
5144
+ longitude: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$address2 = mergedData.address) === null || _mergedData$address2 === void 0 ? void 0 : _mergedData$address2.longitude) || 77.209
5145
+ }
5146
+ },
5147
+ owner: {
5148
+ tenantId: "dl",
5149
+ name: (mergedData === null || mergedData === void 0 ? void 0 : mergedData.ownerName) || name,
5150
+ fatherOrHusbandName: (mergedData === null || mergedData === void 0 ? void 0 : mergedData.fatherOrHusbandName) || name,
5151
+ relationship: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$relations = mergedData.relationship) === null || _mergedData$relations === void 0 ? void 0 : _mergedData$relations.code) || "OTHER",
5152
+ gender: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$gender = mergedData.gender) === null || _mergedData$gender === void 0 ? void 0 : _mergedData$gender.code) || "MALE",
5153
+ dob: mergedData !== null && mergedData !== void 0 && mergedData.dob ? new Date(mergedData.dob).getTime() : new Date("1/1/1970").getTime(),
5154
+ emailId: emailId || "",
5155
+ mobileNumber: phone
5156
+ },
5157
+ additionalDetails: {
5158
+ serviceType: isEkyc ? "ekyc" : mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$serviceTy2 = mergedData.serviceType) === null || _mergedData$serviceTy2 === void 0 ? void 0 : _mergedData$serviceTy2.code
5159
+ },
5160
+ vehicles: [],
5161
+ drivers: [],
5162
+ source: isEkyc ? "eKYC Portal" : "WhatsApp"
5163
+ };
5164
+ const _temp = function () {
5165
+ if (isEkyc) {
5166
+ return Promise.resolve(refetch()).then(function (_ref) {
5167
+ var _mergedData$zoneIds, _mergedData$clusterId;
5168
+ let data = _ref.data;
5169
+ if ((data === null || data === void 0 ? void 0 : data.totalCount) >= 3) {
5170
+ setShowToast({
5171
+ key: "error",
5172
+ message: t("EKYC_VENDOR_LIMIT"),
5173
+ duration: 5000
5174
+ });
5175
+ _exit = true;
5176
+ return;
5177
+ }
5178
+ vendorData = _extends({}, vendorData, {
5179
+ zoneIds: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$zoneIds = mergedData.zoneIds) === null || _mergedData$zoneIds === void 0 ? void 0 : _mergedData$zoneIds.map(z => z === null || z === void 0 ? void 0 : z.code)) || [],
5180
+ clusterIds: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$clusterId = mergedData.clusterIds) === null || _mergedData$clusterId === void 0 ? void 0 : _mergedData$clusterId.map(c => {
5181
+ var _c$;
5182
+ return c === null || c === void 0 ? void 0 : (_c$ = c[1]) === null || _c$ === void 0 ? void 0 : _c$.code;
5183
+ })) || [],
5184
+ contractStartDate: mergedData.contractStartDate ? new Date(mergedData.contractStartDate).getTime() : null,
5185
+ contractEndDate: mergedData.contractEndDate ? new Date(mergedData.contractEndDate).getTime() : null
5186
+ });
5187
+ });
5188
+ }
5189
+ }();
5190
+ return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
5191
+ } catch (e) {
5192
+ return Promise.reject(e);
5193
+ }
5042
5194
  };
5043
5195
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(VerticalTimeline, {
5044
5196
  config: [{
@@ -5072,8 +5224,9 @@ const AddVendor = () => {
5072
5224
  noBreakLine: true
5073
5225
  }), showToast && /*#__PURE__*/React.createElement(Toast, {
5074
5226
  error: showToast.key === "error",
5075
- label: showToast.action === "INVALID_CONTRACT_DATE" ? t("ES_VENDOR_CONTRACT_END_DATE") + " cannot be earlier than " + t("ES_VENDOR_CONTRACT_START_DATE") : t(showToast.key === "success" ? "ES_FSM_REGISTRY_" + showToast.action + "_SUCCESS" : showToast.action),
5076
- onClose: closeToast
5227
+ label: showToast.message,
5228
+ onClose: closeToast,
5229
+ duration: showToast.duration || 5000
5077
5230
  })));
5078
5231
  };
5079
5232