@djb25/digit-ui-module-vendor 1.0.86 → 1.0.88

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
@@ -18,18 +18,23 @@ function _extends() {
18
18
  }, _extends.apply(null, arguments);
19
19
  }
20
20
 
21
- const _iteratorSymbol = /*#__PURE__*/typeof Symbol !== "undefined" ? Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator")) : "@@iterator";
22
- const _asyncIteratorSymbol = /*#__PURE__*/typeof Symbol !== "undefined" ? Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator")) : "@@asyncIterator";
21
+ // A type of promise-like that resolves synchronously and supports only one observer
22
+
23
+ const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
24
+
25
+ const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
26
+
27
+ // Asynchronously call a function and send errors to recovery continuation
23
28
  function _catch(body, recover) {
24
- try {
25
- var result = body();
26
- } catch (e) {
27
- return recover(e);
28
- }
29
- if (result && result.then) {
30
- return result.then(void 0, recover);
31
- }
32
- return result;
29
+ try {
30
+ var result = body();
31
+ } catch(e) {
32
+ return recover(e);
33
+ }
34
+ if (result && result.then) {
35
+ return result.then(void 0, recover);
36
+ }
37
+ return result;
33
38
  }
34
39
 
35
40
  const {
@@ -3306,7 +3311,7 @@ const Heading = props => {
3306
3311
  }, props.label);
3307
3312
  };
3308
3313
  const SupervisorDetails = props => {
3309
- var _Digit$SessionStorage, _userInfo$type, _formState$tableForm, _formState$tableForm2, _formState$tableForm3, _formState$tableForm4, _dashboardData$dashbo, _supervisorData$2, _supervisorData$2$emp, _formState$tableForm10, _formState$tableForm11;
3314
+ var _Digit$SessionStorage, _userInfo$type, _supervisorData$, _supervisorData$$supe, _formState$tableForm, _formState$tableForm2, _formState$tableForm3, _formState$tableForm4, _dashboardData$dashbo, _supervisorData$3, _supervisorData$3$emp, _formState$tableForm10, _formState$tableForm11;
3310
3315
  const tenantId = Digit.ULBService.getCurrentTenantId();
3311
3316
  const {
3312
3317
  t
@@ -3380,18 +3385,28 @@ const SupervisorDetails = props => {
3380
3385
  };
3381
3386
  });
3382
3387
  }, [supervisorSearchResponse, vendorData]);
3388
+ const nextStatus = (supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$ = supervisorData[0]) === null || _supervisorData$ === void 0 ? void 0 : (_supervisorData$$supe = _supervisorData$.supervisorData) === null || _supervisorData$$supe === void 0 ? void 0 : _supervisorData$$supe.status) === "DISABLED" ? {
3389
+ status: "ES_VENDOR_ACTION_ENABLE",
3390
+ action: "ACTIVE",
3391
+ toastMessage: "ES_FSM_REGISTRY_SUPERVISOR_ENABLE_SUCCESS",
3392
+ popupButton: "ENABLE",
3393
+ popupHeader: "ES_VENDOR_SUPERVISOR_ENABLE_POPUP_HEADER",
3394
+ popupMessage: "ES_VENDOR_SUPERVISOR_ENABLE_POPUP_MESSAGE"
3395
+ } : {
3396
+ status: "ES_VENDOR_ACTION_DISABLE",
3397
+ action: "DISABLED",
3398
+ toastMessage: "ES_FSM_REGISTRY_SUPERVISOR_DISABLE_SUCCESS",
3399
+ popupButton: "DISABLE",
3400
+ popupHeader: "ES_VENDOR_SUPERVISOR_DISABLE_POPUP_HEADER",
3401
+ popupMessage: "ES_VENDOR_SUPERVISOR_DISABLE_POPUP_MESSAGE"
3402
+ };
3383
3403
  const {
3384
3404
  mutate: mutateSupervisor
3385
3405
  } = Digit.Hooks.fsm.useSupervisorUpdate(tenantId);
3386
3406
  React.useEffect(() => {
3387
- var _location$state;
3407
+ var _location$state, _location$state2;
3388
3408
  refetch();
3389
- if ((_location$state = location.state) !== null && _location$state !== void 0 && _location$state.showSuccessToast) {
3390
- setShowToast({
3391
- key: "success",
3392
- action: "UPDATE_SUPERVISOR"
3393
- });
3394
- }
3409
+ if ((_location$state = location.state) !== null && _location$state !== void 0 && _location$state.showSuccessToast) setShowToast((_location$state2 = location.state) === null || _location$state2 === void 0 ? void 0 : _location$state2.message);
3395
3410
  }, []);
3396
3411
  React.useEffect(() => {
3397
3412
  switch (selectedAction) {
@@ -3399,7 +3414,7 @@ const SupervisorDetails = props => {
3399
3414
  return history.push(`/digit-ui/${userType}/vendor/registry/modify-supervisor/${supervisorId}`);
3400
3415
  case "HOME":
3401
3416
  return history.push(`/digit-ui/${userType}/vendor/search-vendor?selectedTabs=SUPERVISOR`);
3402
- case "DELETE":
3417
+ case nextStatus.status:
3403
3418
  return setShowModal(true);
3404
3419
  }
3405
3420
  }, [selectedAction]);
@@ -3422,12 +3437,12 @@ const SupervisorDetails = props => {
3422
3437
  keepPreviousData: true
3423
3438
  });
3424
3439
  const handleDeleteSupervisor = () => {
3425
- var _supervisorData$;
3426
- let details = supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$ = supervisorData[0]) === null || _supervisorData$ === void 0 ? void 0 : _supervisorData$.supervisorData;
3440
+ var _supervisorData$2;
3441
+ const details = supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$2 = supervisorData[0]) === null || _supervisorData$2 === void 0 ? void 0 : _supervisorData$2.supervisorData;
3427
3442
  const formData = {
3428
3443
  supervisor: {
3429
3444
  ...details,
3430
- status: "INACTIVE"
3445
+ status: nextStatus.action
3431
3446
  }
3432
3447
  };
3433
3448
  mutateSupervisor(formData, {
@@ -3445,7 +3460,7 @@ const SupervisorDetails = props => {
3445
3460
  showSuccessToast: true,
3446
3461
  message: {
3447
3462
  key: "success",
3448
- action: t("ES_VENDOR_DELETE_SUPERVISOR_SUCCESS")
3463
+ action: t(nextStatus.toastMessage)
3449
3464
  }
3450
3465
  }
3451
3466
  });
@@ -3562,7 +3577,7 @@ const SupervisorDetails = props => {
3562
3577
  className: "employee-form-content"
3563
3578
  }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.Card, {
3564
3579
  className: "flex-box flex-box-col flex-gap-5"
3565
- }, supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$2 = supervisorData[0]) === null || _supervisorData$2 === void 0 ? void 0 : (_supervisorData$2$emp = _supervisorData$2.employeeResponse) === null || _supervisorData$2$emp === void 0 ? void 0 : _supervisorData$2$emp.map((detail, index) => {
3580
+ }, supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$3 = supervisorData[0]) === null || _supervisorData$3 === void 0 ? void 0 : (_supervisorData$3$emp = _supervisorData$3.employeeResponse) === null || _supervisorData$3$emp === void 0 ? void 0 : _supervisorData$3$emp.map((detail, index) => {
3566
3581
  var _detail$values, _userInfo$roles, _userInfo$roles$map;
3567
3582
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
3568
3583
  key: index
@@ -3635,14 +3650,14 @@ const SupervisorDetails = props => {
3635
3650
  isLoading: isDashboradLoading
3636
3651
  }))), showModal && /*#__PURE__*/React__default.createElement(digitUiReactComponents.Modal, {
3637
3652
  headerBarMain: /*#__PURE__*/React__default.createElement(Heading, {
3638
- label: t("ES_VENDOR_SUPERVISOR_DELETE_POPUP_HEADER")
3653
+ label: t(nextStatus.popupHeader)
3639
3654
  }),
3640
3655
  headerBarEnd: /*#__PURE__*/React__default.createElement(digitUiReactComponents.CloseSvg, {
3641
3656
  onClick: closeModal
3642
3657
  }),
3643
3658
  actionCancelLabel: t("CS_COMMON_CANCEL"),
3644
3659
  actionCancelOnSubmit: closeModal,
3645
- actionSaveLabel: t("ES_EVENT_DELETE"),
3660
+ actionSaveLabel: t(nextStatus.status),
3646
3661
  actionSaveOnSubmit: handleDeleteSupervisor
3647
3662
  }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.Card, {
3648
3663
  style: {
@@ -3650,23 +3665,24 @@ const SupervisorDetails = props => {
3650
3665
  }
3651
3666
  }, /*#__PURE__*/React__default.createElement(ConfirmationBox, {
3652
3667
  t: t,
3653
- title: "ES_VENDOR_SUPERVISOR_DELETE_TEXT"
3668
+ title: nextStatus.popupMessage
3654
3669
  }))), showToast && /*#__PURE__*/React__default.createElement(digitUiReactComponents.Toast, {
3655
3670
  error: showToast.key === "error",
3656
3671
  label: showToast.key === "success" ? t(`ES_VENDOR_${showToast.action}_SUCCESS`, showToast.action === "UPDATE_SUPERVISOR" ? "Supervisor updated successfully" : undefined) : t(showToast.action),
3657
3672
  onClose: () => setShowToast(null),
3658
- duration: 5000
3673
+ duration: 15000
3659
3674
  }), /*#__PURE__*/React__default.createElement(digitUiReactComponents.ActionBar, {
3660
3675
  style: {
3661
3676
  zIndex: "19"
3662
3677
  }
3663
3678
  }, displayMenu ? /*#__PURE__*/React__default.createElement(digitUiReactComponents.Menu, {
3664
- localeKeyPrefix: "ES_VENDOR_SUPERVISOR_ACTION",
3665
- options: ["EDIT", "DELETE"],
3679
+ localeKeyPrefix: "ES_VENDOR_ACTION",
3680
+ options: ["EDIT", nextStatus.popupButton],
3666
3681
  t: t,
3667
3682
  onSelect: a => {
3668
3683
  setDisplayMenu(false);
3669
3684
  setSelectedAction(a);
3685
+ setShowModal(true);
3670
3686
  }
3671
3687
  }) : null, /*#__PURE__*/React__default.createElement(digitUiReactComponents.SubmitBar, {
3672
3688
  label: t("ES_COMMON_TAKE_ACTION"),
@@ -3989,7 +4005,7 @@ const CloseBtn = props => {
3989
4005
  }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.CloseSvg, null));
3990
4006
  };
3991
4007
  const SurveyorDetails = props => {
3992
- var _Digit$UserService$ge, _surveyorData$2, _surveyorData$2$emplo;
4008
+ var _Digit$UserService$ge, _surveyorData$, _surveyorData$$survey, _surveyorData$3, _surveyorData$3$emplo;
3993
4009
  const tenantId = Digit.ULBService.getCurrentTenantId();
3994
4010
  const {
3995
4011
  t
@@ -4006,8 +4022,6 @@ const SurveyorDetails = props => {
4006
4022
  const [selectedAction, setSelectedAction] = React.useState(null);
4007
4023
  const [showModal, setShowModal] = React.useState(false);
4008
4024
  const [showToast, setShowToast] = React.useState(null);
4009
- const [vendors, setVendors] = React.useState([]);
4010
- const [selectedOption, setSelectedOption] = React.useState({});
4011
4025
  const {
4012
4026
  data: vendorData
4013
4027
  } = Digit.Hooks.fsm.useDsoSearch(tenantId, {
@@ -4066,52 +4080,47 @@ const SurveyorDetails = props => {
4066
4080
  };
4067
4081
  });
4068
4082
  }, [surveyorSearchResponse, vendorData]);
4083
+ const nextStatus = (surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$ = surveyorData[0]) === null || _surveyorData$ === void 0 ? void 0 : (_surveyorData$$survey = _surveyorData$.surveyorData) === null || _surveyorData$$survey === void 0 ? void 0 : _surveyorData$$survey.status) === "DISABLED" ? {
4084
+ status: "ES_VENDOR_ACTION_ENABLE",
4085
+ action: "ACTIVE",
4086
+ toastMessage: "ES_FSM_REGISTRY_SUPERVISOR_ENABLE_SUCCESS",
4087
+ popupButton: "ENABLE",
4088
+ popupHeader: "ES_VENDOR_SURVEYOR_ENABLE_POPUP_HEADER",
4089
+ popupMessage: "ES_VENDOR_SURVEYOR_ENABLE_POPUP_MESSAGE"
4090
+ } : {
4091
+ status: "ES_VENDOR_ACTION_DISABLE",
4092
+ action: "DISABLED",
4093
+ toastMessage: "ES_FSM_REGISTRY_SUPERVISOR_DISABLE_SUCCESS",
4094
+ popupButton: "DISABLE",
4095
+ popupHeader: "ES_VENDOR_SURVEYOR_DISABLE_POPUP_HEADER",
4096
+ popupMessage: "ES_VENDOR_SURVEYOR_DISABLE_POPUP_MESSAGE"
4097
+ };
4069
4098
  const {
4070
4099
  mutate: mutateSurveyor
4071
4100
  } = Digit.Hooks.fsm.useSurveyorUpdate(tenantId);
4072
4101
  React.useEffect(() => {
4073
- if (vendorData) {
4074
- let vendors = vendorData.map(data => data.dsoDetails);
4075
- setVendors(vendors);
4076
- }
4077
- }, [vendorData]);
4078
- React.useEffect(() => {
4079
- var _location$state;
4102
+ var _location$state, _location$state2;
4080
4103
  refetch();
4081
- if ((_location$state = location.state) !== null && _location$state !== void 0 && _location$state.showSuccessToast) {
4082
- var _location$state2;
4083
- setShowToast((_location$state2 = location.state) === null || _location$state2 === void 0 ? void 0 : _location$state2.message);
4084
- }
4104
+ if ((_location$state = location.state) !== null && _location$state !== void 0 && _location$state.showSuccessToast) setShowToast((_location$state2 = location.state) === null || _location$state2 === void 0 ? void 0 : _location$state2.message);
4085
4105
  }, []);
4086
4106
  React.useEffect(() => {
4087
4107
  switch (selectedAction) {
4088
- case "DELETE":
4089
- case "ADD_VENDOR":
4090
- case "EDIT_VENDOR":
4091
- case "DELETE_VENDOR":
4108
+ case nextStatus.status:
4092
4109
  return setShowModal(true);
4093
4110
  case "EDIT":
4094
4111
  return history.push(`/digit-ui/${userType}/vendor/registry/modify-surveyor/${surveyorId}`);
4095
- case "HOME":
4096
- return history.push(`/digit-ui/${userType}/vendor/search-vendor?selectedTabs=SURVEYOR`);
4097
4112
  }
4098
4113
  }, [selectedAction]);
4099
4114
  const closeToast = () => {
4100
4115
  setShowToast(null);
4101
4116
  };
4102
- const handleModalAction = () => {
4103
- switch (selectedAction) {
4104
- case "DELETE":
4105
- return handleDeleteSurveyor();
4106
- }
4107
- };
4108
4117
  const handleDeleteSurveyor = () => {
4109
- var _surveyorData$;
4110
- let details = surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$ = surveyorData[0]) === null || _surveyorData$ === void 0 ? void 0 : _surveyorData$.surveyorData;
4118
+ var _surveyorData$2;
4119
+ let details = surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$2 = surveyorData[0]) === null || _surveyorData$2 === void 0 ? void 0 : _surveyorData$2.surveyorData;
4111
4120
  const formData = {
4112
4121
  surveyor: {
4113
4122
  ...details,
4114
- status: "INACTIVE"
4123
+ status: "DISABLED"
4115
4124
  }
4116
4125
  };
4117
4126
  mutateSurveyor(formData, {
@@ -4139,43 +4148,14 @@ const SurveyorDetails = props => {
4139
4148
  };
4140
4149
  const closeModal = () => {
4141
4150
  setSelectedAction(null);
4142
- setSelectedOption({});
4143
4151
  setShowModal(false);
4144
4152
  };
4145
- const modalHeading = () => {
4146
- switch (selectedAction) {
4147
- case "DELETE":
4148
- case "DELETE_VENDOR":
4149
- return "ES_VENDOR_SURVEYOR_DELETE_POPUP_HEADER";
4150
- case "ADD_VENDOR":
4151
- case "EDIT_VENDOR":
4152
- return "ES_VENDOR_SURVEYOR_ADD_VENDOR_POPUP_HEADER";
4153
- }
4154
- };
4155
- const renderModalContent = () => {
4156
- if (selectedAction === "DELETE" || selectedAction === "DELETE_VENDOR") {
4157
- return /*#__PURE__*/React__default.createElement(ConfirmationBox, {
4158
- t: t,
4159
- title: "ES_VENDOR_SURVEYOR_DELETE_TEXT"
4160
- });
4161
- }
4162
- if (selectedAction === "ADD_VENDOR" || selectedAction === "EDIT_VENDOR") {
4163
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(digitUiReactComponents.CardText, null, t(`ES_FSM_REGISTRY_SELECT_VENODOR`)), /*#__PURE__*/React__default.createElement(digitUiReactComponents.Dropdown, {
4164
- t: t,
4165
- option: vendors,
4166
- value: selectedOption,
4167
- selected: selectedOption,
4168
- select: setSelectedOption,
4169
- optionKey: "name"
4170
- }));
4171
- }
4172
- };
4173
4153
  if (isLoading) {
4174
4154
  return /*#__PURE__*/React__default.createElement(digitUiReactComponents.Loader, null);
4175
4155
  }
4176
4156
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
4177
4157
  className: "employee-form-content"
4178
- }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.Card, null, surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$2 = surveyorData[0]) === null || _surveyorData$2 === void 0 ? void 0 : (_surveyorData$2$emplo = _surveyorData$2.employeeResponse) === null || _surveyorData$2$emplo === void 0 ? void 0 : _surveyorData$2$emplo.map((detail, index) => {
4158
+ }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.Card, null, surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$3 = surveyorData[0]) === null || _surveyorData$3 === void 0 ? void 0 : (_surveyorData$3$emplo = _surveyorData$3.employeeResponse) === null || _surveyorData$3$emplo === void 0 ? void 0 : _surveyorData$3$emplo.map((detail, index) => {
4179
4159
  var _detail$values;
4180
4160
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
4181
4161
  key: index
@@ -4219,20 +4199,19 @@ const SurveyorDetails = props => {
4219
4199
  }))));
4220
4200
  }))), showModal && /*#__PURE__*/React__default.createElement(digitUiReactComponents.Modal, {
4221
4201
  headerBarMain: /*#__PURE__*/React__default.createElement(Heading$1, {
4222
- label: t(modalHeading())
4202
+ label: t(nextStatus.popupHeader)
4223
4203
  }),
4224
4204
  headerBarEnd: /*#__PURE__*/React__default.createElement(CloseBtn, {
4225
4205
  onClick: closeModal
4226
4206
  }),
4227
4207
  actionCancelLabel: t("CS_COMMON_CANCEL"),
4228
4208
  actionCancelOnSubmit: closeModal,
4229
- actionSaveLabel: t(selectedAction === "DELETE" || selectedAction === "DELETE_VENDOR" ? "ES_EVENT_DELETE" : "CS_COMMON_SUBMIT"),
4230
- actionSaveOnSubmit: handleModalAction
4231
- }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.Card, {
4232
- style: {
4233
- boxShadow: "none"
4234
- }
4235
- }, renderModalContent())), showToast && /*#__PURE__*/React__default.createElement(digitUiReactComponents.Toast, {
4209
+ actionSaveLabel: t(nextStatus.status),
4210
+ actionSaveOnSubmit: handleDeleteSurveyor
4211
+ }, /*#__PURE__*/React__default.createElement(ConfirmationBox, {
4212
+ t: t,
4213
+ title: nextStatus.popupMessage
4214
+ })), showToast && /*#__PURE__*/React__default.createElement(digitUiReactComponents.Toast, {
4236
4215
  error: showToast.key === "error",
4237
4216
  label: showToast.key === "success" ? t(`ES_VENDOR_${showToast.action}_SUCCESS`, showToast.action === "UPDATE_SURVEYOR" ? "Surveyor updated successfully" : undefined) : t(showToast.action),
4238
4217
  onClose: closeToast
@@ -4241,12 +4220,13 @@ const SurveyorDetails = props => {
4241
4220
  zIndex: "19"
4242
4221
  }
4243
4222
  }, displayMenu ? /*#__PURE__*/React__default.createElement(digitUiReactComponents.Menu, {
4244
- localeKeyPrefix: "ES_VENDOR_SURVEYOR_ACTION",
4245
- options: ["EDIT", "DELETE"],
4223
+ localeKeyPrefix: "ES_VENDOR_ACTION",
4224
+ options: ["EDIT", nextStatus.popupButton],
4246
4225
  t: t,
4247
4226
  onSelect: a => {
4248
4227
  setDisplayMenu(false);
4249
4228
  setSelectedAction(a);
4229
+ setShowModal(true);
4250
4230
  }
4251
4231
  }) : null, /*#__PURE__*/React__default.createElement(digitUiReactComponents.SubmitBar, {
4252
4232
  label: t("ES_COMMON_TAKE_ACTION"),