@itilite/iui-user-management 1.5.0-beta-3 → 1.5.0-beta-5

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,8 +1,8 @@
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
- import { IconButton, Menu, MenuItem, Popper, Grow, Paper, ClickAwayListener, MenuList, Typography, Box } from '@material-ui/core';
5
+ import { Tooltip, IconButton, Menu, MenuItem, Popper, Grow, Paper, ClickAwayListener, MenuList, Typography, Box } from '@material-ui/core';
6
6
  import { useDispatch, useSelector, Provider } from 'react-redux';
7
7
  import { combineReducers, createStore, applyMiddleware } from 'redux';
8
8
  import thunk from 'redux-thunk';
@@ -10,7 +10,7 @@ import moment from 'moment';
10
10
  import { composeWithDevTools } from 'redux-devtools-extension';
11
11
  import { useParams, useHistory, useLocation } from 'react-router-dom';
12
12
  import { withStyles, makeStyles } from '@material-ui/core/styles';
13
- import Tooltip from '@material-ui/core/Tooltip';
13
+ import Tooltip$1 from '@material-ui/core/Tooltip';
14
14
  import Switch from '@material-ui/core/Switch';
15
15
  import MoreHorizIcon from '@material-ui/icons/MoreHoriz';
16
16
  import Button from '@material-ui/core/Button';
@@ -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
  },
@@ -839,7 +842,7 @@ var UserRole = function UserRole(_ref) {
839
842
 
840
843
  var styles$1 = {"defaultLabel":"_smjc4","card":"_3_S9J","cardNumber":"_36E9M","cardDigit":"_2pm-T","expiryDate":"_2tBnF","cardImage":"_3QvZh","visa":"_1IpBm","mastercard":"_2x6IX","amex":"_2a38S","discover":"_2vksl","diners":"_2kQRs","jcb":"_2bO1f","unionpay":"_2_jfu","is_nothing":"_1Lrzs","addCard":"_3711U","cardDeleteBtn":"_7Da2t","cardLabel":"_PQTex","defaultBtn":"_1_ArA","cursonPointer":"_1L115","sectionWrapper":"_VpUCK","margin":"_1Fs_D","minGridWidth":"_1hl-Z","firstRowMargin":"_1WZZj","firstChildMargin":"_IT_O_","paddingTop":"_Mhnl7","dividerColor":"_3ltFd"};
841
844
 
842
- var classes = {"disabledCard":"_3MVKj","expiredLabel":"_2_sgJ","expiresoonLabel":"_3G7La","sectionHeader":"_2d_OH","myCardsSection":"_3MNHj","companyCardsSection":"_34lN6","disabledNotice":"_1yV0j","cardsGrid":"_1oHGu","card":"_3ZTQc","moreIcon":"_3utA0","personal":"_duePd","corporate":"_3O33a","company":"_180_L","cardHeader":"_1eF61","cardTitleSection":"_2c40W","cardMaskedNumber":"_2Vlhq","cardName":"_bp-Mt","cardAlias":"_19m4v","cardType":"_3l4HZ","menuButton":"_3TTEn","lockIcon":"_1S27X","cardDetails":"_IP2rg","cardNumber":"_7FOPe","cardExpiry":"_CI_p2","cardCvv":"_3Gzqu","cardUnhide":"_ivgBf","cardFooter":"_1WgPL","brandLogo":"_EV0l8","addCardButton":"_1oaCc","plusIcon":"_w9L5L"};
845
+ var classes = {"disabledCard":"_3MVKj","expiredLabel":"_2_sgJ","invalidLabel":"_1Oqzs","expiresoonLabel":"_3G7La","sectionHeader":"_2d_OH","myCardsSection":"_3MNHj","companyCardsSection":"_34lN6","disabledNotice":"_1yV0j","cardsGrid":"_1oHGu","card":"_3ZTQc","moreIcon":"_3utA0","personal":"_duePd","corporate":"_3O33a","company":"_180_L","cardHeader":"_1eF61","cardTitleSection":"_2c40W","cardMaskedNumber":"_2Vlhq","cardName":"_bp-Mt","cardAlias":"_19m4v","cardType":"_3l4HZ","menuButton":"_3TTEn","lockIcon":"_1S27X","cardDetails":"_IP2rg","cardNumber":"_7FOPe","cardExpiry":"_CI_p2","cardCvv":"_3Gzqu","cardUnhide":"_ivgBf","cardFooter":"_1WgPL","brandLogo":"_EV0l8","addCardButton":"_1oaCc","plusIcon":"_w9L5L"};
843
846
 
844
847
  var SHOW_LOADER = 'SHOW_LOADER';
845
848
  var STOP_LOADER = 'STOP_LOADER';
@@ -2660,8 +2663,15 @@ var Visa = function Visa(props) {
2660
2663
  }))));
2661
2664
  };
2662
2665
 
2666
+ var CARDS_DISABLED = {
2667
+ DISABLED: '0',
2668
+ EXPIRED: '2',
2669
+ INVALID: '3'
2670
+ };
2671
+
2663
2672
  var IUILocalStorageService$3 = services.IUILocalStorageService;
2664
- var env$3 = configs.env;
2673
+ var env$3 = configs.env,
2674
+ paymentApi$1 = configs.paymentApi;
2665
2675
  var CardsManagement = function CardsManagement(_ref) {
2666
2676
  var _selectedCard$metadat, _pg$gateway;
2667
2677
  var _ref$paymentDetails = _ref.paymentDetails,
@@ -2682,6 +2692,23 @@ var CardsManagement = function CardsManagement(_ref) {
2682
2692
  var _useState2 = useState(null),
2683
2693
  selectedCard = _useState2[0],
2684
2694
  setSelectedCard = _useState2[1];
2695
+ var _useState3 = useState(false),
2696
+ allowPersonalCardAdd = _useState3[0],
2697
+ setAllowPersonalCardAdd = _useState3[1];
2698
+ useEffect(function () {
2699
+ var isActive = true;
2700
+ paymentApi$1.get(userAddEditUrl.personalCardEligibility()).then(function (res) {
2701
+ if (isActive) {
2702
+ var _res$data, _res$data$data;
2703
+ 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);
2704
+ }
2705
+ })["catch"](function () {
2706
+ if (isActive) setAllowPersonalCardAdd(false);
2707
+ });
2708
+ return function () {
2709
+ isActive = false;
2710
+ };
2711
+ }, []);
2685
2712
  var handleMenuClick = function handleMenuClick(event, card) {
2686
2713
  setAnchorEl(event.currentTarget);
2687
2714
  setSelectedCard(card);
@@ -2816,14 +2843,20 @@ var CardsManagement = function CardsManagement(_ref) {
2816
2843
  var isCompanyCard = (card === null || card === void 0 ? void 0 : card.category) === 'Company';
2817
2844
  var cardClass = getCardTypeClass(card === null || card === void 0 ? void 0 : card.category);
2818
2845
  var isDefaultCard = !!+(card === null || card === void 0 ? void 0 : (_card$metadata = card.metadata) === null || _card$metadata === void 0 ? void 0 : _card$metadata.default_card);
2819
- var isExpired = card.metadata.is_enabled === '2';
2820
- var isDisabled = card.metadata.is_enabled === '0' || isExpired;
2846
+ var isExpired = card.metadata.is_enabled === CARDS_DISABLED.EXPIRED;
2847
+ var isInvalid = card.metadata.is_enabled === CARDS_DISABLED.INVALID;
2848
+ var isDisabled = card.metadata.is_enabled === CARDS_DISABLED.DISABLED || isExpired || isInvalid;
2821
2849
  var currentDate = new Date();
2822
2850
  var cardExpDate = new Date(parseInt(card.card.exp_year, 10), parseInt(card.card.exp_month, 10) - 1);
2823
2851
  var timeDiff = cardExpDate.getTime() - currentDate.getTime();
2824
2852
  var daysToExpire = Math.ceil(timeDiff / (1000 * 3600 * 24));
2825
2853
  var expiresSoon = daysToExpire <= 30 && !isExpired;
2826
- return /*#__PURE__*/React.createElement("div", {
2854
+ return /*#__PURE__*/React.createElement(Tooltip, {
2855
+ title: isInvalid ? 'This card is invalid, because you have been issued a new card.' : null,
2856
+ disableHoverListener: !isInvalid,
2857
+ placement: "top",
2858
+ arrow: true
2859
+ }, /*#__PURE__*/React.createElement("div", {
2827
2860
  key: card.id,
2828
2861
  className: clsx(classes.card, classes[cardClass], (_clsx = {}, _clsx[classes.disabledCard] = isDisabled, _clsx))
2829
2862
  }, /*#__PURE__*/React.createElement("div", {
@@ -2836,7 +2869,9 @@ var CardsManagement = function CardsManagement(_ref) {
2836
2869
  className: classes.cardAlias
2837
2870
  }, card === null || card === void 0 ? void 0 : card.alias), isExpired && /*#__PURE__*/React.createElement("span", {
2838
2871
  className: classes.expiredLabel
2839
- }, "Expired"), expiresSoon && /*#__PURE__*/React.createElement("span", {
2872
+ }, "Expired"), isInvalid && /*#__PURE__*/React.createElement("span", {
2873
+ className: classes.invalidLabel
2874
+ }, "Invalid"), expiresSoon && !isInvalid && /*#__PURE__*/React.createElement("span", {
2840
2875
  className: clsx(classes.expiresoonLabel, classes.expiredLabel)
2841
2876
  }, "Expires Soon")), /*#__PURE__*/React.createElement("span", {
2842
2877
  className: classes.cardType
@@ -2863,7 +2898,7 @@ var CardsManagement = function CardsManagement(_ref) {
2863
2898
  className: classes.cardCvv
2864
2899
  }, "CVV \u2022\u2022\u2022")), /*#__PURE__*/React.createElement("div", {
2865
2900
  className: classes.cardFooter
2866
- }, /*#__PURE__*/React.createElement("div", null), getBrandLogo(card === null || card === void 0 ? void 0 : (_card$card4 = card.card) === null || _card$card4 === void 0 ? void 0 : _card$card4.brand)));
2901
+ }, /*#__PURE__*/React.createElement("div", null), getBrandLogo(card === null || card === void 0 ? void 0 : (_card$card4 = card.card) === null || _card$card4 === void 0 ? void 0 : _card$card4.brand))));
2867
2902
  };
2868
2903
  var _url = env$3.getPaymentUrl() + ("/api/v1/auth/" + IUILocalStorageService$3.getAccessToken() + "/1/" + pg.entity_id + "/0/" + pg.vendor_id + "/1");
2869
2904
  var showMenuButton = cardsCount === 1 || cardsCount > 1 && !+(selectedCard === null || selectedCard === void 0 ? void 0 : (_selectedCard$metadat = selectedCard.metadata) === null || _selectedCard$metadat === void 0 ? void 0 : _selectedCard$metadat.default_card);
@@ -2899,7 +2934,7 @@ var CardsManagement = function CardsManagement(_ref) {
2899
2934
  return renderCard(card);
2900
2935
  }) : null, corporateCards.length !== 0 ? corporateCards === null || corporateCards === void 0 ? void 0 : corporateCards.map(function (card) {
2901
2936
  return renderCard(card);
2902
- }) : 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", {
2937
+ }) : null), (!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 && allowPersonalCardAdd && /*#__PURE__*/React.createElement("button", {
2903
2938
  className: classes.addCardButton,
2904
2939
  onClick: function onClick() {
2905
2940
  sendLog({
@@ -2948,7 +2983,7 @@ var CardsManagement = function CardsManagement(_ref) {
2948
2983
  vertical: 'top',
2949
2984
  horizontal: 'right'
2950
2985
  }
2951
- }, selectedCard && selectedCard.metadata.is_enabled !== '2' && !+selectedCard.metadata.default_card && /*#__PURE__*/React.createElement(MenuItem, {
2986
+ }, selectedCard && selectedCard.metadata.is_enabled !== CARDS_DISABLED.DISABLED && selectedCard.metadata.is_enabled !== CARDS_DISABLED.EXPIRED && selectedCard.metadata.is_enabled !== CARDS_DISABLED.INVALID && !+selectedCard.metadata.default_card && /*#__PURE__*/React.createElement(MenuItem, {
2952
2987
  onClick: handleMarkAsDefault
2953
2988
  }, "Mark as default"), showMenuButton && /*#__PURE__*/React.createElement(MenuItem, {
2954
2989
  onClick: handleDeleteCard,
@@ -3604,7 +3639,7 @@ var personalInfo = [{
3604
3639
  readOnly: false,
3605
3640
  placeholder: 'Enter first and middle name',
3606
3641
  validation: {
3607
- regexOnChange: null,
3642
+ regexOnChange: /^(?!.* {2}).*$/,
3608
3643
  regexOnBlur: [{
3609
3644
  regex: /^[a-zA-Z ]*$/,
3610
3645
  message: 'Only alphabets are allowed.'
@@ -3626,7 +3661,7 @@ var personalInfo = [{
3626
3661
  readOnly: false,
3627
3662
  placeholder: 'Enter last name',
3628
3663
  validation: {
3629
- regexOnChange: null,
3664
+ regexOnChange: /^(?!.* {2}).*$/,
3630
3665
  regexOnBlur: [{
3631
3666
  regex: /^[a-zA-Z ]*$/,
3632
3667
  message: 'Only alphabets are allowed.'
@@ -3669,7 +3704,7 @@ var personalInfo = [{
3669
3704
  visibility: true,
3670
3705
  readOnly: false,
3671
3706
  validation: {
3672
- regexOnChange: /^[\d]/,
3707
+ regexOnChange: /^\d*$/,
3673
3708
  regexOnBlur: null,
3674
3709
  maxLimit: '',
3675
3710
  minLimit: '',
@@ -10319,7 +10354,7 @@ var StickyHeadTable = function StickyHeadTable(props) {
10319
10354
  return /*#__PURE__*/React.createElement(IUIBox, {
10320
10355
  component: "div",
10321
10356
  width: 80
10322
- }, row && row.has_visited === 0 ? /*#__PURE__*/React.createElement(Tooltip, {
10357
+ }, row && row.has_visited === 0 ? /*#__PURE__*/React.createElement(Tooltip$1, {
10323
10358
  title: "This user hasn't logged in to the platform yet",
10324
10359
  arrow: true,
10325
10360
  classes: {