@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.
@@ -1,5 +1,5 @@
1
1
  import { IUIAsyncSelect, IUIBox, IUILabel, IUIFileUpload, IUICheckboxButton, IUIPhone, IUISelect, IUIDatePicker, IUIInput, IUIGrid, IUIDivider, IUITypography, IUITooltip, IUIRadio, IUIButton, IUIModal, IUISearch, IUICircularProgress, IUIAccordion, IUIAccordionSummary, IUIAccordionDetails, IUICard, IUIBackdrop, IUIBreadCrumb, IUIDropdownButton, IUIDropzone, IUIStepper, IUIIconButton, IUIFormControlLabel, IUICheckBox, IUIPrimaryRadio, IUITable, IUISkeleton, IUIProfileBox, IUIFormGroup, IUITabs } from '@itilite/iuistyles';
2
- import React, { useState, Fragment as Fragment$1, useEffect, memo, useRef } from 'react';
2
+ import React, { useState, useEffect, Fragment as Fragment$1, memo, useRef } from 'react';
3
3
  import { configs, services, utilUrls } from '@itilite/utils';
4
4
  import axios from 'axios';
5
5
  import { Tooltip, IconButton, Menu, MenuItem, Popper, Grow, Paper, ClickAwayListener, MenuList, Typography, Box } from '@material-ui/core';
@@ -420,6 +420,9 @@ var userAddEditUrl = {
420
420
  setDefaultCard: function setDefaultCard(pmId, vendorId) {
421
421
  return env.getPaymentUrl() + "/api/v1/card/default";
422
422
  },
423
+ personalCardEligibility: function personalCardEligibility() {
424
+ return env.getPaymentUrl() + "/api/v1/card/clients/" + IUILocalStorageService.getClientId() + "/personal/eligibility?app_type=1";
425
+ },
423
426
  disablePaymentCard: function disablePaymentCard() {
424
427
  return env.getPaymentUrl() + "/api/v1/card/status";
425
428
  },
@@ -2667,13 +2670,12 @@ var CARDS_DISABLED = {
2667
2670
  };
2668
2671
 
2669
2672
  var IUILocalStorageService$3 = services.IUILocalStorageService;
2670
- var env$3 = configs.env;
2673
+ var env$3 = configs.env,
2674
+ paymentApi$1 = configs.paymentApi;
2671
2675
  var CardsManagement = function CardsManagement(_ref) {
2672
- var _selectedCard$metadat, _pg$gateway;
2676
+ var _selectedCard$metadat;
2673
2677
  var _ref$paymentDetails = _ref.paymentDetails,
2674
2678
  paymentDetails = _ref$paymentDetails === void 0 ? {} : _ref$paymentDetails,
2675
- _ref$paymentMethod = _ref.paymentMethod,
2676
- paymentMethod = _ref$paymentMethod === void 0 ? null : _ref$paymentMethod,
2677
2679
  _ref$sendLog = _ref.sendLog,
2678
2680
  sendLog = _ref$sendLog === void 0 ? function () {} : _ref$sendLog;
2679
2681
  var dispatch = useDispatch();
@@ -2688,6 +2690,23 @@ var CardsManagement = function CardsManagement(_ref) {
2688
2690
  var _useState2 = useState(null),
2689
2691
  selectedCard = _useState2[0],
2690
2692
  setSelectedCard = _useState2[1];
2693
+ var _useState3 = useState(false),
2694
+ allowPersonalCardAdd = _useState3[0],
2695
+ setAllowPersonalCardAdd = _useState3[1];
2696
+ useEffect(function () {
2697
+ var isActive = true;
2698
+ paymentApi$1.get(userAddEditUrl.personalCardEligibility()).then(function (res) {
2699
+ if (isActive) {
2700
+ var _res$data, _res$data$data;
2701
+ 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);
2702
+ }
2703
+ })["catch"](function () {
2704
+ if (isActive) setAllowPersonalCardAdd(false);
2705
+ });
2706
+ return function () {
2707
+ isActive = false;
2708
+ };
2709
+ }, []);
2691
2710
  var handleMenuClick = function handleMenuClick(event, card) {
2692
2711
  setAnchorEl(event.currentTarget);
2693
2712
  setSelectedCard(card);
@@ -2905,7 +2924,7 @@ var CardsManagement = function CardsManagement(_ref) {
2905
2924
  }, /*#__PURE__*/React.createElement(IUIGrid, {
2906
2925
  container: true,
2907
2926
  className: styles$1.formFieldsWrapper
2908
- }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, paymentMethod === 2 && /*#__PURE__*/React.createElement("div", {
2927
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, !allowPersonalCardAdd && /*#__PURE__*/React.createElement("div", {
2909
2928
  className: classes.disabledNotice
2910
2929
  }, "Company has disabled usage of your personal cards, please reach out to your admin"), /*#__PURE__*/React.createElement("div", {
2911
2930
  className: classes.cardsGrid
@@ -2913,7 +2932,7 @@ var CardsManagement = function CardsManagement(_ref) {
2913
2932
  return renderCard(card);
2914
2933
  }) : null, corporateCards.length !== 0 ? corporateCards === null || corporateCards === void 0 ? void 0 : corporateCards.map(function (card) {
2915
2934
  return renderCard(card);
2916
- }) : 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.createElement("button", {
2935
+ }) : null), (!cards || cardsCount < 10) && allowPersonalCardAdd && /*#__PURE__*/React.createElement("button", {
2917
2936
  className: classes.addCardButton,
2918
2937
  onClick: function onClick() {
2919
2938
  sendLog({