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