@itilite/iui-user-management 1.5.14 → 1.5.15

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
@@ -423,6 +423,9 @@ var userAddEditUrl = {
423
423
  setDefaultCard: function setDefaultCard(pmId, vendorId) {
424
424
  return env.getPaymentUrl() + "/api/v1/card/default";
425
425
  },
426
+ personalCardEligibility: function personalCardEligibility() {
427
+ return env.getPaymentUrl() + "/api/v1/card/clients/" + IUILocalStorageService.getClientId() + "/personal/eligibility?app_type=1";
428
+ },
426
429
  disablePaymentCard: function disablePaymentCard() {
427
430
  return env.getPaymentUrl() + "/api/v1/card/status";
428
431
  },
@@ -2670,13 +2673,12 @@ var CARDS_DISABLED = {
2670
2673
  };
2671
2674
 
2672
2675
  var IUILocalStorageService$3 = utils.services.IUILocalStorageService;
2673
- var env$3 = utils.configs.env;
2676
+ var env$3 = utils.configs.env,
2677
+ paymentApi$1 = utils.configs.paymentApi;
2674
2678
  var CardsManagement = function CardsManagement(_ref) {
2675
- var _selectedCard$metadat, _pg$gateway;
2679
+ var _selectedCard$metadat;
2676
2680
  var _ref$paymentDetails = _ref.paymentDetails,
2677
2681
  paymentDetails = _ref$paymentDetails === void 0 ? {} : _ref$paymentDetails,
2678
- _ref$paymentMethod = _ref.paymentMethod,
2679
- paymentMethod = _ref$paymentMethod === void 0 ? null : _ref$paymentMethod,
2680
2682
  _ref$sendLog = _ref.sendLog,
2681
2683
  sendLog = _ref$sendLog === void 0 ? function () {} : _ref$sendLog;
2682
2684
  var dispatch = reactRedux.useDispatch();
@@ -2691,6 +2693,23 @@ var CardsManagement = function CardsManagement(_ref) {
2691
2693
  var _useState2 = React.useState(null),
2692
2694
  selectedCard = _useState2[0],
2693
2695
  setSelectedCard = _useState2[1];
2696
+ var _useState3 = React.useState(false),
2697
+ allowPersonalCardAdd = _useState3[0],
2698
+ setAllowPersonalCardAdd = _useState3[1];
2699
+ React.useEffect(function () {
2700
+ var isActive = true;
2701
+ paymentApi$1.get(userAddEditUrl.personalCardEligibility()).then(function (res) {
2702
+ if (isActive) {
2703
+ var _res$data, _res$data$data;
2704
+ setAllowPersonalCardAdd((res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : (_res$data$data = _res$data.data) === null || _res$data$data === void 0 ? void 0 : _res$data$data.allow_personal_card_add) === true);
2705
+ }
2706
+ })["catch"](function () {
2707
+ if (isActive) setAllowPersonalCardAdd(false);
2708
+ });
2709
+ return function () {
2710
+ isActive = false;
2711
+ };
2712
+ }, []);
2694
2713
  var handleMenuClick = function handleMenuClick(event, card) {
2695
2714
  setAnchorEl(event.currentTarget);
2696
2715
  setSelectedCard(card);
@@ -2908,7 +2927,7 @@ var CardsManagement = function CardsManagement(_ref) {
2908
2927
  }, /*#__PURE__*/React__default.createElement(iuistyles.IUIGrid, {
2909
2928
  container: true,
2910
2929
  className: styles$1.formFieldsWrapper
2911
- }, /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", null, paymentMethod === 2 && /*#__PURE__*/React__default.createElement("div", {
2930
+ }, /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", null, !allowPersonalCardAdd && /*#__PURE__*/React__default.createElement("div", {
2912
2931
  className: classes.disabledNotice
2913
2932
  }, "Company has disabled usage of your personal cards, please reach out to your admin"), /*#__PURE__*/React__default.createElement("div", {
2914
2933
  className: classes.cardsGrid
@@ -2916,7 +2935,7 @@ var CardsManagement = function CardsManagement(_ref) {
2916
2935
  return renderCard(card);
2917
2936
  }) : null, corporateCards.length !== 0 ? corporateCards === null || corporateCards === void 0 ? void 0 : corporateCards.map(function (card) {
2918
2937
  return renderCard(card);
2919
- }) : null), console.log('cards', cards, 'cardsCount', cardsCount, pg), (!cards || cardsCount < 10) && (pg === null || pg === void 0 ? void 0 : (_pg$gateway = pg.gateway) === null || _pg$gateway === void 0 ? void 0 : _pg$gateway.toLowerCase()) === 'stripe' && (pg === null || pg === void 0 ? void 0 : pg.save_card_enable) === 1 && paymentMethod === 1 && /*#__PURE__*/React__default.createElement("button", {
2938
+ }) : null), (!cards || cardsCount < 10) && allowPersonalCardAdd && /*#__PURE__*/React__default.createElement("button", {
2920
2939
  className: classes.addCardButton,
2921
2940
  onClick: function onClick() {
2922
2941
  sendLog({