@itilite/iui-user-management 1.4.964-beta.11 → 1.4.964-beta.13

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.
@@ -1379,9 +1379,9 @@ var updateActiveStatus = function updateActiveStatus(activateVal, id, roleTransf
1379
1379
  };
1380
1380
  };
1381
1381
 
1382
- var api$2 = configs.api;
1383
- var IUIToastMessageService$1 = services.IUIToastMessageService,
1384
- IUILocalStorageService$2 = services.IUILocalStorageService;
1382
+ var api$2 = configs.api,
1383
+ paymentApi = configs.paymentApi;
1384
+ var IUIToastMessageService$1 = services.IUIToastMessageService;
1385
1385
  var showLoader = function showLoader() {
1386
1386
  return {
1387
1387
  type: SHOW_LOADER
@@ -1820,11 +1820,7 @@ var deletePaymentCard = function deletePaymentCard(payload) {
1820
1820
  return function (dispatch, getState) {
1821
1821
  return new Promise(function (resolve, reject) {
1822
1822
  dispatch(showLoader());
1823
- axios["delete"](userAddEditUrl.deletePaymentCard(payload.pmId, payload.vendorId), {
1824
- headers: {
1825
- Authorization: 'Bearer ' + IUILocalStorageService$2.getAccessToken()
1826
- }
1827
- }).then(function (res) {
1823
+ paymentApi["delete"](userAddEditUrl.deletePaymentCard(payload.pmId, payload.vendorId)).then(function (res) {
1828
1824
  if (res.data.status) {
1829
1825
  resolve(res.data.result);
1830
1826
  var _paymentDetails = getState().userAddEdit.paymentDetails;
@@ -1851,11 +1847,7 @@ var setDefaultPaymentCard = function setDefaultPaymentCard(payload) {
1851
1847
  return function (dispatch, getState) {
1852
1848
  return new Promise(function (resolve, reject) {
1853
1849
  dispatch(showLoader());
1854
- axios.put(userAddEditUrl.setDefaultCard(), payload, {
1855
- headers: {
1856
- Authorization: 'Bearer ' + IUILocalStorageService$2.getAccessToken()
1857
- }
1858
- }).then(function (res) {
1850
+ paymentApi.put(userAddEditUrl.setDefaultCard(), payload).then(function (res) {
1859
1851
  if (res.data.status) {
1860
1852
  resolve(res.data.result);
1861
1853
  var _paymentDetails = getState().userAddEdit.paymentDetails;
@@ -2073,7 +2065,7 @@ var SET_VERIFICATION_ERROR = 'SET_VERIFICATION_ERROR';
2073
2065
  var api$4 = configs.api,
2074
2066
  env$2 = configs.env;
2075
2067
  var common = utilUrls.common;
2076
- var IUILocalStorageService$3 = services.IUILocalStorageService;
2068
+ var IUILocalStorageService$2 = services.IUILocalStorageService;
2077
2069
  var setTokenResponse = function setTokenResponse(payload) {
2078
2070
  return {
2079
2071
  type: VERIFY_ACCESS_TOKEN,
@@ -2094,7 +2086,7 @@ var verifyAccessToken = function verifyAccessToken(roleCanAccess) {
2094
2086
  return new Promise(function (resolve, reject) {
2095
2087
  dispatch(setVerificationError(false));
2096
2088
  api$4.post(common.verifyToken(), {
2097
- client_id: +IUILocalStorageService$3.getClientId() || null,
2089
+ client_id: +IUILocalStorageService$2.getClientId() || null,
2098
2090
  product: env$2.isExpense() ? 'expense' : 'travel'
2099
2091
  }).then(function (res) {
2100
2092
  if (res.data.status === true) {
@@ -2104,21 +2096,21 @@ var verifyAccessToken = function verifyAccessToken(roleCanAccess) {
2104
2096
  return;
2105
2097
  }
2106
2098
  if (env$2.isProfilePage()) {
2107
- IUILocalStorageService$3.setCompanyId(res.data.company);
2099
+ IUILocalStorageService$2.setCompanyId(res.data.company);
2108
2100
  dispatch(setTokenResponse(res.data));
2109
2101
  dispatch(setVerificationError(false));
2110
2102
  if (env$2.isExpense()) {
2111
- IUILocalStorageService$3.setRole('submitter');
2103
+ IUILocalStorageService$2.setRole('submitter');
2112
2104
  } else {
2113
- IUILocalStorageService$3.setRole('traveler');
2105
+ IUILocalStorageService$2.setRole('traveler');
2114
2106
  }
2115
2107
  resolve();
2116
2108
  return;
2117
2109
  } else {
2118
2110
  for (var index = 0; index < res.data.applicable_role.length; index++) {
2119
2111
  if (roleCanAccess.includes(res.data.applicable_role[index])) {
2120
- IUILocalStorageService$3.setCompanyId(res.data.company);
2121
- IUILocalStorageService$3.setRole(res.data.applicable_role[index]);
2112
+ IUILocalStorageService$2.setCompanyId(res.data.company);
2113
+ IUILocalStorageService$2.setRole(res.data.applicable_role[index]);
2122
2114
  dispatch(setTokenResponse(res.data));
2123
2115
  dispatch(setVerificationError(false));
2124
2116
  resolve();
@@ -2674,7 +2666,7 @@ var CARDS_DISABLED = {
2674
2666
  INVALID: '3'
2675
2667
  };
2676
2668
 
2677
- var IUILocalStorageService$4 = services.IUILocalStorageService;
2669
+ var IUILocalStorageService$3 = services.IUILocalStorageService;
2678
2670
  var env$3 = configs.env;
2679
2671
  var CardsManagement = function CardsManagement(_ref) {
2680
2672
  var _selectedCard$metadat, _pg$gateway;
@@ -2887,7 +2879,7 @@ var CardsManagement = function CardsManagement(_ref) {
2887
2879
  className: classes.cardFooter
2888
2880
  }, /*#__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))));
2889
2881
  };
2890
- var _url = env$3.getPaymentUrl() + ("/api/v1/auth/" + IUILocalStorageService$4.getAccessToken() + "/1/" + pg.entity_id + "/0/" + pg.vendor_id + "/1");
2882
+ var _url = env$3.getPaymentUrl() + ("/api/v1/auth/" + IUILocalStorageService$3.getAccessToken() + "/1/" + pg.entity_id + "/0/" + pg.vendor_id + "/1");
2891
2883
  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);
2892
2884
  return /*#__PURE__*/React.createElement("div", {
2893
2885
  style: {
@@ -6535,9 +6527,9 @@ var CardsField = function CardsField(props) {
6535
6527
  }, editUserId ? "Only Card admin can change the Card role." : "Only Card admin can change card roles. By default this user will have Card Holder role.")))));
6536
6528
  };
6537
6529
 
6538
- var IUIToastMessageService$6 = services.IUIToastMessageService,
6539
- IUILocalStorageService$5 = services.IUILocalStorageService;
6540
- var env$4 = configs.env;
6530
+ var IUIToastMessageService$6 = services.IUIToastMessageService;
6531
+ var cardsApi = configs.cardsApi,
6532
+ env$4 = configs.env;
6541
6533
  var UserAddEdit = function UserAddEdit(props) {
6542
6534
  var isEditMode = props.isEditMode,
6543
6535
  editUserId = props.editUserId,
@@ -6752,14 +6744,8 @@ var UserAddEdit = function UserAddEdit(props) {
6752
6744
  });
6753
6745
  };
6754
6746
  var fetchEditUserCardsDetails = function fetchEditUserCardsDetails(editUserId) {
6755
- fetch(userAddEditUrl.cardsEditUserDetails(editUserId), {
6756
- method: 'GET',
6757
- headers: {
6758
- 'Content-Type': 'application/json',
6759
- authorization: "Bearer " + IUILocalStorageService$5.getAccessToken()
6760
- }
6761
- }).then(function (response) {
6762
- return response.json();
6747
+ cardsApi.get(userAddEditUrl.cardsEditUserDetails(editUserId)).then(function (response) {
6748
+ return response.data;
6763
6749
  }).then(function (res) {
6764
6750
  var _res$roles;
6765
6751
  if (res !== null && res !== void 0 && (_res$roles = res.roles) !== null && _res$roles !== void 0 && _res$roles.length) {
@@ -6768,18 +6754,16 @@ var UserAddEdit = function UserAddEdit(props) {
6768
6754
  IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
6769
6755
  }
6770
6756
  })["catch"](function (error) {
6771
- console.log('errorrr', error);
6757
+ if (error !== null && error !== void 0 && error.response) {
6758
+ IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
6759
+ } else {
6760
+ console.log('errorrr', error);
6761
+ }
6772
6762
  });
6773
6763
  };
6774
6764
  var fetchLoggedUserCardsDetails = function fetchLoggedUserCardsDetails() {
6775
- fetch(userAddEditUrl.cardsAddUsersDetails(), {
6776
- method: 'GET',
6777
- headers: {
6778
- 'Content-Type': 'application/json',
6779
- authorization: "Bearer " + IUILocalStorageService$5.getAccessToken()
6780
- }
6781
- }).then(function (response) {
6782
- return response.json();
6765
+ cardsApi.get(userAddEditUrl.cardsAddUsersDetails()).then(function (response) {
6766
+ return response.data;
6783
6767
  }).then(function (res) {
6784
6768
  var _res$roles2;
6785
6769
  if (res !== null && res !== void 0 && (_res$roles2 = res.roles) !== null && _res$roles2 !== void 0 && _res$roles2.length) {
@@ -6788,7 +6772,11 @@ var UserAddEdit = function UserAddEdit(props) {
6788
6772
  IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
6789
6773
  }
6790
6774
  })["catch"](function (error) {
6791
- console.log('errorrr', error);
6775
+ if (error !== null && error !== void 0 && error.response) {
6776
+ IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
6777
+ } else {
6778
+ console.log('errorrr', error);
6779
+ }
6792
6780
  });
6793
6781
  };
6794
6782
  useEffect(function () {
@@ -8027,21 +8015,18 @@ var UserAddEdit = function UserAddEdit(props) {
8027
8015
  if (isEditMode && editUserId || isProfile) {
8028
8016
  dispatch(showLoader());
8029
8017
  if (cardApiflag && !isProfile && editUserId !== (id === null || id === void 0 ? void 0 : id.toString())) {
8030
- fetch(userAddEditUrl.cardsEditUserDetails(editUserId), {
8031
- method: 'POST',
8032
- body: JSON.stringify(cardsPayload),
8033
- headers: {
8034
- 'Content-Type': 'application/json',
8035
- authorization: "Bearer " + IUILocalStorageService$5.getAccessToken()
8036
- }
8037
- }).then(function (response) {
8018
+ cardsApi.post(userAddEditUrl.cardsEditUserDetails(editUserId), cardsPayload).then(function (response) {
8038
8019
  if (response.status === 200) {
8039
8020
  updateUserApiCall(payload, inputChangeLog);
8040
8021
  } else {
8041
8022
  IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
8042
8023
  }
8043
8024
  })["catch"](function (error) {
8044
- console.log('errorrr', error);
8025
+ if (error !== null && error !== void 0 && error.response) {
8026
+ IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
8027
+ } else {
8028
+ console.log('errorrr', error);
8029
+ }
8045
8030
  })["finally"](function () {
8046
8031
  dispatch(stopLoader());
8047
8032
  });
@@ -8054,19 +8039,16 @@ var UserAddEdit = function UserAddEdit(props) {
8054
8039
  dispatch(createUser(payload)).then(function (res) {
8055
8040
  var _config$routes4, _config$routes4$users, _config$routes4$users2;
8056
8041
  if (res !== null && res !== void 0 && res.user_id) {
8057
- fetch(userAddEditUrl.cardsEditUserDetails(res === null || res === void 0 ? void 0 : res.user_id), {
8058
- method: 'POST',
8059
- body: JSON.stringify(cardsPayload),
8060
- headers: {
8061
- 'Content-Type': 'application/json',
8062
- authorization: "Bearer " + IUILocalStorageService$5.getAccessToken()
8063
- }
8064
- }).then(function (response) {
8042
+ cardsApi.post(userAddEditUrl.cardsEditUserDetails(res === null || res === void 0 ? void 0 : res.user_id), cardsPayload).then(function (response) {
8065
8043
  if (response.status !== 200) {
8066
8044
  IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
8067
8045
  }
8068
8046
  })["catch"](function (error) {
8069
- console.log('errorrr', error);
8047
+ if (error !== null && error !== void 0 && error.response) {
8048
+ IUIToastMessageService$6.warningNotify('Opps, Something went wrong.');
8049
+ } else {
8050
+ console.log('errorrr', error);
8051
+ }
8070
8052
  });
8071
8053
  }
8072
8054
  (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);