@itilite/iui-user-management 1.4.768 → 1.4.772

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.
@@ -2382,6 +2382,7 @@ var CardsManagement = function CardsManagement(_ref) {
2382
2382
  var companyCards = cards.filter(function (card) {
2383
2383
  return card.category === 'Company';
2384
2384
  });
2385
+ var cardsCount = personalCards.length + corporateCards.length;
2385
2386
  var _url = env$3.getPaymentUrl() + ("/api/v1/auth/" + IUILocalStorageService$4.getAccessToken() + "/1/" + pg.entity_id + "/0/" + pg.vendor_id + "/1");
2386
2387
  return /*#__PURE__*/React.createElement("div", {
2387
2388
  style: {
@@ -2415,7 +2416,7 @@ var CardsManagement = function CardsManagement(_ref) {
2415
2416
  return renderCard(card);
2416
2417
  }), corporateCards.map(function (card) {
2417
2418
  return renderCard(card);
2418
- })), (!cards || (cards === null || cards === void 0 ? void 0 : cards.length) < 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 !== 2 && /*#__PURE__*/React.createElement("button", {
2419
+ })), (!cards || (cardsCount === null || cardsCount === void 0 ? void 0 : cardsCount.length) < 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", {
2419
2420
  className: classes.addCardButton,
2420
2421
  onClick: function onClick() {
2421
2422
  return window.location.assign(_url);
@@ -2472,14 +2473,16 @@ var CardsManagement = function CardsManagement(_ref) {
2472
2473
 
2473
2474
  var PaymentCards = function PaymentCards(_ref) {
2474
2475
  var _paymentDetails$pg, _paymentDetails$pg2;
2475
- var paymentDetails = _ref.paymentDetails;
2476
- if (!paymentDetails || Object.keys(paymentDetails).length === 0 || (!paymentDetails.cards || paymentDetails.cards.length === 0) && ((paymentDetails === null || paymentDetails === void 0 ? void 0 : (_paymentDetails$pg = paymentDetails.pg) === null || _paymentDetails$pg === void 0 ? void 0 : _paymentDetails$pg.gateway.toLowerCase()) !== 'stripe' || (paymentDetails === null || paymentDetails === void 0 ? void 0 : (_paymentDetails$pg2 = paymentDetails.pg) === null || _paymentDetails$pg2 === void 0 ? void 0 : _paymentDetails$pg2.save_card_enable) !== 1)) {
2476
+ var paymentDetails = _ref.paymentDetails,
2477
+ paymentMethod = _ref.paymentMethod;
2478
+ if (!paymentDetails || Object.keys(paymentDetails).length === 0 || (!paymentDetails.cards || paymentDetails.cards.length === 0) && ((paymentDetails === null || paymentDetails === void 0 ? void 0 : (_paymentDetails$pg = paymentDetails.pg) === null || _paymentDetails$pg === void 0 ? void 0 : _paymentDetails$pg.gateway.toLowerCase()) !== 'stripe' || (paymentDetails === null || paymentDetails === void 0 ? void 0 : (_paymentDetails$pg2 = paymentDetails.pg) === null || _paymentDetails$pg2 === void 0 ? void 0 : _paymentDetails$pg2.save_card_enable) !== 1 || paymentMethod !== 1)) {
2477
2479
  return /*#__PURE__*/React.createElement(React.Fragment, null);
2478
2480
  }
2479
2481
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IUIDivider, {
2480
2482
  className: styles$1.dividerColor
2481
2483
  }), /*#__PURE__*/React.createElement(CardsManagement, {
2482
- paymentDetails: paymentDetails
2484
+ paymentDetails: paymentDetails,
2485
+ paymentMethod: paymentMethod
2483
2486
  }));
2484
2487
  };
2485
2488
 
@@ -6196,7 +6199,7 @@ var UserAddEdit = function UserAddEdit(props) {
6196
6199
  method: 'GET',
6197
6200
  headers: {
6198
6201
  'Content-Type': 'application/json',
6199
- 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
6202
+ authorization: "Bearer " + IUILocalStorageService$5.getAccessToken()
6200
6203
  }
6201
6204
  }).then(function (response) {
6202
6205
  return response.json();
@@ -6208,7 +6211,7 @@ var UserAddEdit = function UserAddEdit(props) {
6208
6211
  IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
6209
6212
  }
6210
6213
  })["catch"](function (error) {
6211
- console.log("errorrr", error);
6214
+ console.log('errorrr', error);
6212
6215
  });
6213
6216
  };
6214
6217
  useEffect(function () {
@@ -6388,13 +6391,20 @@ var UserAddEdit = function UserAddEdit(props) {
6388
6391
  }
6389
6392
  } else if (isCardsDetailsRendered && isProfile && productAccess.card) {
6390
6393
  var targetRole = isCardsAdmin ? 'card-admin' : 'card-holder';
6391
- for (var _iterator = _createForOfIteratorHelperLoose(cardsDetails.cardsRoles), _step; !(_step = _iterator()).done;) {
6392
- var role = _step.value;
6393
- var splitRoleVal = role.value.split(':');
6394
- var profileRole = splitRoleVal[2];
6395
- if (profileRole === targetRole) {
6396
- setCardsRole(role.value);
6397
- break;
6394
+ var _selectedRole = cardsDetails.cardsRoles.find(function (role) {
6395
+ return role.isAssigned;
6396
+ });
6397
+ if (_selectedRole) {
6398
+ setCardsRole(_selectedRole.value);
6399
+ } else {
6400
+ for (var _iterator = _createForOfIteratorHelperLoose(cardsDetails.cardsRoles), _step; !(_step = _iterator()).done;) {
6401
+ var role = _step.value;
6402
+ var splitRoleVal = role.value.split(':');
6403
+ var profileRole = splitRoleVal[2];
6404
+ if (profileRole === targetRole) {
6405
+ setCardsRole(role.value);
6406
+ break;
6407
+ }
6398
6408
  }
6399
6409
  }
6400
6410
  }
@@ -6902,7 +6912,6 @@ var UserAddEdit = function UserAddEdit(props) {
6902
6912
  }
6903
6913
  }, [isTokenVerified]);
6904
6914
  useEffect(function () {
6905
- console.log(isProfile, 'isProfile', id, 'id', editUserId, 'editUserId');
6906
6915
  if (isRendered === true) {
6907
6916
  renderFields === null || renderFields === void 0 ? void 0 : renderFields.products.forEach(function (prod) {
6908
6917
  if ((prod === null || prod === void 0 ? void 0 : prod.name) === 'card') {
@@ -7249,7 +7258,7 @@ var UserAddEdit = function UserAddEdit(props) {
7249
7258
  employeeInfoInput.skip_manager_id = employeeInfoInput.skip_manager.value;
7250
7259
  }
7251
7260
  var cardsPayload = {
7252
- "roles": [cardsRole]
7261
+ roles: [cardsRole]
7253
7262
  };
7254
7263
  var payload = {
7255
7264
  personalInfoInput: personalInfoInput,
@@ -7435,7 +7444,7 @@ var UserAddEdit = function UserAddEdit(props) {
7435
7444
  body: JSON.stringify(cardsPayload),
7436
7445
  headers: {
7437
7446
  'Content-Type': 'application/json',
7438
- 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
7447
+ authorization: "Bearer " + IUILocalStorageService$5.getAccessToken()
7439
7448
  }
7440
7449
  }).then(function (response) {
7441
7450
  if (response.status === 200) {
@@ -7444,7 +7453,7 @@ var UserAddEdit = function UserAddEdit(props) {
7444
7453
  IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
7445
7454
  }
7446
7455
  })["catch"](function (error) {
7447
- console.log("errorrr", error);
7456
+ console.log('errorrr', error);
7448
7457
  })["finally"](function () {
7449
7458
  dispatch(stopLoader());
7450
7459
  });
@@ -7462,14 +7471,14 @@ var UserAddEdit = function UserAddEdit(props) {
7462
7471
  body: JSON.stringify(cardsPayload),
7463
7472
  headers: {
7464
7473
  'Content-Type': 'application/json',
7465
- 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
7474
+ authorization: "Bearer " + IUILocalStorageService$5.getAccessToken()
7466
7475
  }
7467
7476
  }).then(function (response) {
7468
7477
  if (response.status !== 200) {
7469
7478
  IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
7470
7479
  }
7471
7480
  })["catch"](function (error) {
7472
- console.log("errorrr", error);
7481
+ console.log('errorrr', error);
7473
7482
  });
7474
7483
  }
7475
7484
  (config === null || config === void 0 ? void 0 : (_config$routes4 = config.routes) === null || _config$routes4 === void 0 ? void 0 : (_config$routes4$users = _config$routes4.users) === null || _config$routes4$users === void 0 ? void 0 : (_config$routes4$users2 = _config$routes4$users.list) === null || _config$routes4$users2 === void 0 ? void 0 : _config$routes4$users2.path) && history.push(config.routes.users.list.path);
@@ -7924,7 +7933,8 @@ var UserAddEdit = function UserAddEdit(props) {
7924
7933
  maxApprovers: maxExpenseApprovers,
7925
7934
  isProfile: isProfile,
7926
7935
  editUserId: editUserId,
7927
- roles: renderFields.expenseRoles
7936
+ roles: renderFields.expenseRoles,
7937
+ paymentMethod: paymentMethod
7928
7938
  }), /*#__PURE__*/React.createElement(IUIDivider, {
7929
7939
  className: styles.dividerColor
7930
7940
  }), isCardsDetailsRendered && productAccess && productAccess.card && /*#__PURE__*/React.createElement(CardsField, {