@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.
package/dist/index.js CHANGED
@@ -2385,6 +2385,7 @@ var CardsManagement = function CardsManagement(_ref) {
2385
2385
  var companyCards = cards.filter(function (card) {
2386
2386
  return card.category === 'Company';
2387
2387
  });
2388
+ var cardsCount = personalCards.length + corporateCards.length;
2388
2389
  var _url = env$3.getPaymentUrl() + ("/api/v1/auth/" + IUILocalStorageService$4.getAccessToken() + "/1/" + pg.entity_id + "/0/" + pg.vendor_id + "/1");
2389
2390
  return /*#__PURE__*/React__default.createElement("div", {
2390
2391
  style: {
@@ -2418,7 +2419,7 @@ var CardsManagement = function CardsManagement(_ref) {
2418
2419
  return renderCard(card);
2419
2420
  }), corporateCards.map(function (card) {
2420
2421
  return renderCard(card);
2421
- })), (!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__default.createElement("button", {
2422
+ })), (!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__default.createElement("button", {
2422
2423
  className: classes.addCardButton,
2423
2424
  onClick: function onClick() {
2424
2425
  return window.location.assign(_url);
@@ -2475,14 +2476,16 @@ var CardsManagement = function CardsManagement(_ref) {
2475
2476
 
2476
2477
  var PaymentCards = function PaymentCards(_ref) {
2477
2478
  var _paymentDetails$pg, _paymentDetails$pg2;
2478
- var paymentDetails = _ref.paymentDetails;
2479
- 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)) {
2479
+ var paymentDetails = _ref.paymentDetails,
2480
+ paymentMethod = _ref.paymentMethod;
2481
+ 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)) {
2480
2482
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
2481
2483
  }
2482
2484
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(iuistyles.IUIDivider, {
2483
2485
  className: styles$1.dividerColor
2484
2486
  }), /*#__PURE__*/React__default.createElement(CardsManagement, {
2485
- paymentDetails: paymentDetails
2487
+ paymentDetails: paymentDetails,
2488
+ paymentMethod: paymentMethod
2486
2489
  }));
2487
2490
  };
2488
2491
 
@@ -6199,7 +6202,7 @@ var UserAddEdit = function UserAddEdit(props) {
6199
6202
  method: 'GET',
6200
6203
  headers: {
6201
6204
  'Content-Type': 'application/json',
6202
- 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
6205
+ authorization: "Bearer " + IUILocalStorageService$5.getAccessToken()
6203
6206
  }
6204
6207
  }).then(function (response) {
6205
6208
  return response.json();
@@ -6211,7 +6214,7 @@ var UserAddEdit = function UserAddEdit(props) {
6211
6214
  IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
6212
6215
  }
6213
6216
  })["catch"](function (error) {
6214
- console.log("errorrr", error);
6217
+ console.log('errorrr', error);
6215
6218
  });
6216
6219
  };
6217
6220
  React.useEffect(function () {
@@ -6391,13 +6394,20 @@ var UserAddEdit = function UserAddEdit(props) {
6391
6394
  }
6392
6395
  } else if (isCardsDetailsRendered && isProfile && productAccess.card) {
6393
6396
  var targetRole = isCardsAdmin ? 'card-admin' : 'card-holder';
6394
- for (var _iterator = _createForOfIteratorHelperLoose(cardsDetails.cardsRoles), _step; !(_step = _iterator()).done;) {
6395
- var role = _step.value;
6396
- var splitRoleVal = role.value.split(':');
6397
- var profileRole = splitRoleVal[2];
6398
- if (profileRole === targetRole) {
6399
- setCardsRole(role.value);
6400
- break;
6397
+ var _selectedRole = cardsDetails.cardsRoles.find(function (role) {
6398
+ return role.isAssigned;
6399
+ });
6400
+ if (_selectedRole) {
6401
+ setCardsRole(_selectedRole.value);
6402
+ } else {
6403
+ for (var _iterator = _createForOfIteratorHelperLoose(cardsDetails.cardsRoles), _step; !(_step = _iterator()).done;) {
6404
+ var role = _step.value;
6405
+ var splitRoleVal = role.value.split(':');
6406
+ var profileRole = splitRoleVal[2];
6407
+ if (profileRole === targetRole) {
6408
+ setCardsRole(role.value);
6409
+ break;
6410
+ }
6401
6411
  }
6402
6412
  }
6403
6413
  }
@@ -6905,7 +6915,6 @@ var UserAddEdit = function UserAddEdit(props) {
6905
6915
  }
6906
6916
  }, [isTokenVerified]);
6907
6917
  React.useEffect(function () {
6908
- console.log(isProfile, 'isProfile', id, 'id', editUserId, 'editUserId');
6909
6918
  if (isRendered === true) {
6910
6919
  renderFields === null || renderFields === void 0 ? void 0 : renderFields.products.forEach(function (prod) {
6911
6920
  if ((prod === null || prod === void 0 ? void 0 : prod.name) === 'card') {
@@ -7252,7 +7261,7 @@ var UserAddEdit = function UserAddEdit(props) {
7252
7261
  employeeInfoInput.skip_manager_id = employeeInfoInput.skip_manager.value;
7253
7262
  }
7254
7263
  var cardsPayload = {
7255
- "roles": [cardsRole]
7264
+ roles: [cardsRole]
7256
7265
  };
7257
7266
  var payload = {
7258
7267
  personalInfoInput: personalInfoInput,
@@ -7438,7 +7447,7 @@ var UserAddEdit = function UserAddEdit(props) {
7438
7447
  body: JSON.stringify(cardsPayload),
7439
7448
  headers: {
7440
7449
  'Content-Type': 'application/json',
7441
- 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
7450
+ authorization: "Bearer " + IUILocalStorageService$5.getAccessToken()
7442
7451
  }
7443
7452
  }).then(function (response) {
7444
7453
  if (response.status === 200) {
@@ -7447,7 +7456,7 @@ var UserAddEdit = function UserAddEdit(props) {
7447
7456
  IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
7448
7457
  }
7449
7458
  })["catch"](function (error) {
7450
- console.log("errorrr", error);
7459
+ console.log('errorrr', error);
7451
7460
  })["finally"](function () {
7452
7461
  dispatch(stopLoader());
7453
7462
  });
@@ -7465,14 +7474,14 @@ var UserAddEdit = function UserAddEdit(props) {
7465
7474
  body: JSON.stringify(cardsPayload),
7466
7475
  headers: {
7467
7476
  'Content-Type': 'application/json',
7468
- 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
7477
+ authorization: "Bearer " + IUILocalStorageService$5.getAccessToken()
7469
7478
  }
7470
7479
  }).then(function (response) {
7471
7480
  if (response.status !== 200) {
7472
7481
  IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
7473
7482
  }
7474
7483
  })["catch"](function (error) {
7475
- console.log("errorrr", error);
7484
+ console.log('errorrr', error);
7476
7485
  });
7477
7486
  }
7478
7487
  (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);
@@ -7927,7 +7936,8 @@ var UserAddEdit = function UserAddEdit(props) {
7927
7936
  maxApprovers: maxExpenseApprovers,
7928
7937
  isProfile: isProfile,
7929
7938
  editUserId: editUserId,
7930
- roles: renderFields.expenseRoles
7939
+ roles: renderFields.expenseRoles,
7940
+ paymentMethod: paymentMethod
7931
7941
  }), /*#__PURE__*/React__default.createElement(iuistyles.IUIDivider, {
7932
7942
  className: styles.dividerColor
7933
7943
  }), isCardsDetailsRendered && productAccess && productAccess.card && /*#__PURE__*/React__default.createElement(CardsField, {