@itilite/iui-user-management 0.4.52 → 0.4.53

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.
@@ -32,6 +32,37 @@ function _extends() {
32
32
  };
33
33
  return _extends.apply(this, arguments);
34
34
  }
35
+ function _unsupportedIterableToArray(o, minLen) {
36
+ if (!o) return;
37
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
38
+ var n = Object.prototype.toString.call(o).slice(8, -1);
39
+ if (n === "Object" && o.constructor) n = o.constructor.name;
40
+ if (n === "Map" || n === "Set") return Array.from(o);
41
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
42
+ }
43
+ function _arrayLikeToArray(arr, len) {
44
+ if (len == null || len > arr.length) len = arr.length;
45
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
46
+ return arr2;
47
+ }
48
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
49
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
50
+ if (it) return (it = it.call(o)).next.bind(it);
51
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
52
+ if (it) o = it;
53
+ var i = 0;
54
+ return function () {
55
+ if (i >= o.length) return {
56
+ done: true
57
+ };
58
+ return {
59
+ done: false,
60
+ value: o[i++]
61
+ };
62
+ };
63
+ }
64
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
65
+ }
35
66
 
36
67
  var _Pact = /*#__PURE__*/function () {
37
68
  function _Pact() {}
@@ -389,6 +420,12 @@ var userAddEditUrl = {
389
420
  },
390
421
  undoRejectUserVerification: function undoRejectUserVerification(userId) {
391
422
  return "api/v1/onboarding/user-signup-reject/" + userId + "?action=undo";
423
+ },
424
+ cardsEditUserDetails: function cardsEditUserDetails(userId) {
425
+ return env.getCardsapiURL() + "/card/authorization/user/" + userId;
426
+ },
427
+ cardsAddUsersDetails: function cardsAddUsersDetails() {
428
+ return env.getCardsapiURL() + "/card/authorization/company/" + IUILocalStorageService.getCompanyId() + "/roles";
392
429
  }
393
430
  };
394
431
  var userListUrl = {
@@ -747,7 +784,6 @@ var departmentHeadOptions = function departmentHeadOptions(search, loadedOptions
747
784
  data: item
748
785
  };
749
786
  });
750
- console.log(response.next);
751
787
  return {
752
788
  options: mappedValue,
753
789
  hasMore: !!response.next,
@@ -792,6 +828,7 @@ var styles$1 = {"card":"_3_S9J","cardNumber":"_36E9M","cardDigit":"_2pm-T","expi
792
828
  var SHOW_LOADER = 'SHOW_LOADER';
793
829
  var STOP_LOADER = 'STOP_LOADER';
794
830
  var SET_RENDER_FIELDS = 'SET_RENDER_FIELDS';
831
+ var SET_CARDS_DETAILS = 'SET_CARDS_DETAILS';
795
832
  var SET_CUSTOM_FIELD = 'SET_CUSTOM_FIELD';
796
833
  var SET_TRAVEL_APPROVER_FIELD = 'SET_TRAVEL_APPROVER_FIELD';
797
834
  var SET_EXPENSE_APPROVER_FIELD = 'SET_EXPENSE_APPROVER_FIELD';
@@ -836,9 +873,15 @@ var formatCreateUserPayload = function formatCreateUserPayload(payload) {
836
873
  if (payload.productAccess.expense) {
837
874
  product.expense = payload.expenseRole || null;
838
875
  }
876
+ if (payload.productAccess.cards) {
877
+ var splitRole = payload.cardsRole.split(":");
878
+ var cardsUsmRole = splitRole[2];
879
+ product.cards = cardsUsmRole || null;
880
+ }
839
881
  return product;
840
882
  }(),
841
- approvers: {}
883
+ approvers: {},
884
+ requested_user_is_admin: payload.isCardsAdmin
842
885
  };
843
886
  var userTags = [];
844
887
  for (var key in payload.userTagType) {
@@ -930,13 +973,20 @@ var formatUpdateUserPayload = function formatUpdateUserPayload(payload, inputCha
930
973
  var res = {
931
974
  fields: {
932
975
  user_personal_info: {},
933
- employee_info: {}
976
+ employee_info: {},
977
+ requested_user_is_admin: payload.isCardsAdmin
934
978
  }
935
979
  };
936
980
  if (!env$1.isProfilePage()) {
937
981
  res.fields.product = function () {
938
- if (payload.productAccess.travel && payload.productAccess.expense) {
982
+ if (payload.productAccess.travel && payload.productAccess.expense && payload.productAccess.cards) {
983
+ return 'expense+travel+cards';
984
+ } else if (payload.productAccess.travel && payload.productAccess.expense) {
939
985
  return 'expense+travel';
986
+ } else if (payload.productAccess.expense && payload.productAccess.cards) {
987
+ return 'expense+cards';
988
+ } else if (payload.productAccess.travel && payload.productAccess.cards) {
989
+ return 'travel+cards';
940
990
  } else if (payload.productAccess.travel) {
941
991
  return 'travel';
942
992
  } else {
@@ -951,6 +1001,11 @@ var formatUpdateUserPayload = function formatUpdateUserPayload(payload, inputCha
951
1001
  if (payload.productAccess.expense) {
952
1002
  roles.expense = payload.expenseRole;
953
1003
  }
1004
+ if (payload.productAccess.cards) {
1005
+ var splitRole = payload.cardsRole.split(":");
1006
+ var cardsUsmRole = splitRole[2];
1007
+ roles.cards = cardsUsmRole;
1008
+ }
954
1009
  return roles;
955
1010
  }();
956
1011
  res.fields.custom_attributes = payload.customFieldsInput;
@@ -1289,6 +1344,12 @@ var setRenderFields = function setRenderFields(payload) {
1289
1344
  payload: payload
1290
1345
  };
1291
1346
  };
1347
+ var setCardsDetails = function setCardsDetails(payload) {
1348
+ return {
1349
+ type: SET_CARDS_DETAILS,
1350
+ payload: payload
1351
+ };
1352
+ };
1292
1353
  var setCustomField = function setCustomField(payload) {
1293
1354
  return {
1294
1355
  type: SET_CUSTOM_FIELD,
@@ -1360,7 +1421,7 @@ var fetchCountryCodes = function fetchCountryCodes() {
1360
1421
  return new Promise(function (resolve, reject) {
1361
1422
  api$2.get(userAddEditUrl.countryCode()).then(function (res) {
1362
1423
  dispatch(setCountryCodes(res.data.country_code_details));
1363
- resolve('success');
1424
+ resolve(res.data.country_code_details);
1364
1425
  })["catch"](function (err) {
1365
1426
  reject(err);
1366
1427
  })["finally"](function () {});
@@ -1514,7 +1575,6 @@ var createUser = function createUser(payload) {
1514
1575
  return new Promise(function (resolve, reject) {
1515
1576
  api$2.post(userAddEditUrl.createUser(), formatCreateUserPayload(payload)).then(function (res) {
1516
1577
  if (res.data.status === true) {
1517
- IUIToastMessageService$1.sNotify(res.data.message);
1518
1578
  resolve(res.data);
1519
1579
  } else {
1520
1580
  if (res.data.errors && typeof res.data.errors === 'object') {
@@ -1665,7 +1725,6 @@ var updateUser = function updateUser(payload, userId, inputChangeLog) {
1665
1725
  return new Promise(function (resolve, reject) {
1666
1726
  api$2.put(userAddEditUrl.editUser(userId), formatUpdateUserPayload(payload, inputChangeLog)).then(function (res) {
1667
1727
  if (res.data.status === true) {
1668
- IUIToastMessageService$1.sNotify(res.data.message);
1669
1728
  resolve(res.data);
1670
1729
  } else {
1671
1730
  if (!Object.keys(res.data.errors).length) {
@@ -3191,6 +3250,12 @@ var products = [{
3191
3250
  name: 'expense',
3192
3251
  type: 'checkbox',
3193
3252
  disableText: 'Please get in touch with your administrator to change this value.'
3253
+ }, {
3254
+ id: 3,
3255
+ label: 'Cards',
3256
+ name: 'cards',
3257
+ type: 'checkbox',
3258
+ disableText: 'Please get in touch with your administrator to change this value.'
3194
3259
  }];
3195
3260
  var dropdownList = {
3196
3261
  gender: [{
@@ -3361,6 +3426,34 @@ var expenseConstants = {
3361
3426
  disableText: 'Please get in touch with your administrator to change this value.'
3362
3427
  }]
3363
3428
  };
3429
+ var cardsConstants = {
3430
+ heading: 'Card specific information',
3431
+ roleHeading: 'Card role',
3432
+ roleDescription: 'Roles allow users to only access relevant features and functionalities',
3433
+ roles: [{
3434
+ id: 1,
3435
+ label: 'Card holder',
3436
+ description: 'Can own and use cards that are issued to them',
3437
+ value: '',
3438
+ name: '',
3439
+ type: 'radio',
3440
+ isAssigned: false,
3441
+ fullWidth: false,
3442
+ visibility: true,
3443
+ disableText: 'Please get in touch with your administrator to change this value.'
3444
+ }, {
3445
+ id: 2,
3446
+ label: 'Card admin',
3447
+ description: 'Can issue cards to others and can manage all cards and transactions across the company.',
3448
+ value: '',
3449
+ name: '',
3450
+ type: 'radio',
3451
+ isAssigned: false,
3452
+ fullWidth: false,
3453
+ visibility: true,
3454
+ disableText: 'Please get in touch with your administrator to change this value.'
3455
+ }]
3456
+ };
3364
3457
  var passportInfo = [{
3365
3458
  id: 1,
3366
3459
  label: 'Passport issuing country',
@@ -3590,6 +3683,12 @@ var initialState = {
3590
3683
  travelConstants: travelConstants,
3591
3684
  expenseConstants: expenseConstants
3592
3685
  },
3686
+ isCardsDetailsRendered: false,
3687
+ isCardsAdmin: false,
3688
+ cardsDetails: {
3689
+ cardsRoles: cardsConstants.roles,
3690
+ cardsConstants: cardsConstants
3691
+ },
3593
3692
  dropdownList: dropdownList,
3594
3693
  maxTravelApprovers: 10,
3595
3694
  maxExpenseApprovers: 10,
@@ -3756,11 +3855,37 @@ var reducer = function reducer(state, action) {
3756
3855
  isRendered: true
3757
3856
  });
3758
3857
  }
3858
+ case SET_CARDS_DETAILS:
3859
+ {
3860
+ var _action$payload8, _action$payload8$role, _action$payload9;
3861
+ var cardsDetails = _extends({}, state.cardsDetails);
3862
+ if (action !== null && action !== void 0 && (_action$payload8 = action.payload) !== null && _action$payload8 !== void 0 && (_action$payload8$role = _action$payload8.roles) !== null && _action$payload8$role !== void 0 && _action$payload8$role.length) {
3863
+ cardsDetails.cardsRoles = action.payload.roles.map(function (role) {
3864
+ return {
3865
+ id: role.id,
3866
+ label: role.name,
3867
+ description: role.description,
3868
+ value: role.value,
3869
+ isAssigned: role.is_assigned,
3870
+ name: role.value,
3871
+ type: 'radio',
3872
+ fullWidth: false,
3873
+ visibility: true,
3874
+ disableText: 'Please get in touch with your administrator to change this value.'
3875
+ };
3876
+ });
3877
+ }
3878
+ return _extends({}, state, {
3879
+ cardsDetails: cardsDetails,
3880
+ isCardsDetailsRendered: true,
3881
+ isCardsAdmin: action === null || action === void 0 ? void 0 : (_action$payload9 = action.payload) === null || _action$payload9 === void 0 ? void 0 : _action$payload9.requested_user_is_admin
3882
+ });
3883
+ }
3759
3884
  case SET_STATIC_FIELDS_VISIBILITY:
3760
3885
  {
3761
3886
  var _personalInfo = state.renderFields.personalInfo.map(function (input) {
3762
- var _action$payload8;
3763
- if (action !== null && action !== void 0 && action.payload && Object.hasOwnProperty.call(action.payload, input.name) && action !== null && action !== void 0 && (_action$payload8 = action.payload) !== null && _action$payload8 !== void 0 && _action$payload8[input.name]) {
3887
+ var _action$payload10;
3888
+ if (action !== null && action !== void 0 && action.payload && Object.hasOwnProperty.call(action.payload, input.name) && action !== null && action !== void 0 && (_action$payload10 = action.payload) !== null && _action$payload10 !== void 0 && _action$payload10[input.name]) {
3764
3889
  if (Object.hasOwnProperty.call(action.payload[input.name], 'readOnly')) {
3765
3890
  input.readOnly = action.payload[input.name].readOnly;
3766
3891
  }
@@ -4813,7 +4938,8 @@ var ErrorMessages = {
4813
4938
  passport_expiry_date: 'Please enter passport expiry date.',
4814
4939
  passport_photo: 'Please attach passport photo.',
4815
4940
  travel_docs: 'Please attach travel docs.',
4816
- products: 'Please select atleast one product access.'
4941
+ only_cards_products: 'Select at least one additional product if opting for cards.',
4942
+ none_products: 'Select at least one product. If opting for cards, please choose at least one additional product.'
4817
4943
  };
4818
4944
 
4819
4945
  function AddPanelDialog(_ref) {
@@ -4863,7 +4989,56 @@ function AddPanelDialog(_ref) {
4863
4989
  })));
4864
4990
  }
4865
4991
 
4866
- var IUIToastMessageService$4 = services.IUIToastMessageService;
4992
+ var CardsField = function CardsField(props) {
4993
+ var cardsConstants = props.cardsConstants,
4994
+ _props$onRoleChange = props.onRoleChange,
4995
+ onRoleChange = _props$onRoleChange === void 0 ? function () {} : _props$onRoleChange,
4996
+ _props$roleValue = props.roleValue,
4997
+ roleValue = _props$roleValue === void 0 ? '' : _props$roleValue,
4998
+ _props$isProfile = props.isProfile,
4999
+ isProfile = _props$isProfile === void 0 ? false : _props$isProfile,
5000
+ _props$roles = props.roles,
5001
+ roles = _props$roles === void 0 ? [] : _props$roles;
5002
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IUIGrid, {
5003
+ container: true,
5004
+ className: (styles.headingPadding)
5005
+ }, /*#__PURE__*/React.createElement(IUITypography, {
5006
+ variant: "h3",
5007
+ className: clsx(styles.heading, styles.headingMedium)
5008
+ }, cardsConstants.heading)), /*#__PURE__*/React.createElement(IUIDivider, {
5009
+ className: styles.dividerColor
5010
+ }), /*#__PURE__*/React.createElement(IUIGrid, {
5011
+ container: true,
5012
+ className: clsx(styles.product_info, styles.sectionWrapper)
5013
+ }, /*#__PURE__*/React.createElement(IUIGrid, {
5014
+ item: true,
5015
+ sm: 12,
5016
+ md: 4
5017
+ }, /*#__PURE__*/React.createElement(IUILabel, {
5018
+ label: cardsConstants.roleHeading,
5019
+ headerType: true,
5020
+ description: cardsConstants.roleDescription
5021
+ })), /*#__PURE__*/React.createElement(IUIGrid, {
5022
+ item: true,
5023
+ sm: 12,
5024
+ md: 8,
5025
+ lg: 8,
5026
+ xl: 6
5027
+ }, /*#__PURE__*/React.createElement(IUIGrid, {
5028
+ container: true,
5029
+ className: styles.formFieldsWrapper
5030
+ }, isProfile ? /*#__PURE__*/React.createElement(UserRole, {
5031
+ list: roles,
5032
+ value: roleValue
5033
+ }) : /*#__PURE__*/React.createElement(IUIRadio, {
5034
+ list: roles,
5035
+ value: roleValue,
5036
+ onValueChange: onRoleChange
5037
+ })))));
5038
+ };
5039
+
5040
+ var IUIToastMessageService$4 = services.IUIToastMessageService,
5041
+ IUILocalStorageService$5 = services.IUILocalStorageService;
4867
5042
  var env$4 = configs.env;
4868
5043
  var UserAddEdit = function UserAddEdit(props) {
4869
5044
  var isEditMode = props.isEditMode,
@@ -4871,6 +5046,8 @@ var UserAddEdit = function UserAddEdit(props) {
4871
5046
  config = props.config,
4872
5047
  _props$isProfile = props.isProfile,
4873
5048
  isProfile = _props$isProfile === void 0 ? false : _props$isProfile;
5049
+ console.log("isProfile", isProfile);
5050
+ console.log("isEditMode", isEditMode);
4874
5051
  env$4.init(config, isProfile);
4875
5052
  var queryParams = new URLSearchParams(window.location.search);
4876
5053
  var verifyUserId = Number(queryParams.get(config.routes.users.add.queryParamKeys.verifyUserId));
@@ -4890,7 +5067,12 @@ var UserAddEdit = function UserAddEdit(props) {
4890
5067
  isRendered = _useSelector.isRendered,
4891
5068
  maxTravelApprovers = _useSelector.maxTravelApprovers,
4892
5069
  maxExpenseApprovers = _useSelector.maxExpenseApprovers,
4893
- maxMembershipInput = _useSelector.maxMembershipInput;
5070
+ maxMembershipInput = _useSelector.maxMembershipInput,
5071
+ isCardsDetailsRendered = _useSelector.isCardsDetailsRendered,
5072
+ isCardsAdmin = _useSelector.isCardsAdmin,
5073
+ cardsDetails = _useSelector.cardsDetails;
5074
+ console.log("isCardsAdmin", isCardsAdmin);
5075
+ console.log("cardsDetails", cardsDetails);
4894
5076
  var _useSelector2 = useSelector(function (state) {
4895
5077
  return state.common;
4896
5078
  }),
@@ -4899,11 +5081,13 @@ var UserAddEdit = function UserAddEdit(props) {
4899
5081
  hasVerificationError = _useSelector2.hasVerificationError,
4900
5082
  isILadmin = _useSelector2.isILadmin,
4901
5083
  companyName = _useSelector2.companyName;
5084
+ console.log("id", id);
4902
5085
  var history = useHistory();
4903
5086
  var location = useLocation();
4904
5087
  var _useState = useState({
4905
5088
  travel: false,
4906
- expense: false
5089
+ expense: false,
5090
+ cards: false
4907
5091
  }),
4908
5092
  productAccess = _useState[0],
4909
5093
  setProductAccess = _useState[1];
@@ -4914,13 +5098,13 @@ var UserAddEdit = function UserAddEdit(props) {
4914
5098
  errorMsgs.products = '';
4915
5099
  var _productAccess = _extends({}, productAccess);
4916
5100
  _productAccess[value] = !_productAccess[value];
4917
- if (_productAccess.travel === false && _productAccess.expense === false) {
5101
+ if (_productAccess.travel === false && _productAccess.expense === false && _productAccess.cards === true) {
4918
5102
  var _errorArray = [].concat(errorArray);
4919
5103
  var _errorMsgs = _extends({}, errorMsgs);
4920
5104
  if (_errorArray.indexOf('products') === -1) {
4921
5105
  _errorArray.push('products');
4922
5106
  }
4923
- _errorMsgs.products = ErrorMessages.products;
5107
+ _errorMsgs.products = ErrorMessages.only_cards_products;
4924
5108
  setErrorArray(_errorArray);
4925
5109
  setErrorMsgs(_errorMsgs);
4926
5110
  var el = document.getElementById('products');
@@ -4930,13 +5114,192 @@ var UserAddEdit = function UserAddEdit(props) {
4930
5114
  block: 'center'
4931
5115
  });
4932
5116
  }
5117
+ } else if (_productAccess.travel === false && _productAccess.expense === false && _productAccess.cards === false) {
5118
+ var _errorArray2 = [].concat(errorArray);
5119
+ var _errorMsgs2 = _extends({}, errorMsgs);
5120
+ if (_errorArray2.indexOf('products') === -1) {
5121
+ _errorArray2.push('products');
5122
+ }
5123
+ _errorMsgs2.products = ErrorMessages.none_products;
5124
+ setErrorArray(_errorArray2);
5125
+ setErrorMsgs(_errorMsgs2);
5126
+ var _el = document.getElementById('products');
5127
+ if (_el) {
5128
+ _el.scrollIntoView({
5129
+ behavior: 'smooth',
5130
+ block: 'center'
5131
+ });
5132
+ }
4933
5133
  } else {
4934
5134
  setErrorArray(errorArray);
4935
5135
  setErrorMsgs(errorMsgs);
4936
5136
  }
4937
5137
  setProductAccess(_productAccess);
4938
5138
  };
4939
- var _useState2 = useState({
5139
+ var _useState2 = useState(''),
5140
+ newCountryCode = _useState2[0],
5141
+ setNewCountryCode = _useState2[1];
5142
+ var _useState3 = useState(),
5143
+ countryDialCode = _useState3[0],
5144
+ setCountryDialCode = _useState3[1];
5145
+ var _useState4 = useState([]),
5146
+ countryContactCode = _useState4[0],
5147
+ setCountryContactCode = _useState4[1];
5148
+ var updateUserApiCall = function updateUserApiCall(payload, inputChangeLog) {
5149
+ dispatch(updateUser(payload, isProfile ? id : editUserId, inputChangeLog)).then(function (res) {
5150
+ if (isProfile) {
5151
+ var _config$routes, _config$routes$profil, _config$routes$profil2;
5152
+ (config === null || config === void 0 ? void 0 : (_config$routes = config.routes) === null || _config$routes === void 0 ? void 0 : (_config$routes$profil = _config$routes.profile) === null || _config$routes$profil === void 0 ? void 0 : (_config$routes$profil2 = _config$routes$profil.redirectUrl) === null || _config$routes$profil2 === void 0 ? void 0 : _config$routes$profil2.submit) && history.push(config.routes.profile.redirectUrl.submit);
5153
+ } else {
5154
+ var _config$routes2, _config$routes2$users, _config$routes2$users2;
5155
+ (config === null || config === void 0 ? void 0 : (_config$routes2 = config.routes) === null || _config$routes2 === void 0 ? void 0 : (_config$routes2$users = _config$routes2.users) === null || _config$routes2$users === void 0 ? void 0 : (_config$routes2$users2 = _config$routes2$users.list) === null || _config$routes2$users2 === void 0 ? void 0 : _config$routes2$users2.path) && history.push(config.routes.users.list.path);
5156
+ }
5157
+ setFilesForDelete([]);
5158
+ setProfilePicDelete([]);
5159
+ })["catch"](function (err) {
5160
+ if (typeof err === 'object') {
5161
+ if (err.country_code) {
5162
+ err.contact_number = err.country_code;
5163
+ }
5164
+ if (err.contact_country_code) {
5165
+ err.contact_number = err.contact_country_code;
5166
+ }
5167
+ if (err.passport) {
5168
+ err.passport_photo = _extends({}, err.passport);
5169
+ delete err.passport;
5170
+ }
5171
+ setErrorArray(Object.keys(err));
5172
+ setErrorMsgs(err);
5173
+ var _loop = function _loop() {
5174
+ if (Object.hasOwnProperty.call(err, key)) {
5175
+ if (err[key]) {
5176
+ if (key in passportInfoInput || key in travelPreferenceInfo || key in secureTravelInputInfo) {
5177
+ setAdditionalInfoFlag('open');
5178
+ }
5179
+ var el = document.getElementById(key === 'country_code' || key === 'contact_country_code' ? 'contact_number' : key);
5180
+ if (el) {
5181
+ setTimeout(function () {
5182
+ el.scrollIntoView({
5183
+ behavior: 'smooth',
5184
+ block: 'center'
5185
+ });
5186
+ }, 500);
5187
+ return 1;
5188
+ }
5189
+ }
5190
+ }
5191
+ };
5192
+ for (var key in err) {
5193
+ if (_loop()) break;
5194
+ }
5195
+ } else if (typeof err === 'string') {
5196
+ IUIToastMessageService$4.warningNotify(err);
5197
+ } else {
5198
+ IUIToastMessageService$4.warningNotify('Opps, Something went wrong.');
5199
+ }
5200
+ })["finally"](function () {
5201
+ dispatch(stopLoader());
5202
+ });
5203
+ };
5204
+ var createUserApiCall = function createUserApiCall(payload) {
5205
+ dispatch(createUser(payload)).then(function (res) {
5206
+ var _config$routes3, _config$routes3$users, _config$routes3$users2;
5207
+ if (config !== null && config !== void 0 && (_config$routes3 = config.routes) !== null && _config$routes3 !== void 0 && (_config$routes3$users = _config$routes3.users) !== null && _config$routes3$users !== void 0 && (_config$routes3$users2 = _config$routes3$users.list) !== null && _config$routes3$users2 !== void 0 && _config$routes3$users2.path) {
5208
+ history.push({
5209
+ pathname: config.routes.users.list.path
5210
+ });
5211
+ }
5212
+ })["catch"](function (err) {
5213
+ if (typeof err === 'object') {
5214
+ if (err.country_code) {
5215
+ err.contact_number = err.country_code;
5216
+ }
5217
+ if (err.contact_country_code) {
5218
+ err.contact_number = err.contact_country_code;
5219
+ }
5220
+ if (err.passport) {
5221
+ err.passport_photo = _extends({}, err.passport);
5222
+ delete err.passport;
5223
+ }
5224
+ setErrorArray(Object.keys(err));
5225
+ setErrorMsgs(err);
5226
+ var _loop2 = function _loop2() {
5227
+ if (Object.hasOwnProperty.call(err, key)) {
5228
+ if (err[key]) {
5229
+ if (key in passportInfoInput || key in travelPreferenceInfo || key in secureTravelInputInfo) {
5230
+ setAdditionalInfoFlag('open');
5231
+ }
5232
+ var el = document.getElementById(key === 'country_code' || key === 'contact_country_code' ? 'contact_number' : key);
5233
+ if (el) {
5234
+ setTimeout(function () {
5235
+ el.scrollIntoView({
5236
+ behavior: 'smooth',
5237
+ block: 'center'
5238
+ });
5239
+ }, 500);
5240
+ return 1;
5241
+ }
5242
+ }
5243
+ }
5244
+ };
5245
+ for (var key in err) {
5246
+ if (_loop2()) break;
5247
+ }
5248
+ } else if (typeof err === 'string') {
5249
+ IUIToastMessageService$4.warningNotify(err);
5250
+ } else {
5251
+ IUIToastMessageService$4.warningNotify('Opps, Something went wrong.');
5252
+ }
5253
+ })["finally"](function () {
5254
+ dispatch(stopLoader());
5255
+ });
5256
+ };
5257
+ var fetchEditUserCardsDetails = function fetchEditUserCardsDetails(editUserId) {
5258
+ fetch(userAddEditUrl.cardsEditUserDetails(editUserId), {
5259
+ method: 'GET',
5260
+ headers: {
5261
+ 'Content-Type': 'application/json',
5262
+ 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
5263
+ }
5264
+ }).then(function (response) {
5265
+ return response.json();
5266
+ }).then(function (res) {
5267
+ dispatch(setCardsDetails(res));
5268
+ })["catch"](function (error) {
5269
+ console.log("errorrr", error);
5270
+ });
5271
+ };
5272
+ var fetchLoggedUserCardsDetails = function fetchLoggedUserCardsDetails() {
5273
+ fetch(userAddEditUrl.cardsAddUsersDetails(), {
5274
+ method: 'GET',
5275
+ headers: {
5276
+ 'Content-Type': 'application/json',
5277
+ 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
5278
+ }
5279
+ }).then(function (response) {
5280
+ return response.json();
5281
+ }).then(function (res) {
5282
+ dispatch(setCardsDetails(res));
5283
+ })["catch"](function (error) {
5284
+ console.log("errorrr", error);
5285
+ });
5286
+ };
5287
+ useEffect(function () {
5288
+ var countryObject = countryContactCode.find(function (t) {
5289
+ return t.dial_code === countryDialCode;
5290
+ });
5291
+ if (countryObject) {
5292
+ setPersonalInfoInput(_extends({}, personalInfoInput, {
5293
+ country_code: countryObject.code
5294
+ }));
5295
+ }
5296
+ }, [countryDialCode]);
5297
+ useEffect(function () {
5298
+ var extractedNumber = newCountryCode.substring(1);
5299
+ var convertedNumber = parseInt(extractedNumber);
5300
+ setCountryDialCode(convertedNumber);
5301
+ }, [newCountryCode]);
5302
+ var _useState5 = useState({
4940
5303
  first_name: '',
4941
5304
  last_name: '',
4942
5305
  email: '',
@@ -4947,9 +5310,9 @@ var UserAddEdit = function UserAddEdit(props) {
4947
5310
  contact_country_code: '',
4948
5311
  profile_pic: []
4949
5312
  }),
4950
- personalInfoInput = _useState2[0],
4951
- setPersonalInfoInput = _useState2[1];
4952
- var _useState3 = useState({
5313
+ personalInfoInput = _useState5[0],
5314
+ setPersonalInfoInput = _useState5[1];
5315
+ var _useState6 = useState({
4953
5316
  emp_level: {
4954
5317
  value: '',
4955
5318
  label: 'Select employee level'
@@ -4982,9 +5345,9 @@ var UserAddEdit = function UserAddEdit(props) {
4982
5345
  label: defaultCurrency
4983
5346
  }
4984
5347
  }),
4985
- employeeInfoInput = _useState3[0],
4986
- setEmployeeInfoInput = _useState3[1];
4987
- var _useState4 = useState({
5348
+ employeeInfoInput = _useState6[0],
5349
+ setEmployeeInfoInput = _useState6[1];
5350
+ var _useState7 = useState({
4988
5351
  emp_level: 0,
4989
5352
  entity: 0,
4990
5353
  business_unit: 0,
@@ -4993,48 +5356,48 @@ var UserAddEdit = function UserAddEdit(props) {
4993
5356
  manager_id: 0,
4994
5357
  skip_manager_id: 0
4995
5358
  }),
4996
- cacheForAsyncDropdown = _useState4[0],
4997
- clearCacheForAsyncDropdown = _useState4[1];
4998
- var _useState5 = useState({}),
4999
- userTagType = _useState5[0],
5000
- setUserTagType = _useState5[1];
5001
- var _useState6 = useState(false),
5002
- scroll = _useState6[0],
5003
- setScroll = _useState6[1];
5004
- var _useState7 = useState({}),
5005
- customFieldsInput = _useState7[0],
5006
- setCustomFieldsInput = _useState7[1];
5007
- var _useState8 = useState('traveler'),
5008
- travelRole = _useState8[0],
5009
- setTravelRole = _useState8[1];
5010
- var _useState9 = useState({}),
5011
- travelApproversInput = _useState9[0],
5012
- setTravelApproversInput = _useState9[1];
5013
- var _useState10 = useState({
5359
+ cacheForAsyncDropdown = _useState7[0],
5360
+ clearCacheForAsyncDropdown = _useState7[1];
5361
+ var _useState8 = useState({}),
5362
+ userTagType = _useState8[0],
5363
+ setUserTagType = _useState8[1];
5364
+ var _useState9 = useState(false),
5365
+ scroll = _useState9[0],
5366
+ setScroll = _useState9[1];
5367
+ var _useState10 = useState({}),
5368
+ customFieldsInput = _useState10[0],
5369
+ setCustomFieldsInput = _useState10[1];
5370
+ var _useState11 = useState('traveler'),
5371
+ travelRole = _useState11[0],
5372
+ setTravelRole = _useState11[1];
5373
+ var _useState12 = useState({}),
5374
+ travelApproversInput = _useState12[0],
5375
+ setTravelApproversInput = _useState12[1];
5376
+ var _useState13 = useState({
5014
5377
  value: '',
5015
5378
  label: 'Select approver'
5016
5379
  }),
5017
- travelFYI = _useState10[0],
5018
- setTravelFYI = _useState10[1];
5019
- var _useState11 = useState([]),
5020
- membershipInfoInput = _useState11[0],
5021
- setMembershipInfoInput = _useState11[1];
5022
- var _useState12 = useState([]),
5023
- removedMembershipInfoInput = _useState12[0],
5024
- setRemovedMembershipInfoInput = _useState12[1];
5025
- var _useState13 = useState({
5380
+ travelFYI = _useState13[0],
5381
+ setTravelFYI = _useState13[1];
5382
+ var _useState14 = useState([]),
5383
+ membershipInfoInput = _useState14[0],
5384
+ setMembershipInfoInput = _useState14[1];
5385
+ var _useState15 = useState([]),
5386
+ removedMembershipInfoInput = _useState15[0],
5387
+ setRemovedMembershipInfoInput = _useState15[1];
5388
+ var _useState16 = useState({
5026
5389
  flight_seat_preference: '',
5027
5390
  meal_preference: ''
5028
5391
  }),
5029
- travelPreferenceInfo = _useState13[0],
5030
- settravelPreferenceInfo = _useState13[1];
5031
- var _useState14 = useState({
5392
+ travelPreferenceInfo = _useState16[0],
5393
+ settravelPreferenceInfo = _useState16[1];
5394
+ var _useState17 = useState({
5032
5395
  trusted_traveller: '',
5033
5396
  redress_number: ''
5034
5397
  }),
5035
- secureTravelInputInfo = _useState14[0],
5036
- setSecureTravelInputInfo = _useState14[1];
5037
- var _useState15 = useState({
5398
+ secureTravelInputInfo = _useState17[0],
5399
+ setSecureTravelInputInfo = _useState17[1];
5400
+ var _useState18 = useState({
5038
5401
  passport_issue_country: {
5039
5402
  value: '',
5040
5403
  label: 'Select country'
@@ -5049,39 +5412,94 @@ var UserAddEdit = function UserAddEdit(props) {
5049
5412
  passport_photo: [],
5050
5413
  travel_docs: []
5051
5414
  }),
5052
- passportInfoInput = _useState15[0],
5053
- setPassportInfoInput = _useState15[1];
5054
- var _useState16 = useState([]),
5055
- filesForDelete = _useState16[0],
5056
- setFilesForDelete = _useState16[1];
5057
- var _useState17 = useState([]),
5058
- profilePicDelete = _useState17[0],
5059
- setProfilePicDelete = _useState17[1];
5060
- var _useState18 = useState(config.env.isTravelProduct && isProfile ? 'open' : ''),
5061
- isAdditionalInfoExpanded = _useState18[0],
5062
- setAdditionalInfoFlag = _useState18[1];
5063
- var _useState19 = useState('submitter'),
5064
- expenseRole = _useState19[0],
5065
- setExpenseRole = _useState19[1];
5066
- var _useState20 = useState({}),
5067
- expenseApproversInput = _useState20[0],
5068
- setExpenseApproversInput = _useState20[1];
5069
- var _useState21 = useState({
5415
+ passportInfoInput = _useState18[0],
5416
+ setPassportInfoInput = _useState18[1];
5417
+ var _useState19 = useState([]),
5418
+ filesForDelete = _useState19[0],
5419
+ setFilesForDelete = _useState19[1];
5420
+ var _useState20 = useState([]),
5421
+ profilePicDelete = _useState20[0],
5422
+ setProfilePicDelete = _useState20[1];
5423
+ var _useState21 = useState(config.env.isTravelProduct && isProfile ? 'open' : ''),
5424
+ isAdditionalInfoExpanded = _useState21[0],
5425
+ setAdditionalInfoFlag = _useState21[1];
5426
+ var _useState22 = useState('submitter'),
5427
+ expenseRole = _useState22[0],
5428
+ setExpenseRole = _useState22[1];
5429
+ var _useState23 = useState({}),
5430
+ expenseApproversInput = _useState23[0],
5431
+ setExpenseApproversInput = _useState23[1];
5432
+ var _useState24 = useState({
5070
5433
  value: '',
5071
5434
  label: 'Select approver'
5072
5435
  }),
5073
- expenseFYI = _useState21[0],
5074
- setExpenseFYI = _useState21[1];
5436
+ expenseFYI = _useState24[0],
5437
+ setExpenseFYI = _useState24[1];
5438
+ var _useState25 = useState(''),
5439
+ cardsRole = _useState25[0],
5440
+ setCardsRole = _useState25[1];
5441
+ var _useState26 = useState(false),
5442
+ cardsErrorMsg = _useState26[0],
5443
+ setCardsErrorMsg = _useState26[1];
5444
+ console.log("cardsRole123", cardsRole);
5445
+ console.log("cardsErrorMsg", cardsErrorMsg);
5446
+ useEffect(function () {
5447
+ if (isCardsAdmin === false && cardsRole.includes("card_admin")) {
5448
+ setCardsErrorMsg(true);
5449
+ IUIToastMessageService$4.warningNotify("You are not authorized person to make someone admin");
5450
+ } else {
5451
+ setCardsErrorMsg(false);
5452
+ }
5453
+ }, [cardsRole]);
5454
+ useEffect(function () {
5455
+ if (productAccess.cards === false) {
5456
+ setCardsRole('');
5457
+ } else {
5458
+ for (var _iterator = _createForOfIteratorHelperLoose(cardsDetails.cardsRoles), _step; !(_step = _iterator()).done;) {
5459
+ var role = _step.value;
5460
+ var splitRoleval = role.value.split(":");
5461
+ var defaultRole = splitRoleval[2];
5462
+ if (defaultRole === 'card_holder') {
5463
+ setCardsRole(role.value);
5464
+ break;
5465
+ }
5466
+ }
5467
+ }
5468
+ }, [productAccess.cards]);
5469
+ useEffect(function () {
5470
+ if (isCardsDetailsRendered) {
5471
+ var selectedRole = null;
5472
+ for (var _iterator2 = _createForOfIteratorHelperLoose(cardsDetails.cardsRoles), _step2; !(_step2 = _iterator2()).done;) {
5473
+ var _role = _step2.value;
5474
+ if (_role.isAssigned) {
5475
+ setCardsRole(_role.value);
5476
+ selectedRole = _role.value;
5477
+ break;
5478
+ }
5479
+ }
5480
+ if (selectedRole === null) {
5481
+ for (var _iterator3 = _createForOfIteratorHelperLoose(cardsDetails.cardsRoles), _step3; !(_step3 = _iterator3()).done;) {
5482
+ var role = _step3.value;
5483
+ var splitRoleval = role.value.split(":");
5484
+ var defaultRole = splitRoleval[2];
5485
+ if (defaultRole === 'card_holder') {
5486
+ setCardsRole(role.value);
5487
+ break;
5488
+ }
5489
+ }
5490
+ }
5491
+ }
5492
+ }, [isCardsDetailsRendered, cardsDetails]);
5075
5493
  var asyncSelectRefs = useRef({
5076
5494
  emp_level: useRef(null),
5077
5495
  entity: useRef(null),
5078
5496
  business_unit: useRef(null),
5079
5497
  department: useRef(null)
5080
5498
  });
5081
- var _useState22 = useState([]),
5082
- errorArray = _useState22[0],
5083
- setErrorArray = _useState22[1];
5084
- var _useState23 = useState({
5499
+ var _useState27 = useState([]),
5500
+ errorArray = _useState27[0],
5501
+ setErrorArray = _useState27[1];
5502
+ var _useState28 = useState({
5085
5503
  first_name: '',
5086
5504
  last_name: '',
5087
5505
  email: '',
@@ -5111,9 +5529,9 @@ var UserAddEdit = function UserAddEdit(props) {
5111
5529
  userTagType: '',
5112
5530
  profile_pic: ''
5113
5531
  }),
5114
- errorMsgs = _useState23[0],
5115
- setErrorMsgs = _useState23[1];
5116
- var _useState24 = useState({
5532
+ errorMsgs = _useState28[0],
5533
+ setErrorMsgs = _useState28[1];
5534
+ var _useState29 = useState({
5117
5535
  first_name: false,
5118
5536
  last_name: false,
5119
5537
  email: false,
@@ -5140,14 +5558,14 @@ var UserAddEdit = function UserAddEdit(props) {
5140
5558
  userTagType: false,
5141
5559
  profile_pic: false
5142
5560
  }),
5143
- inputChangeLog = _useState24[0],
5144
- updateInputChangeLog = _useState24[1];
5145
- var _useState25 = useState([]),
5146
- uploadedFiles = _useState25[0],
5147
- setUploadedFiles = _useState25[1];
5148
- var _useState26 = useState(70),
5149
- maxLengthForModal = _useState26[0],
5150
- setMaxLengthForModal = _useState26[1];
5561
+ inputChangeLog = _useState29[0],
5562
+ updateInputChangeLog = _useState29[1];
5563
+ var _useState30 = useState([]),
5564
+ uploadedFiles = _useState30[0],
5565
+ setUploadedFiles = _useState30[1];
5566
+ var _useState31 = useState(70),
5567
+ maxLengthForModal = _useState31[0],
5568
+ setMaxLengthForModal = _useState31[1];
5151
5569
  var defaultAddModalData = {
5152
5570
  isOpen: false,
5153
5571
  isError: false,
@@ -5163,9 +5581,9 @@ var UserAddEdit = function UserAddEdit(props) {
5163
5581
  maxLength: maxLengthForModal,
5164
5582
  minLength: 0
5165
5583
  };
5166
- var _useState27 = useState(defaultAddModalData),
5167
- addModalData = _useState27[0],
5168
- setAddModalData = _useState27[1];
5584
+ var _useState32 = useState(defaultAddModalData),
5585
+ addModalData = _useState32[0],
5586
+ setAddModalData = _useState32[1];
5169
5587
  var onAddModalClose = function onAddModalClose() {
5170
5588
  setAddModalData(_extends({}, defaultAddModalData));
5171
5589
  };
@@ -5342,7 +5760,6 @@ var UserAddEdit = function UserAddEdit(props) {
5342
5760
  _value = args._value,
5343
5761
  _isError = args._isError,
5344
5762
  _errorMsg = args._errorMsg;
5345
- console.log(_name, _value);
5346
5763
  setEmployeeInfoInput(_extends({}, employeeInfoInput, (_extends8 = {}, _extends8[_name] = _value, _extends8)));
5347
5764
  updateError(_name, _isError, _errorMsg);
5348
5765
  if (Object.hasOwnProperty.call(inputChangeLog, _name)) {
@@ -5376,7 +5793,6 @@ var UserAddEdit = function UserAddEdit(props) {
5376
5793
  var _extends12;
5377
5794
  var _name = _ref3._name,
5378
5795
  _value = _ref3._value;
5379
- console.log(_name, _value, 'travel');
5380
5796
  setTravelApproversInput(_extends({}, travelApproversInput, (_extends12 = {}, _extends12[_name] = _value, _extends12)));
5381
5797
  };
5382
5798
  var onExpenseApproversInputChange = function onExpenseApproversInputChange(_ref4) {
@@ -5574,6 +5990,7 @@ var UserAddEdit = function UserAddEdit(props) {
5574
5990
  useEffect(function () {
5575
5991
  if (isTokenVerified === true) {
5576
5992
  dispatch(fetchRenderFileds());
5993
+ editUserId ? fetchEditUserCardsDetails(editUserId) : fetchLoggedUserCardsDetails();
5577
5994
  }
5578
5995
  }, [isTokenVerified]);
5579
5996
  useEffect(function () {
@@ -5588,6 +6005,7 @@ var UserAddEdit = function UserAddEdit(props) {
5588
6005
  }
5589
6006
  }));
5590
6007
  dispatch(fetchCountryCodes()).then(function (_res) {
6008
+ setCountryContactCode(_res);
5591
6009
  if (isEditMode) {
5592
6010
  if (!isProfile && !editUserId) return false;
5593
6011
  dispatch(setStaticFieldsVisibility({
@@ -5698,7 +6116,8 @@ var UserAddEdit = function UserAddEdit(props) {
5698
6116
  var products = res.user_product.split('+');
5699
6117
  setProductAccess({
5700
6118
  travel: products.includes('travel'),
5701
- expense: products.includes('expense')
6119
+ expense: products.includes('expense'),
6120
+ cards: products.includes('cards')
5702
6121
  });
5703
6122
  if (products.includes('travel')) {
5704
6123
  var _res$travel_info, _res$travel_info2, _res$travel_info3, _res$travel_info4, _res$travel_info5, _res$travel_info6;
@@ -5909,13 +6328,15 @@ var UserAddEdit = function UserAddEdit(props) {
5909
6328
  IUIToastMessageService$4.warningNotify(checkAnyError);
5910
6329
  return Promise.resolve();
5911
6330
  }
5912
- console.log(employeeInfoInput, 'data');
5913
6331
  if (employeeInfoInput.manager_id.value !== '') {
5914
6332
  employeeInfoInput.manager_id = employeeInfoInput.manager.value;
5915
6333
  }
5916
6334
  if (employeeInfoInput.skip_manager_id.value !== '') {
5917
6335
  employeeInfoInput.skip_manager_id = employeeInfoInput.skip_manager.value;
5918
6336
  }
6337
+ var cardsPayload = {
6338
+ "roles": [cardsRole]
6339
+ };
5919
6340
  var payload = {
5920
6341
  personalInfoInput: personalInfoInput,
5921
6342
  employeeInfoInput: employeeInfoInput,
@@ -5934,7 +6355,9 @@ var UserAddEdit = function UserAddEdit(props) {
5934
6355
  uploadedFiles: uploadedFiles,
5935
6356
  filesForDelete: filesForDelete,
5936
6357
  profilePicDelete: profilePicDelete,
5937
- userTagType: userTagType
6358
+ userTagType: userTagType,
6359
+ cardsRole: cardsRole,
6360
+ isCardsAdmin: isCardsAdmin
5938
6361
  };
5939
6362
  if (verifyUserId) {
5940
6363
  payload.verifyUserId = verifyUserId;
@@ -5946,6 +6369,9 @@ var UserAddEdit = function UserAddEdit(props) {
5946
6369
  employeeInfo = optionalFields.employee_info,
5947
6370
  userTravelInfo = optionalFields.user_travel_info;
5948
6371
  var allMandatoryFields = ['first_name', 'last_name', 'email'];
6372
+ if (cardsErrorMsg) {
6373
+ _isError = true;
6374
+ }
5949
6375
  allMandatoryFields.forEach(function (key, index) {
5950
6376
  if (personalInfoInput[key] === '') {
5951
6377
  _isError = true;
@@ -5973,11 +6399,8 @@ var UserAddEdit = function UserAddEdit(props) {
5973
6399
  }
5974
6400
  }
5975
6401
  for (var _key in employeeInfo) {
5976
- console.log('key', _key);
5977
6402
  if (Object.hasOwnProperty.call(employeeInfo, _key)) {
5978
- var _employeeInfoInput$_k;
5979
- console.log('employeeInfo0000', (_employeeInfoInput$_k = employeeInfoInput[_key]) === null || _employeeInfoInput$_k === void 0 ? void 0 : _employeeInfoInput$_k.value, 'sajkdhjasj');
5980
- if (employeeInfo[_key] === false && employeeInfoInput[_key] !== undefined && (typeof employeeInfoInput[_key] === 'string' && !employeeInfoInput[_key] || typeof employeeInfoInput[_key] === 'object' && !employeeInfoInput[_key].value || !employeeInfoInput[_key].value) === '' && fieldsVisibility.employee_info[_key] !== 2) {
6403
+ if (employeeInfo[_key] === false && employeeInfoInput[_key] !== undefined && (typeof employeeInfoInput[_key] === 'string' && !employeeInfoInput[_key] || typeof employeeInfoInput[_key] === 'object' && !employeeInfoInput[_key].value) && fieldsVisibility.employee_info[_key] !== 2) {
5981
6404
  _isError = true;
5982
6405
  if (_errorArray.indexOf(_key) === -1) _errorArray.push(_key);
5983
6406
  _errorMsgs[_key] = ErrorMessages[_key];
@@ -6063,7 +6486,7 @@ var UserAddEdit = function UserAddEdit(props) {
6063
6486
  if (_isError) {
6064
6487
  setErrorArray(_errorArray);
6065
6488
  setErrorMsgs(_errorMsgs);
6066
- var _loop = function _loop() {
6489
+ var _loop3 = function _loop3() {
6067
6490
  if (Object.hasOwnProperty.call(_errorMsgs, _key3)) {
6068
6491
  if (_errorMsgs[_key3]) {
6069
6492
  if (_key3 in passportInfoInput || _key3 in travelPreferenceInfo || _key3 in secureTravelInputInfo) {
@@ -6083,115 +6506,57 @@ var UserAddEdit = function UserAddEdit(props) {
6083
6506
  }
6084
6507
  };
6085
6508
  for (var _key3 in _errorMsgs) {
6086
- if (_loop()) break;
6509
+ if (_loop3()) break;
6087
6510
  }
6088
6511
  }
6512
+ var cardApiflag = false;
6513
+ if (productAccess.cards === false) {
6514
+ cardApiflag = false;
6515
+ } else {
6516
+ cardApiflag = true;
6517
+ }
6089
6518
  if (!_isError) {
6090
6519
  if (isEditMode && editUserId || isProfile) {
6091
6520
  dispatch(showLoader());
6092
- dispatch(updateUser(payload, isProfile ? id : editUserId, inputChangeLog)).then(function (res) {
6093
- if (isProfile) {
6094
- var _config$routes, _config$routes$profil, _config$routes$profil2;
6095
- (config === null || config === void 0 ? void 0 : (_config$routes = config.routes) === null || _config$routes === void 0 ? void 0 : (_config$routes$profil = _config$routes.profile) === null || _config$routes$profil === void 0 ? void 0 : (_config$routes$profil2 = _config$routes$profil.redirectUrl) === null || _config$routes$profil2 === void 0 ? void 0 : _config$routes$profil2.submit) && history.push(config.routes.profile.redirectUrl.submit);
6096
- } else {
6097
- var _config$routes2, _config$routes2$users, _config$routes2$users2;
6098
- (config === null || config === void 0 ? void 0 : (_config$routes2 = config.routes) === null || _config$routes2 === void 0 ? void 0 : (_config$routes2$users = _config$routes2.users) === null || _config$routes2$users === void 0 ? void 0 : (_config$routes2$users2 = _config$routes2$users.list) === null || _config$routes2$users2 === void 0 ? void 0 : _config$routes2$users2.path) && history.push(config.routes.users.list.path);
6099
- }
6100
- setFilesForDelete([]);
6101
- setProfilePicDelete([]);
6102
- })["catch"](function (err) {
6103
- if (typeof err === 'object') {
6104
- if (err.country_code) {
6105
- err.contact_number = err.country_code;
6106
- }
6107
- if (err.contact_country_code) {
6108
- err.contact_number = err.contact_country_code;
6109
- }
6110
- if (err.passport) {
6111
- err.passport_photo = _extends({}, err.passport);
6112
- delete err.passport;
6521
+ if (cardApiflag) {
6522
+ fetch(userAddEditUrl.cardsEditUserDetails(editUserId), {
6523
+ method: 'POST',
6524
+ body: JSON.stringify(cardsPayload),
6525
+ headers: {
6526
+ 'Content-Type': 'application/json',
6527
+ 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
6113
6528
  }
6114
- setErrorArray(Object.keys(err));
6115
- setErrorMsgs(err);
6116
- var _loop2 = function _loop2() {
6117
- if (Object.hasOwnProperty.call(err, _key4)) {
6118
- if (err[_key4]) {
6119
- if (_key4 in passportInfoInput || _key4 in travelPreferenceInfo || _key4 in secureTravelInputInfo) {
6120
- setAdditionalInfoFlag('open');
6121
- }
6122
- var el = document.getElementById(_key4 === 'country_code' || _key4 === 'contact_country_code' ? 'contact_number' : _key4);
6123
- if (el) {
6124
- setTimeout(function () {
6125
- el.scrollIntoView({
6126
- behavior: 'smooth',
6127
- block: 'center'
6128
- });
6129
- }, 500);
6130
- return 1;
6131
- }
6132
- }
6133
- }
6134
- };
6135
- for (var _key4 in err) {
6136
- if (_loop2()) break;
6137
- }
6138
- } else if (typeof err === 'string') {
6139
- IUIToastMessageService$4.warningNotify(err);
6140
- } else {
6141
- IUIToastMessageService$4.warningNotify('Opps, Something went wrong.');
6142
- }
6143
- })["finally"](function () {
6144
- dispatch(stopLoader());
6145
- });
6529
+ }).then(function (response) {
6530
+ return response.json();
6531
+ }).then(function (res) {
6532
+ updateUserApiCall(payload, inputChangeLog);
6533
+ })["catch"](function (error) {
6534
+ console.log("errorrr", error);
6535
+ });
6536
+ } else {
6537
+ updateUserApiCall(payload, inputChangeLog);
6538
+ }
6146
6539
  } else {
6147
6540
  dispatch(showLoader());
6148
- dispatch(createUser(payload)).then(function (res) {
6149
- var _config$routes3, _config$routes3$users, _config$routes3$users2;
6150
- (config === null || config === void 0 ? void 0 : (_config$routes3 = config.routes) === null || _config$routes3 === void 0 ? void 0 : (_config$routes3$users = _config$routes3.users) === null || _config$routes3$users === void 0 ? void 0 : (_config$routes3$users2 = _config$routes3$users.list) === null || _config$routes3$users2 === void 0 ? void 0 : _config$routes3$users2.path) && history.push(config.routes.users.list.path);
6151
- })["catch"](function (err) {
6152
- if (typeof err === 'object') {
6153
- if (err.country_code) {
6154
- err.contact_number = err.country_code;
6155
- }
6156
- if (err.contact_country_code) {
6157
- err.contact_number = err.contact_country_code;
6158
- }
6159
- if (err.passport) {
6160
- err.passport_photo = _extends({}, err.passport);
6161
- delete err.passport;
6162
- }
6163
- setErrorArray(Object.keys(err));
6164
- setErrorMsgs(err);
6165
- var _loop3 = function _loop3() {
6166
- if (Object.hasOwnProperty.call(err, _key5)) {
6167
- if (err[_key5]) {
6168
- if (_key5 in passportInfoInput || _key5 in travelPreferenceInfo || _key5 in secureTravelInputInfo) {
6169
- setAdditionalInfoFlag('open');
6170
- }
6171
- var el = document.getElementById(_key5 === 'country_code' || _key5 === 'contact_country_code' ? 'contact_number' : _key5);
6172
- if (el) {
6173
- setTimeout(function () {
6174
- el.scrollIntoView({
6175
- behavior: 'smooth',
6176
- block: 'center'
6177
- });
6178
- }, 500);
6179
- return 1;
6180
- }
6181
- }
6182
- }
6183
- };
6184
- for (var _key5 in err) {
6185
- if (_loop3()) break;
6541
+ dispatch(showLoader());
6542
+ if (cardApiflag === true) {
6543
+ fetch(userAddEditUrl.cardsEditUserDetails(isEditMode ? editUserId : id), {
6544
+ method: 'POST',
6545
+ body: JSON.stringify(cardsPayload),
6546
+ headers: {
6547
+ 'Content-Type': 'application/json',
6548
+ 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
6186
6549
  }
6187
- } else if (typeof err === 'string') {
6188
- IUIToastMessageService$4.warningNotify(err);
6189
- } else {
6190
- IUIToastMessageService$4.warningNotify('Opps, Something went wrong.');
6191
- }
6192
- })["finally"](function () {
6193
- dispatch(stopLoader());
6194
- });
6550
+ }).then(function (response) {
6551
+ return response.json();
6552
+ }).then(function (res) {
6553
+ createUserApiCall(payload);
6554
+ })["catch"](function (error) {
6555
+ console.log("errorrr", error);
6556
+ });
6557
+ } else {
6558
+ createUserApiCall(payload);
6559
+ }
6195
6560
  }
6196
6561
  }
6197
6562
  return Promise.resolve();
@@ -6230,17 +6595,13 @@ var UserAddEdit = function UserAddEdit(props) {
6230
6595
  if (verifyUserId) {
6231
6596
  dispatch(showLoader());
6232
6597
  dispatch(verifyUserInfo(verifyUserId)).then(function (res) {
6598
+ setNewCountryCode(res === null || res === void 0 ? void 0 : res.country_contact_code);
6233
6599
  setPersonalInfoInput(function (prevState) {
6234
6600
  return _extends({}, prevState, {
6235
- first_name: res.fname,
6236
- last_name: res.lname,
6601
+ first_name: res.first_name,
6602
+ last_name: res.last_name,
6237
6603
  email: res.email,
6238
- contact_number: res.phone,
6239
- dob: function () {
6240
- var dt = new Date(res.dob);
6241
- var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
6242
- return dt.getDate() + " " + months[dt.getMonth()] + " " + dt.getFullYear();
6243
- }(),
6604
+ contact_number: res === null || res === void 0 ? void 0 : res.contact_number,
6244
6605
  gender: function () {
6245
6606
  if (res.gender === 'male') return 'Male';else if (res.gender === 'female') return 'Female';else if (res.gender === 'others') return 'Others';else return '';
6246
6607
  }()
@@ -6513,7 +6874,7 @@ var UserAddEdit = function UserAddEdit(props) {
6513
6874
  md: 4
6514
6875
  }, /*#__PURE__*/React.createElement(IUILabel, {
6515
6876
  label: "Product access",
6516
- description: isProfile ? '' : 'Select at least one product',
6877
+ description: isProfile ? '' : 'Please select a product. Cards are available along with at least one additional product.',
6517
6878
  headerType: true,
6518
6879
  required: true
6519
6880
  })), /*#__PURE__*/React.createElement(IUIGrid, {
@@ -6619,6 +6980,19 @@ var UserAddEdit = function UserAddEdit(props) {
6619
6980
  isProfile: isProfile,
6620
6981
  editUserId: editUserId,
6621
6982
  roles: renderFields.expenseRoles
6983
+ }), /*#__PURE__*/React.createElement(IUIDivider, {
6984
+ className: styles.dividerColor
6985
+ }), isCardsDetailsRendered && productAccess && productAccess.cards && /*#__PURE__*/React.createElement(CardsField, {
6986
+ cardsConstants: cardsDetails.cardsConstants,
6987
+ type: "cards",
6988
+ isProfile: isProfile,
6989
+ onRoleChange: function onRoleChange(_ref7) {
6990
+ var _value = _ref7._value;
6991
+ return setCardsRole(_value);
6992
+ },
6993
+ roleValue: cardsRole,
6994
+ roles: cardsDetails.cardsRoles,
6995
+ cardsAdmin: isCardsAdmin
6622
6996
  }))) : /*#__PURE__*/React.createElement(VerificationError, {
6623
6997
  config: config,
6624
6998
  errMsg: hasVerificationError
@@ -8427,7 +8801,7 @@ var StickyHeadTable = function StickyHeadTable(props) {
8427
8801
  cell: function cell(row) {
8428
8802
  return /*#__PURE__*/React.createElement(IUIBox, {
8429
8803
  component: "div"
8430
- }, row.products.length > 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IUIBox, {
8804
+ }, row.products.length > 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, row.products[0].role !== "Card Holder" ? /*#__PURE__*/React.createElement(IUIBox, {
8431
8805
  component: "div",
8432
8806
  display: "flex"
8433
8807
  }, /*#__PURE__*/React.createElement(IUITypography, {
@@ -8440,7 +8814,7 @@ var StickyHeadTable = function StickyHeadTable(props) {
8440
8814
  style: {
8441
8815
  whiteSpace: 'nowrap'
8442
8816
  }
8443
- }, "\xA0" + row.products[0].role)), row.products[1] && /*#__PURE__*/React.createElement(IUIBox, {
8817
+ }, "\xA0" + row.products[0].role)) : "", row.products[1] && row.products[1].role !== "Card Holder" && /*#__PURE__*/React.createElement(IUIBox, {
8444
8818
  component: "div",
8445
8819
  display: "flex"
8446
8820
  }, /*#__PURE__*/React.createElement(IUITypography, {
@@ -8453,7 +8827,20 @@ var StickyHeadTable = function StickyHeadTable(props) {
8453
8827
  style: {
8454
8828
  whiteSpace: 'nowrap'
8455
8829
  }
8456
- }, "\xA0" + row.products[1].role))) : '');
8830
+ }, "\xA0" + row.products[1].role)), row.products[2] && row.products[2].role !== "Card Holder" && /*#__PURE__*/React.createElement(IUIBox, {
8831
+ component: "div",
8832
+ display: "flex"
8833
+ }, /*#__PURE__*/React.createElement(IUITypography, {
8834
+ className: clsx(styles$5.rowText, styles$5.textTransform, styles$5.lightColor),
8835
+ style: {
8836
+ whiteSpace: 'nowrap'
8837
+ }
8838
+ }, row.products[2].name + ' / '), /*#__PURE__*/React.createElement(IUITypography, {
8839
+ className: clsx(styles$5.rowText, styles$5.textTransform),
8840
+ style: {
8841
+ whiteSpace: 'nowrap'
8842
+ }
8843
+ }, "\xA0" + row.products[2].role))) : '');
8457
8844
  }
8458
8845
  }, {
8459
8846
  id: 'status',
@@ -8594,17 +8981,17 @@ var SingupRequests = function SingupRequests(props) {
8594
8981
  return dt.getDate() + " " + months[dt.getMonth()] + " " + dt.getFullYear();
8595
8982
  };
8596
8983
  var columns = [{
8597
- id: 'fname',
8984
+ id: 'first_name',
8598
8985
  label: 'Name',
8599
8986
  minWidth: 250,
8600
8987
  sortable: true,
8601
8988
  cell: function cell(row) {
8602
8989
  var _row$profile_pic2;
8603
8990
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IUIProfileBox, {
8604
- firstName: row.fname,
8605
- lastName: row.lname,
8991
+ firstName: row.first_name,
8992
+ lastName: row.last_name,
8606
8993
  isLetterAvatar: row.profile_pic && row.profile_pic.presigned_url ? false : true,
8607
- primaryText: row.fname + ' ' + row.lname,
8994
+ primaryText: row.first_name + ' ' + row.last_name,
8608
8995
  secondaryText: row.email,
8609
8996
  letterAvatarTextColor: "black",
8610
8997
  letterAvatarBackgroundColor: "#d3d3d3",
@@ -8613,7 +9000,7 @@ var SingupRequests = function SingupRequests(props) {
8613
9000
  }));
8614
9001
  }
8615
9002
  }, {
8616
- id: 'created',
9003
+ id: 'created_at',
8617
9004
  label: 'Requested on',
8618
9005
  minWidth: 100,
8619
9006
  sortable: true,
@@ -8623,7 +9010,7 @@ var SingupRequests = function SingupRequests(props) {
8623
9010
  width: 100
8624
9011
  }, /*#__PURE__*/React.createElement(IUITypography, {
8625
9012
  className: clsx(styles$5.rowText, styles$5.textTransform)
8626
- }, formatDate(row.created)));
9013
+ }, formatDate(row.created_at)));
8627
9014
  }
8628
9015
  }, {
8629
9016
  id: 'actions',
@@ -8896,7 +9283,7 @@ var UserList = function UserList(_ref2) {
8896
9283
  var _React$useState11 = React.useState('asc'),
8897
9284
  signup_order = _React$useState11[0],
8898
9285
  setSignUpOrder = _React$useState11[1];
8899
- var _React$useState12 = React.useState('fname'),
9286
+ var _React$useState12 = React.useState('first_name'),
8900
9287
  signup_orderBy = _React$useState12[0],
8901
9288
  setSignUpOrderBy = _React$useState12[1];
8902
9289
  var _useState22 = useState(''),
@@ -8919,7 +9306,11 @@ var UserList = function UserList(_ref2) {
8919
9306
  }),
8920
9307
  signupRequestListInfo = _useSelector3.signupRequestListInfo;
8921
9308
  var redirectToNotifications = function redirectToNotifications() {
8922
- history.push(config.routes.notification.path);
9309
+ if (config.routes.notification) {
9310
+ history.push({
9311
+ pathname: config.routes.notification.path
9312
+ });
9313
+ }
8923
9314
  };
8924
9315
  var openDeactivateModal = function openDeactivateModal() {
8925
9316
  if (Object.values(selected).flat().length === 0 || Object.values(selected).flat() === undefined) {
@@ -9541,7 +9932,7 @@ var UserList = function UserList(_ref2) {
9541
9932
  variant: "body2",
9542
9933
  className: clsx(styles$5.description)
9543
9934
  }, "Verify and add users to allow them to start using ITILITE. Set up preferences for receiving sign up request updates in", ' ', /*#__PURE__*/React.createElement("span", {
9544
- onClick: config.routes.notification && redirectToNotifications,
9935
+ onClick: redirectToNotifications,
9545
9936
  className: clsx(config.routes.notification && 'iui__cursor-pointer iui__border--bottom_solid_black500-1')
9546
9937
  }, "Notifications"))), /*#__PURE__*/React.createElement(SingupRequests, {
9547
9938
  data: signupRequestListInfo,
@@ -10079,7 +10470,6 @@ function EditPanelDialog(_ref) {
10079
10470
  }, [rowData]);
10080
10471
  var history = useHistory();
10081
10472
  var handleAddPageNavigation = function handleAddPageNavigation() {
10082
- console.log(rowData);
10083
10473
  history.push({
10084
10474
  pathname: config.routes.users.add.path,
10085
10475
  state: rowData