@itilite/iui-user-management 1.4.766 → 1.4.771

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.
@@ -2240,6 +2240,7 @@ var CardsManagement = function CardsManagement(_ref) {
2240
2240
  paymentDetails = _ref$paymentDetails === void 0 ? {} : _ref$paymentDetails,
2241
2241
  _ref$paymentMethod = _ref.paymentMethod,
2242
2242
  paymentMethod = _ref$paymentMethod === void 0 ? null : _ref$paymentMethod;
2243
+ console.log(paymentMethod, 'paymentMethod in CardsManagement');
2243
2244
  var dispatch = useDispatch();
2244
2245
  var pg = paymentDetails.pg,
2245
2246
  _paymentDetails$cards = paymentDetails.cards,
@@ -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
+ })), console.log(paymentMethod, 'paymentMethod in card section'), (!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 === 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,17 @@ 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
  }
2481
+ console.log(paymentMethod, 'paymentMethod in payment cards');
2479
2482
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IUIDivider, {
2480
2483
  className: styles$1.dividerColor
2481
2484
  }), /*#__PURE__*/React.createElement(CardsManagement, {
2482
- paymentDetails: paymentDetails
2485
+ paymentDetails: paymentDetails,
2486
+ paymentMethod: paymentMethod
2483
2487
  }));
2484
2488
  };
2485
2489
 
@@ -6196,7 +6200,7 @@ var UserAddEdit = function UserAddEdit(props) {
6196
6200
  method: 'GET',
6197
6201
  headers: {
6198
6202
  'Content-Type': 'application/json',
6199
- 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
6203
+ authorization: "Bearer " + IUILocalStorageService$5.getAccessToken()
6200
6204
  }
6201
6205
  }).then(function (response) {
6202
6206
  return response.json();
@@ -6208,27 +6212,7 @@ var UserAddEdit = function UserAddEdit(props) {
6208
6212
  IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
6209
6213
  }
6210
6214
  })["catch"](function (error) {
6211
- console.log("errorrr", error);
6212
- });
6213
- };
6214
- var fetchLoggedUserCardsDetails = function fetchLoggedUserCardsDetails() {
6215
- fetch(userAddEditUrl.cardsAddUsersDetails(), {
6216
- method: 'GET',
6217
- headers: {
6218
- 'Content-Type': 'application/json',
6219
- 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
6220
- }
6221
- }).then(function (response) {
6222
- return response.json();
6223
- }).then(function (res) {
6224
- var _res$roles2;
6225
- if (res !== null && res !== void 0 && (_res$roles2 = res.roles) !== null && _res$roles2 !== void 0 && _res$roles2.length) {
6226
- dispatch(setCardsDetails(res));
6227
- } else {
6228
- IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
6229
- }
6230
- })["catch"](function (error) {
6231
- console.log("errorrr", error);
6215
+ console.log('errorrr', error);
6232
6216
  });
6233
6217
  };
6234
6218
  useEffect(function () {
@@ -6408,13 +6392,20 @@ var UserAddEdit = function UserAddEdit(props) {
6408
6392
  }
6409
6393
  } else if (isCardsDetailsRendered && isProfile && productAccess.card) {
6410
6394
  var targetRole = isCardsAdmin ? 'card-admin' : 'card-holder';
6411
- for (var _iterator = _createForOfIteratorHelperLoose(cardsDetails.cardsRoles), _step; !(_step = _iterator()).done;) {
6412
- var role = _step.value;
6413
- var splitRoleVal = role.value.split(':');
6414
- var profileRole = splitRoleVal[2];
6415
- if (profileRole === targetRole) {
6416
- setCardsRole(role.value);
6417
- break;
6395
+ var _selectedRole = cardsDetails.cardsRoles.find(function (role) {
6396
+ return role.isAssigned;
6397
+ });
6398
+ if (_selectedRole) {
6399
+ setCardsRole(_selectedRole.value);
6400
+ } else {
6401
+ for (var _iterator = _createForOfIteratorHelperLoose(cardsDetails.cardsRoles), _step; !(_step = _iterator()).done;) {
6402
+ var role = _step.value;
6403
+ var splitRoleVal = role.value.split(':');
6404
+ var profileRole = splitRoleVal[2];
6405
+ if (profileRole === targetRole) {
6406
+ setCardsRole(role.value);
6407
+ break;
6408
+ }
6418
6409
  }
6419
6410
  }
6420
6411
  }
@@ -6925,7 +6916,7 @@ var UserAddEdit = function UserAddEdit(props) {
6925
6916
  if (isRendered === true) {
6926
6917
  renderFields === null || renderFields === void 0 ? void 0 : renderFields.products.forEach(function (prod) {
6927
6918
  if ((prod === null || prod === void 0 ? void 0 : prod.name) === 'card') {
6928
- editUserId ? fetchEditUserCardsDetails(editUserId) : fetchLoggedUserCardsDetails();
6919
+ fetchEditUserCardsDetails(isProfile ? id : editUserId);
6929
6920
  }
6930
6921
  });
6931
6922
  setPersonalInfoInput(_extends({}, personalInfoInput, {
@@ -7268,7 +7259,7 @@ var UserAddEdit = function UserAddEdit(props) {
7268
7259
  employeeInfoInput.skip_manager_id = employeeInfoInput.skip_manager.value;
7269
7260
  }
7270
7261
  var cardsPayload = {
7271
- "roles": [cardsRole]
7262
+ roles: [cardsRole]
7272
7263
  };
7273
7264
  var payload = {
7274
7265
  personalInfoInput: personalInfoInput,
@@ -7454,7 +7445,7 @@ var UserAddEdit = function UserAddEdit(props) {
7454
7445
  body: JSON.stringify(cardsPayload),
7455
7446
  headers: {
7456
7447
  'Content-Type': 'application/json',
7457
- 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
7448
+ authorization: "Bearer " + IUILocalStorageService$5.getAccessToken()
7458
7449
  }
7459
7450
  }).then(function (response) {
7460
7451
  if (response.status === 200) {
@@ -7463,7 +7454,7 @@ var UserAddEdit = function UserAddEdit(props) {
7463
7454
  IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
7464
7455
  }
7465
7456
  })["catch"](function (error) {
7466
- console.log("errorrr", error);
7457
+ console.log('errorrr', error);
7467
7458
  })["finally"](function () {
7468
7459
  dispatch(stopLoader());
7469
7460
  });
@@ -7481,14 +7472,14 @@ var UserAddEdit = function UserAddEdit(props) {
7481
7472
  body: JSON.stringify(cardsPayload),
7482
7473
  headers: {
7483
7474
  'Content-Type': 'application/json',
7484
- 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
7475
+ authorization: "Bearer " + IUILocalStorageService$5.getAccessToken()
7485
7476
  }
7486
7477
  }).then(function (response) {
7487
7478
  if (response.status !== 200) {
7488
7479
  IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
7489
7480
  }
7490
7481
  })["catch"](function (error) {
7491
- console.log("errorrr", error);
7482
+ console.log('errorrr', error);
7492
7483
  });
7493
7484
  }
7494
7485
  (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);
@@ -7943,7 +7934,8 @@ var UserAddEdit = function UserAddEdit(props) {
7943
7934
  maxApprovers: maxExpenseApprovers,
7944
7935
  isProfile: isProfile,
7945
7936
  editUserId: editUserId,
7946
- roles: renderFields.expenseRoles
7937
+ roles: renderFields.expenseRoles,
7938
+ paymentMethod: paymentMethod
7947
7939
  }), /*#__PURE__*/React.createElement(IUIDivider, {
7948
7940
  className: styles.dividerColor
7949
7941
  }), isCardsDetailsRendered && productAccess && productAccess.card && /*#__PURE__*/React.createElement(CardsField, {