@djb25/digit-ui-module-vendor 1.0.82 → 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.
@@ -748,8 +748,7 @@ const RegisteredVendorSearch = _ref => {
748
748
  searchParams = _ref.searchParams,
749
749
  isInboxPage = _ref.isInboxPage,
750
750
  selectedTab = _ref.selectedTab,
751
- matchedRoles = _ref.matchedRoles,
752
- ekycVendorCount = _ref.ekycVendorCount;
751
+ matchedRoles = _ref.matchedRoles;
753
752
  const storedSearchParams = isInboxPage ? Digit.SessionStorage.get("vendor/inbox/searchParams") : Digit.SessionStorage.get("vendor/search/searchParams");
754
753
  const _useTranslation = useTranslation(),
755
754
  t = _useTranslation.t;
@@ -811,13 +810,7 @@ const RegisteredVendorSearch = _ref => {
811
810
  const userPath = userType === null || userType === void 0 ? void 0 : userType.toLowerCase();
812
811
  switch (action) {
813
812
  case "VENDOR":
814
- if (ekycVendorCount >= 3) {
815
- setShowToast({
816
- key: "error",
817
- action: "You can't create more than 3 eKYC vendors. Please delete an existing vendor before creating a new one."
818
- });
819
- return;
820
- } else return history.push("/digit-ui/" + userPath + "/vendor/registry/new-vendor");
813
+ return history.push("/digit-ui/" + userPath + "/vendor/registry/new-vendor");
821
814
  case "VEHICLE":
822
815
  return history.push("/digit-ui/" + userPath + "/vendor/registry/new-vehicle");
823
816
  case "DRIVER":
@@ -5000,7 +4993,7 @@ const AddVendor = () => {
5000
4993
  key: "error",
5001
4994
  action: "INVALID_CONTRACT_DATE"
5002
4995
  });
5003
- } else if (!isInvalid && showToast) {
4996
+ } else if (!isInvalid && (showToast === null || showToast === void 0 ? void 0 : showToast.action) === "INVALID_CONTRACT_DATE") {
5004
4997
  setShowToast(null);
5005
4998
  }
5006
4999
  }
@@ -5038,132 +5031,166 @@ const AddVendor = () => {
5038
5031
  const closeToast = () => {
5039
5032
  setShowToast(null);
5040
5033
  };
5041
- const onSubmit = data => {
5042
- 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;
5043
- const mergedData = data;
5044
- const address = mergedData === null || mergedData === void 0 ? void 0 : mergedData.propertyAddress;
5045
- const pincode = address === null || address === void 0 ? void 0 : address.pincode;
5046
- const street = address === null || address === void 0 ? void 0 : address.streetName;
5047
- const doorNo = address === null || address === void 0 ? void 0 : address.houseNo;
5048
- const landmark = address === null || address === void 0 ? void 0 : address.landmark;
5049
- const city = address === null || address === void 0 ? void 0 : (_address$city = address.city) === null || _address$city === void 0 ? void 0 : _address$city.name;
5050
- const state = address === null || address === void 0 ? void 0 : (_address$city2 = address.city) === null || _address$city2 === void 0 ? void 0 : _address$city2.name;
5051
- const district = address === null || address === void 0 ? void 0 : (_address$city3 = address.city) === null || _address$city3 === void 0 ? void 0 : _address$city3.name;
5052
- const region = address === null || address === void 0 ? void 0 : (_address$city4 = address.city) === null || _address$city4 === void 0 ? void 0 : _address$city4.name;
5053
- const localityCode = address === null || address === void 0 ? void 0 : (_address$locality = address.locality) === null || _address$locality === void 0 ? void 0 : _address$locality.code;
5054
- const localityName = address === null || address === void 0 ? void 0 : (_address$locality2 = address.locality) === null || _address$locality2 === void 0 ? void 0 : _address$locality2.name;
5055
- const localityArea = address === null || address === void 0 ? void 0 : address.subLocality;
5056
- const wardCode = address === null || address === void 0 ? void 0 : (_address$ward = address.ward) === null || _address$ward === void 0 ? void 0 : _address$ward.code;
5057
- const wardName = address === null || address === void 0 ? void 0 : (_address$ward2 = address.ward) === null || _address$ward2 === void 0 ? void 0 : _address$ward2.name;
5058
- 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);
5059
- const addressLine1 = address === null || address === void 0 ? void 0 : address.addressLine1;
5060
- const addressLine2 = address === null || address === void 0 ? void 0 : address.addressLine2;
5061
- const actualAssembly = address === null || address === void 0 ? void 0 : address.actualAssembly;
5062
- const actualWard = address === null || address === void 0 ? void 0 : address.actualWard;
5063
- const actualZone = address === null || address === void 0 ? void 0 : address.actualZone;
5064
- const name = mergedData === null || mergedData === void 0 ? void 0 : mergedData.vendorName;
5065
- const plotNo = mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$plotNo = mergedData.plotNo) === null || _mergedData$plotNo === void 0 ? void 0 : _mergedData$plotNo.trim();
5066
- const buildingName = mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$buildingN = mergedData.buildingName) === null || _mergedData$buildingN === void 0 ? void 0 : _mergedData$buildingN.trim();
5067
- const emailId = mergedData === null || mergedData === void 0 ? void 0 : mergedData.emailId;
5068
- const phone = mergedData === null || mergedData === void 0 ? void 0 : mergedData.phone;
5069
- const isEkyc = (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$serviceTy = mergedData.serviceType) === null || _mergedData$serviceTy === void 0 ? void 0 : _mergedData$serviceTy.code) === "EKYC";
5070
- let vendorData = {
5071
- tenantId: tenantId,
5072
- name,
5073
- agencyType: "ULB",
5074
- paymentPreference: "post-service",
5075
- address: {
5076
- tenantId: tenantId,
5077
- landmark,
5078
- doorNo,
5079
- plotNo,
5080
- street,
5081
- city,
5082
- district,
5083
- region,
5084
- state,
5085
- country: "india",
5086
- pincode,
5087
- buildingName,
5088
- locality: {
5089
- code: localityCode || "",
5090
- name: localityName || "",
5091
- label: "Locality",
5092
- area: localityArea || ""
5093
- },
5094
- subLocality: subLocality,
5095
- addressLine1: addressLine1,
5096
- addressLine2: addressLine2,
5097
- actualAssembly,
5098
- actualWard,
5099
- actualZone,
5100
- ward: wardCode ? {
5101
- code: wardCode,
5102
- name: wardName
5103
- } : undefined,
5104
- geoLocation: {
5105
- latitude: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$address = mergedData.address) === null || _mergedData$address === void 0 ? void 0 : _mergedData$address.latitude) || 28.6139,
5106
- longitude: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$address2 = mergedData.address) === null || _mergedData$address2 === void 0 ? void 0 : _mergedData$address2.longitude) || 77.209
5107
- }
5108
- },
5109
- owner: {
5110
- tenantId: "dl",
5111
- name: (mergedData === null || mergedData === void 0 ? void 0 : mergedData.ownerName) || name,
5112
- fatherOrHusbandName: (mergedData === null || mergedData === void 0 ? void 0 : mergedData.fatherOrHusbandName) || name,
5113
- relationship: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$relations = mergedData.relationship) === null || _mergedData$relations === void 0 ? void 0 : _mergedData$relations.code) || "OTHER",
5114
- gender: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$gender = mergedData.gender) === null || _mergedData$gender === void 0 ? void 0 : _mergedData$gender.code) || "MALE",
5115
- dob: mergedData !== null && mergedData !== void 0 && mergedData.dob ? new Date(mergedData.dob).getTime() : new Date("1/1/1970").getTime(),
5116
- emailId: emailId || "",
5117
- mobileNumber: phone
5118
- },
5119
- additionalDetails: {
5120
- serviceType: isEkyc ? "ekyc" : mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$serviceTy2 = mergedData.serviceType) === null || _mergedData$serviceTy2 === void 0 ? void 0 : _mergedData$serviceTy2.code
5121
- },
5122
- vehicles: [],
5123
- drivers: [],
5124
- source: isEkyc ? "eKYC Portal" : "WhatsApp"
5125
- };
5126
- if (isEkyc) {
5127
- var _mergedData$zoneIds, _mergedData$clusterId;
5128
- vendorData = _extends({}, vendorData, {
5129
- 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)) || [],
5130
- clusterIds: (mergedData === null || mergedData === void 0 ? void 0 : (_mergedData$clusterId = mergedData.clusterIds) === null || _mergedData$clusterId === void 0 ? void 0 : _mergedData$clusterId.map(c => {
5131
- var _c$;
5132
- return c === null || c === void 0 ? void 0 : (_c$ = c[1]) === null || _c$ === void 0 ? void 0 : _c$.code;
5133
- })) || [],
5134
- contractStartDate: mergedData.contractStartDate ? new Date(mergedData.contractStartDate).getTime() : null,
5135
- contractEndDate: mergedData.contractEndDate ? new Date(mergedData.contractEndDate).getTime() : null
5136
- });
5137
- }
5138
- const payload = {
5139
- vendor: vendorData
5140
- };
5141
- if (isEkyc) {
5142
- payload.RequestInfo = {
5143
- apiId: "Rainmaker",
5144
- msgId: "ekyc-vendor-create"
5145
- };
5146
- }
5147
- mutate(payload, {
5148
- onError: error => {
5149
- setShowToast({
5150
- key: "error",
5151
- action: (error === null || error === void 0 ? void 0 : error.message) || error
5152
- });
5034
+ const _Digit$Hooks$fsm$useV2 = Digit.Hooks.fsm.useVendorSearch({
5035
+ tenantId,
5036
+ filters: {
5037
+ status: "ACTIVE,DISABLED",
5038
+ serviceType: "ekyc"
5153
5039
  },
5154
- onSuccess: () => {
5155
- history.push({
5156
- pathname: "/digit-ui/" + userType + "/vendor/search-vendor",
5157
- state: {
5158
- showSuccessToast: true,
5159
- message: {
5160
- key: "success",
5161
- action: "ES_VENDOR_ADD_VENDOR"
5162
- }
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
+ });
5163
5078
  }
5164
5079
  });
5165
5080
  }
5166
- });
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
+ }
5167
5194
  };
5168
5195
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(VerticalTimeline, {
5169
5196
  config: [{
@@ -5197,8 +5224,9 @@ const AddVendor = () => {
5197
5224
  noBreakLine: true
5198
5225
  }), showToast && /*#__PURE__*/React.createElement(Toast, {
5199
5226
  error: showToast.key === "error",
5200
- 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),
5201
- onClose: closeToast
5227
+ label: showToast.message,
5228
+ onClose: closeToast,
5229
+ duration: showToast.duration || 5000
5202
5230
  })));
5203
5231
  };
5204
5232