@itilite/iui-user-management 0.4.52 → 0.4.54

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 () {});
@@ -3191,6 +3252,12 @@ var products = [{
3191
3252
  name: 'expense',
3192
3253
  type: 'checkbox',
3193
3254
  disableText: 'Please get in touch with your administrator to change this value.'
3255
+ }, {
3256
+ id: 3,
3257
+ label: 'Cards',
3258
+ name: 'cards',
3259
+ type: 'checkbox',
3260
+ disableText: 'Please get in touch with your administrator to change this value.'
3194
3261
  }];
3195
3262
  var dropdownList = {
3196
3263
  gender: [{
@@ -3361,6 +3428,34 @@ var expenseConstants = {
3361
3428
  disableText: 'Please get in touch with your administrator to change this value.'
3362
3429
  }]
3363
3430
  };
3431
+ var cardsConstants = {
3432
+ heading: 'Card specific information',
3433
+ roleHeading: 'Card role',
3434
+ roleDescription: 'Roles allow users to only access relevant features and functionalities',
3435
+ roles: [{
3436
+ id: 1,
3437
+ label: 'Card holder',
3438
+ description: 'Can own and use cards that are issued to them',
3439
+ value: '',
3440
+ name: '',
3441
+ type: 'radio',
3442
+ isAssigned: false,
3443
+ fullWidth: false,
3444
+ visibility: true,
3445
+ disableText: 'Please get in touch with your administrator to change this value.'
3446
+ }, {
3447
+ id: 2,
3448
+ label: 'Card admin',
3449
+ description: 'Can issue cards to others and can manage all cards and transactions across the company.',
3450
+ value: '',
3451
+ name: '',
3452
+ type: 'radio',
3453
+ isAssigned: false,
3454
+ fullWidth: false,
3455
+ visibility: true,
3456
+ disableText: 'Please get in touch with your administrator to change this value.'
3457
+ }]
3458
+ };
3364
3459
  var passportInfo = [{
3365
3460
  id: 1,
3366
3461
  label: 'Passport issuing country',
@@ -3590,6 +3685,12 @@ var initialState = {
3590
3685
  travelConstants: travelConstants,
3591
3686
  expenseConstants: expenseConstants
3592
3687
  },
3688
+ isCardsDetailsRendered: false,
3689
+ isCardsAdmin: false,
3690
+ cardsDetails: {
3691
+ cardsRoles: cardsConstants.roles,
3692
+ cardsConstants: cardsConstants
3693
+ },
3593
3694
  dropdownList: dropdownList,
3594
3695
  maxTravelApprovers: 10,
3595
3696
  maxExpenseApprovers: 10,
@@ -3756,11 +3857,37 @@ var reducer = function reducer(state, action) {
3756
3857
  isRendered: true
3757
3858
  });
3758
3859
  }
3860
+ case SET_CARDS_DETAILS:
3861
+ {
3862
+ var _action$payload8, _action$payload8$role, _action$payload9;
3863
+ var cardsDetails = _extends({}, state.cardsDetails);
3864
+ 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) {
3865
+ cardsDetails.cardsRoles = action.payload.roles.map(function (role) {
3866
+ return {
3867
+ id: role.id,
3868
+ label: role.name,
3869
+ description: role.description,
3870
+ value: role.value,
3871
+ isAssigned: role.is_assigned,
3872
+ name: role.value,
3873
+ type: 'radio',
3874
+ fullWidth: false,
3875
+ visibility: true,
3876
+ disableText: 'Please get in touch with your administrator to change this value.'
3877
+ };
3878
+ });
3879
+ }
3880
+ return _extends({}, state, {
3881
+ cardsDetails: cardsDetails,
3882
+ isCardsDetailsRendered: true,
3883
+ 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
3884
+ });
3885
+ }
3759
3886
  case SET_STATIC_FIELDS_VISIBILITY:
3760
3887
  {
3761
3888
  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]) {
3889
+ var _action$payload10;
3890
+ 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
3891
  if (Object.hasOwnProperty.call(action.payload[input.name], 'readOnly')) {
3765
3892
  input.readOnly = action.payload[input.name].readOnly;
3766
3893
  }
@@ -4813,7 +4940,8 @@ var ErrorMessages = {
4813
4940
  passport_expiry_date: 'Please enter passport expiry date.',
4814
4941
  passport_photo: 'Please attach passport photo.',
4815
4942
  travel_docs: 'Please attach travel docs.',
4816
- products: 'Please select atleast one product access.'
4943
+ only_cards_products: 'Select at least one additional product if opting for cards.',
4944
+ none_products: 'Select at least one product. If opting for cards, please choose at least one additional product.'
4817
4945
  };
4818
4946
 
4819
4947
  function AddPanelDialog(_ref) {
@@ -4863,7 +4991,56 @@ function AddPanelDialog(_ref) {
4863
4991
  })));
4864
4992
  }
4865
4993
 
4866
- var IUIToastMessageService$4 = services.IUIToastMessageService;
4994
+ var CardsField = function CardsField(props) {
4995
+ var cardsConstants = props.cardsConstants,
4996
+ _props$onRoleChange = props.onRoleChange,
4997
+ onRoleChange = _props$onRoleChange === void 0 ? function () {} : _props$onRoleChange,
4998
+ _props$roleValue = props.roleValue,
4999
+ roleValue = _props$roleValue === void 0 ? '' : _props$roleValue,
5000
+ _props$isProfile = props.isProfile,
5001
+ isProfile = _props$isProfile === void 0 ? false : _props$isProfile,
5002
+ _props$roles = props.roles,
5003
+ roles = _props$roles === void 0 ? [] : _props$roles;
5004
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IUIGrid, {
5005
+ container: true,
5006
+ className: (styles.headingPadding)
5007
+ }, /*#__PURE__*/React.createElement(IUITypography, {
5008
+ variant: "h3",
5009
+ className: clsx(styles.heading, styles.headingMedium)
5010
+ }, cardsConstants.heading)), /*#__PURE__*/React.createElement(IUIDivider, {
5011
+ className: styles.dividerColor
5012
+ }), /*#__PURE__*/React.createElement(IUIGrid, {
5013
+ container: true,
5014
+ className: clsx(styles.product_info, styles.sectionWrapper)
5015
+ }, /*#__PURE__*/React.createElement(IUIGrid, {
5016
+ item: true,
5017
+ sm: 12,
5018
+ md: 4
5019
+ }, /*#__PURE__*/React.createElement(IUILabel, {
5020
+ label: cardsConstants.roleHeading,
5021
+ headerType: true,
5022
+ description: cardsConstants.roleDescription
5023
+ })), /*#__PURE__*/React.createElement(IUIGrid, {
5024
+ item: true,
5025
+ sm: 12,
5026
+ md: 8,
5027
+ lg: 8,
5028
+ xl: 6
5029
+ }, /*#__PURE__*/React.createElement(IUIGrid, {
5030
+ container: true,
5031
+ className: styles.formFieldsWrapper
5032
+ }, isProfile ? /*#__PURE__*/React.createElement(UserRole, {
5033
+ list: roles,
5034
+ value: roleValue
5035
+ }) : /*#__PURE__*/React.createElement(IUIRadio, {
5036
+ list: roles,
5037
+ value: roleValue,
5038
+ onValueChange: onRoleChange
5039
+ })))));
5040
+ };
5041
+
5042
+ var IUIToastMessageService$4 = services.IUIToastMessageService,
5043
+ IUILocalStorageService$5 = services.IUILocalStorageService;
4867
5044
  var env$4 = configs.env;
4868
5045
  var UserAddEdit = function UserAddEdit(props) {
4869
5046
  var isEditMode = props.isEditMode,
@@ -4871,6 +5048,8 @@ var UserAddEdit = function UserAddEdit(props) {
4871
5048
  config = props.config,
4872
5049
  _props$isProfile = props.isProfile,
4873
5050
  isProfile = _props$isProfile === void 0 ? false : _props$isProfile;
5051
+ console.log("isProfile", isProfile);
5052
+ console.log("isEditMode", isEditMode);
4874
5053
  env$4.init(config, isProfile);
4875
5054
  var queryParams = new URLSearchParams(window.location.search);
4876
5055
  var verifyUserId = Number(queryParams.get(config.routes.users.add.queryParamKeys.verifyUserId));
@@ -4890,7 +5069,12 @@ var UserAddEdit = function UserAddEdit(props) {
4890
5069
  isRendered = _useSelector.isRendered,
4891
5070
  maxTravelApprovers = _useSelector.maxTravelApprovers,
4892
5071
  maxExpenseApprovers = _useSelector.maxExpenseApprovers,
4893
- maxMembershipInput = _useSelector.maxMembershipInput;
5072
+ maxMembershipInput = _useSelector.maxMembershipInput,
5073
+ isCardsDetailsRendered = _useSelector.isCardsDetailsRendered,
5074
+ isCardsAdmin = _useSelector.isCardsAdmin,
5075
+ cardsDetails = _useSelector.cardsDetails;
5076
+ console.log("isCardsAdmin", isCardsAdmin);
5077
+ console.log("cardsDetails", cardsDetails);
4894
5078
  var _useSelector2 = useSelector(function (state) {
4895
5079
  return state.common;
4896
5080
  }),
@@ -4899,11 +5083,13 @@ var UserAddEdit = function UserAddEdit(props) {
4899
5083
  hasVerificationError = _useSelector2.hasVerificationError,
4900
5084
  isILadmin = _useSelector2.isILadmin,
4901
5085
  companyName = _useSelector2.companyName;
5086
+ console.log("id", id);
4902
5087
  var history = useHistory();
4903
5088
  var location = useLocation();
4904
5089
  var _useState = useState({
4905
5090
  travel: false,
4906
- expense: false
5091
+ expense: false,
5092
+ cards: false
4907
5093
  }),
4908
5094
  productAccess = _useState[0],
4909
5095
  setProductAccess = _useState[1];
@@ -4914,13 +5100,13 @@ var UserAddEdit = function UserAddEdit(props) {
4914
5100
  errorMsgs.products = '';
4915
5101
  var _productAccess = _extends({}, productAccess);
4916
5102
  _productAccess[value] = !_productAccess[value];
4917
- if (_productAccess.travel === false && _productAccess.expense === false) {
5103
+ if (_productAccess.travel === false && _productAccess.expense === false && _productAccess.cards === true) {
4918
5104
  var _errorArray = [].concat(errorArray);
4919
5105
  var _errorMsgs = _extends({}, errorMsgs);
4920
5106
  if (_errorArray.indexOf('products') === -1) {
4921
5107
  _errorArray.push('products');
4922
5108
  }
4923
- _errorMsgs.products = ErrorMessages.products;
5109
+ _errorMsgs.products = ErrorMessages.only_cards_products;
4924
5110
  setErrorArray(_errorArray);
4925
5111
  setErrorMsgs(_errorMsgs);
4926
5112
  var el = document.getElementById('products');
@@ -4930,13 +5116,202 @@ var UserAddEdit = function UserAddEdit(props) {
4930
5116
  block: 'center'
4931
5117
  });
4932
5118
  }
5119
+ } else if (_productAccess.travel === false && _productAccess.expense === false && _productAccess.cards === false) {
5120
+ var _errorArray2 = [].concat(errorArray);
5121
+ var _errorMsgs2 = _extends({}, errorMsgs);
5122
+ if (_errorArray2.indexOf('products') === -1) {
5123
+ _errorArray2.push('products');
5124
+ }
5125
+ _errorMsgs2.products = ErrorMessages.none_products;
5126
+ setErrorArray(_errorArray2);
5127
+ setErrorMsgs(_errorMsgs2);
5128
+ var _el = document.getElementById('products');
5129
+ if (_el) {
5130
+ _el.scrollIntoView({
5131
+ behavior: 'smooth',
5132
+ block: 'center'
5133
+ });
5134
+ }
4933
5135
  } else {
4934
5136
  setErrorArray(errorArray);
4935
5137
  setErrorMsgs(errorMsgs);
4936
5138
  }
4937
5139
  setProductAccess(_productAccess);
4938
5140
  };
4939
- var _useState2 = useState({
5141
+ var _useState2 = useState(''),
5142
+ newCountryCode = _useState2[0],
5143
+ setNewCountryCode = _useState2[1];
5144
+ var _useState3 = useState(),
5145
+ countryDialCode = _useState3[0],
5146
+ setCountryDialCode = _useState3[1];
5147
+ var _useState4 = useState([]),
5148
+ countryContactCode = _useState4[0],
5149
+ setCountryContactCode = _useState4[1];
5150
+ var updateUserApiCall = function updateUserApiCall(payload, inputChangeLog) {
5151
+ dispatch(updateUser(payload, isProfile ? id : editUserId, inputChangeLog)).then(function (res) {
5152
+ if (isProfile) {
5153
+ var _config$routes, _config$routes$profil, _config$routes$profil2;
5154
+ (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);
5155
+ } else {
5156
+ var _config$routes2, _config$routes2$users, _config$routes2$users2;
5157
+ (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);
5158
+ }
5159
+ setFilesForDelete([]);
5160
+ setProfilePicDelete([]);
5161
+ })["catch"](function (err) {
5162
+ if (typeof err === 'object') {
5163
+ if (err.country_code) {
5164
+ err.contact_number = err.country_code;
5165
+ }
5166
+ if (err.contact_country_code) {
5167
+ err.contact_number = err.contact_country_code;
5168
+ }
5169
+ if (err.passport) {
5170
+ err.passport_photo = _extends({}, err.passport);
5171
+ delete err.passport;
5172
+ }
5173
+ setErrorArray(Object.keys(err));
5174
+ setErrorMsgs(err);
5175
+ var _loop = function _loop() {
5176
+ if (Object.hasOwnProperty.call(err, key)) {
5177
+ if (err[key]) {
5178
+ if (key in passportInfoInput || key in travelPreferenceInfo || key in secureTravelInputInfo) {
5179
+ setAdditionalInfoFlag('open');
5180
+ }
5181
+ var el = document.getElementById(key === 'country_code' || key === 'contact_country_code' ? 'contact_number' : key);
5182
+ if (el) {
5183
+ setTimeout(function () {
5184
+ el.scrollIntoView({
5185
+ behavior: 'smooth',
5186
+ block: 'center'
5187
+ });
5188
+ }, 500);
5189
+ return 1;
5190
+ }
5191
+ }
5192
+ }
5193
+ };
5194
+ for (var key in err) {
5195
+ if (_loop()) break;
5196
+ }
5197
+ } else if (typeof err === 'string') {
5198
+ IUIToastMessageService$4.warningNotify(err);
5199
+ } else {
5200
+ IUIToastMessageService$4.warningNotify('Opps, Something went wrong.');
5201
+ }
5202
+ })["finally"](function () {
5203
+ dispatch(stopLoader());
5204
+ });
5205
+ };
5206
+ var createUserApiCall = function createUserApiCall(payload) {
5207
+ dispatch(createUser(payload)).then(function (res) {
5208
+ var _config$routes3, _config$routes3$users, _config$routes3$users2;
5209
+ 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) {
5210
+ history.push({
5211
+ pathname: config.routes.users.list.path
5212
+ });
5213
+ }
5214
+ })["catch"](function (err) {
5215
+ if (typeof err === 'object') {
5216
+ if (err.country_code) {
5217
+ err.contact_number = err.country_code;
5218
+ }
5219
+ if (err.contact_country_code) {
5220
+ err.contact_number = err.contact_country_code;
5221
+ }
5222
+ if (err.passport) {
5223
+ err.passport_photo = _extends({}, err.passport);
5224
+ delete err.passport;
5225
+ }
5226
+ setErrorArray(Object.keys(err));
5227
+ setErrorMsgs(err);
5228
+ var _loop2 = function _loop2() {
5229
+ if (Object.hasOwnProperty.call(err, key)) {
5230
+ if (err[key]) {
5231
+ if (key in passportInfoInput || key in travelPreferenceInfo || key in secureTravelInputInfo) {
5232
+ setAdditionalInfoFlag('open');
5233
+ }
5234
+ var el = document.getElementById(key === 'country_code' || key === 'contact_country_code' ? 'contact_number' : key);
5235
+ if (el) {
5236
+ setTimeout(function () {
5237
+ el.scrollIntoView({
5238
+ behavior: 'smooth',
5239
+ block: 'center'
5240
+ });
5241
+ }, 500);
5242
+ return 1;
5243
+ }
5244
+ }
5245
+ }
5246
+ };
5247
+ for (var key in err) {
5248
+ if (_loop2()) break;
5249
+ }
5250
+ } else if (typeof err === 'string') {
5251
+ IUIToastMessageService$4.warningNotify(err);
5252
+ } else {
5253
+ IUIToastMessageService$4.warningNotify('Opps, Something went wrong.');
5254
+ }
5255
+ })["finally"](function () {
5256
+ dispatch(stopLoader());
5257
+ });
5258
+ };
5259
+ var fetchEditUserCardsDetails = function fetchEditUserCardsDetails(editUserId) {
5260
+ fetch(userAddEditUrl.cardsEditUserDetails(editUserId), {
5261
+ method: 'GET',
5262
+ headers: {
5263
+ 'Content-Type': 'application/json',
5264
+ 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
5265
+ }
5266
+ }).then(function (response) {
5267
+ return response.json();
5268
+ }).then(function (res) {
5269
+ var _res$roles;
5270
+ if (res !== null && res !== void 0 && (_res$roles = res.roles) !== null && _res$roles !== void 0 && _res$roles.length) {
5271
+ dispatch(setCardsDetails(res));
5272
+ } else {
5273
+ IUIToastMessageService$4.warningNotify('Opps, Something went wrong.');
5274
+ }
5275
+ })["catch"](function (error) {
5276
+ console.log("errorrr", error);
5277
+ });
5278
+ };
5279
+ var fetchLoggedUserCardsDetails = function fetchLoggedUserCardsDetails() {
5280
+ fetch(userAddEditUrl.cardsAddUsersDetails(), {
5281
+ method: 'GET',
5282
+ headers: {
5283
+ 'Content-Type': 'application/json',
5284
+ 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
5285
+ }
5286
+ }).then(function (response) {
5287
+ return response.json();
5288
+ }).then(function (res) {
5289
+ var _res$roles2;
5290
+ if (res !== null && res !== void 0 && (_res$roles2 = res.roles) !== null && _res$roles2 !== void 0 && _res$roles2.length) {
5291
+ dispatch(setCardsDetails(res));
5292
+ } else {
5293
+ IUIToastMessageService$4.warningNotify('Opps, Something went wrong.');
5294
+ }
5295
+ })["catch"](function (error) {
5296
+ console.log("errorrr", error);
5297
+ });
5298
+ };
5299
+ useEffect(function () {
5300
+ var countryObject = countryContactCode.find(function (t) {
5301
+ return t.dial_code === countryDialCode;
5302
+ });
5303
+ if (countryObject) {
5304
+ setPersonalInfoInput(_extends({}, personalInfoInput, {
5305
+ country_code: countryObject.code
5306
+ }));
5307
+ }
5308
+ }, [countryDialCode]);
5309
+ useEffect(function () {
5310
+ var extractedNumber = newCountryCode.substring(1);
5311
+ var convertedNumber = parseInt(extractedNumber);
5312
+ setCountryDialCode(convertedNumber);
5313
+ }, [newCountryCode]);
5314
+ var _useState5 = useState({
4940
5315
  first_name: '',
4941
5316
  last_name: '',
4942
5317
  email: '',
@@ -4947,9 +5322,9 @@ var UserAddEdit = function UserAddEdit(props) {
4947
5322
  contact_country_code: '',
4948
5323
  profile_pic: []
4949
5324
  }),
4950
- personalInfoInput = _useState2[0],
4951
- setPersonalInfoInput = _useState2[1];
4952
- var _useState3 = useState({
5325
+ personalInfoInput = _useState5[0],
5326
+ setPersonalInfoInput = _useState5[1];
5327
+ var _useState6 = useState({
4953
5328
  emp_level: {
4954
5329
  value: '',
4955
5330
  label: 'Select employee level'
@@ -4982,9 +5357,9 @@ var UserAddEdit = function UserAddEdit(props) {
4982
5357
  label: defaultCurrency
4983
5358
  }
4984
5359
  }),
4985
- employeeInfoInput = _useState3[0],
4986
- setEmployeeInfoInput = _useState3[1];
4987
- var _useState4 = useState({
5360
+ employeeInfoInput = _useState6[0],
5361
+ setEmployeeInfoInput = _useState6[1];
5362
+ var _useState7 = useState({
4988
5363
  emp_level: 0,
4989
5364
  entity: 0,
4990
5365
  business_unit: 0,
@@ -4993,48 +5368,48 @@ var UserAddEdit = function UserAddEdit(props) {
4993
5368
  manager_id: 0,
4994
5369
  skip_manager_id: 0
4995
5370
  }),
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({
5371
+ cacheForAsyncDropdown = _useState7[0],
5372
+ clearCacheForAsyncDropdown = _useState7[1];
5373
+ var _useState8 = useState({}),
5374
+ userTagType = _useState8[0],
5375
+ setUserTagType = _useState8[1];
5376
+ var _useState9 = useState(false),
5377
+ scroll = _useState9[0],
5378
+ setScroll = _useState9[1];
5379
+ var _useState10 = useState({}),
5380
+ customFieldsInput = _useState10[0],
5381
+ setCustomFieldsInput = _useState10[1];
5382
+ var _useState11 = useState('traveler'),
5383
+ travelRole = _useState11[0],
5384
+ setTravelRole = _useState11[1];
5385
+ var _useState12 = useState({}),
5386
+ travelApproversInput = _useState12[0],
5387
+ setTravelApproversInput = _useState12[1];
5388
+ var _useState13 = useState({
5014
5389
  value: '',
5015
5390
  label: 'Select approver'
5016
5391
  }),
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({
5392
+ travelFYI = _useState13[0],
5393
+ setTravelFYI = _useState13[1];
5394
+ var _useState14 = useState([]),
5395
+ membershipInfoInput = _useState14[0],
5396
+ setMembershipInfoInput = _useState14[1];
5397
+ var _useState15 = useState([]),
5398
+ removedMembershipInfoInput = _useState15[0],
5399
+ setRemovedMembershipInfoInput = _useState15[1];
5400
+ var _useState16 = useState({
5026
5401
  flight_seat_preference: '',
5027
5402
  meal_preference: ''
5028
5403
  }),
5029
- travelPreferenceInfo = _useState13[0],
5030
- settravelPreferenceInfo = _useState13[1];
5031
- var _useState14 = useState({
5404
+ travelPreferenceInfo = _useState16[0],
5405
+ settravelPreferenceInfo = _useState16[1];
5406
+ var _useState17 = useState({
5032
5407
  trusted_traveller: '',
5033
5408
  redress_number: ''
5034
5409
  }),
5035
- secureTravelInputInfo = _useState14[0],
5036
- setSecureTravelInputInfo = _useState14[1];
5037
- var _useState15 = useState({
5410
+ secureTravelInputInfo = _useState17[0],
5411
+ setSecureTravelInputInfo = _useState17[1];
5412
+ var _useState18 = useState({
5038
5413
  passport_issue_country: {
5039
5414
  value: '',
5040
5415
  label: 'Select country'
@@ -5049,39 +5424,94 @@ var UserAddEdit = function UserAddEdit(props) {
5049
5424
  passport_photo: [],
5050
5425
  travel_docs: []
5051
5426
  }),
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({
5427
+ passportInfoInput = _useState18[0],
5428
+ setPassportInfoInput = _useState18[1];
5429
+ var _useState19 = useState([]),
5430
+ filesForDelete = _useState19[0],
5431
+ setFilesForDelete = _useState19[1];
5432
+ var _useState20 = useState([]),
5433
+ profilePicDelete = _useState20[0],
5434
+ setProfilePicDelete = _useState20[1];
5435
+ var _useState21 = useState(config.env.isTravelProduct && isProfile ? 'open' : ''),
5436
+ isAdditionalInfoExpanded = _useState21[0],
5437
+ setAdditionalInfoFlag = _useState21[1];
5438
+ var _useState22 = useState('submitter'),
5439
+ expenseRole = _useState22[0],
5440
+ setExpenseRole = _useState22[1];
5441
+ var _useState23 = useState({}),
5442
+ expenseApproversInput = _useState23[0],
5443
+ setExpenseApproversInput = _useState23[1];
5444
+ var _useState24 = useState({
5070
5445
  value: '',
5071
5446
  label: 'Select approver'
5072
5447
  }),
5073
- expenseFYI = _useState21[0],
5074
- setExpenseFYI = _useState21[1];
5448
+ expenseFYI = _useState24[0],
5449
+ setExpenseFYI = _useState24[1];
5450
+ var _useState25 = useState(''),
5451
+ cardsRole = _useState25[0],
5452
+ setCardsRole = _useState25[1];
5453
+ var _useState26 = useState(false),
5454
+ cardsErrorMsg = _useState26[0],
5455
+ setCardsErrorMsg = _useState26[1];
5456
+ console.log("cardsRole123", cardsRole);
5457
+ console.log("cardsErrorMsg", cardsErrorMsg);
5458
+ useEffect(function () {
5459
+ if (isCardsAdmin === false && cardsRole.includes("card_admin")) {
5460
+ setCardsErrorMsg(true);
5461
+ IUIToastMessageService$4.warningNotify("You are not authorized person to make someone admin");
5462
+ } else {
5463
+ setCardsErrorMsg(false);
5464
+ }
5465
+ }, [cardsRole]);
5466
+ useEffect(function () {
5467
+ if (productAccess.cards === false) {
5468
+ setCardsRole('');
5469
+ } else {
5470
+ for (var _iterator = _createForOfIteratorHelperLoose(cardsDetails.cardsRoles), _step; !(_step = _iterator()).done;) {
5471
+ var role = _step.value;
5472
+ var splitRoleval = role.value.split(":");
5473
+ var defaultRole = splitRoleval[2];
5474
+ if (defaultRole === 'card_holder') {
5475
+ setCardsRole(role.value);
5476
+ break;
5477
+ }
5478
+ }
5479
+ }
5480
+ }, [productAccess.cards]);
5481
+ useEffect(function () {
5482
+ if (isCardsDetailsRendered) {
5483
+ var selectedRole = null;
5484
+ for (var _iterator2 = _createForOfIteratorHelperLoose(cardsDetails.cardsRoles), _step2; !(_step2 = _iterator2()).done;) {
5485
+ var _role = _step2.value;
5486
+ if (_role.isAssigned) {
5487
+ setCardsRole(_role.value);
5488
+ selectedRole = _role.value;
5489
+ break;
5490
+ }
5491
+ }
5492
+ if (selectedRole === null) {
5493
+ for (var _iterator3 = _createForOfIteratorHelperLoose(cardsDetails.cardsRoles), _step3; !(_step3 = _iterator3()).done;) {
5494
+ var role = _step3.value;
5495
+ var splitRoleval = role.value.split(":");
5496
+ var defaultRole = splitRoleval[2];
5497
+ if (defaultRole === 'card_holder') {
5498
+ setCardsRole(role.value);
5499
+ break;
5500
+ }
5501
+ }
5502
+ }
5503
+ }
5504
+ }, [isCardsDetailsRendered, cardsDetails]);
5075
5505
  var asyncSelectRefs = useRef({
5076
5506
  emp_level: useRef(null),
5077
5507
  entity: useRef(null),
5078
5508
  business_unit: useRef(null),
5079
5509
  department: useRef(null)
5080
5510
  });
5081
- var _useState22 = useState([]),
5082
- errorArray = _useState22[0],
5083
- setErrorArray = _useState22[1];
5084
- var _useState23 = useState({
5511
+ var _useState27 = useState([]),
5512
+ errorArray = _useState27[0],
5513
+ setErrorArray = _useState27[1];
5514
+ var _useState28 = useState({
5085
5515
  first_name: '',
5086
5516
  last_name: '',
5087
5517
  email: '',
@@ -5111,9 +5541,9 @@ var UserAddEdit = function UserAddEdit(props) {
5111
5541
  userTagType: '',
5112
5542
  profile_pic: ''
5113
5543
  }),
5114
- errorMsgs = _useState23[0],
5115
- setErrorMsgs = _useState23[1];
5116
- var _useState24 = useState({
5544
+ errorMsgs = _useState28[0],
5545
+ setErrorMsgs = _useState28[1];
5546
+ var _useState29 = useState({
5117
5547
  first_name: false,
5118
5548
  last_name: false,
5119
5549
  email: false,
@@ -5140,14 +5570,14 @@ var UserAddEdit = function UserAddEdit(props) {
5140
5570
  userTagType: false,
5141
5571
  profile_pic: false
5142
5572
  }),
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];
5573
+ inputChangeLog = _useState29[0],
5574
+ updateInputChangeLog = _useState29[1];
5575
+ var _useState30 = useState([]),
5576
+ uploadedFiles = _useState30[0],
5577
+ setUploadedFiles = _useState30[1];
5578
+ var _useState31 = useState(70),
5579
+ maxLengthForModal = _useState31[0],
5580
+ setMaxLengthForModal = _useState31[1];
5151
5581
  var defaultAddModalData = {
5152
5582
  isOpen: false,
5153
5583
  isError: false,
@@ -5163,9 +5593,9 @@ var UserAddEdit = function UserAddEdit(props) {
5163
5593
  maxLength: maxLengthForModal,
5164
5594
  minLength: 0
5165
5595
  };
5166
- var _useState27 = useState(defaultAddModalData),
5167
- addModalData = _useState27[0],
5168
- setAddModalData = _useState27[1];
5596
+ var _useState32 = useState(defaultAddModalData),
5597
+ addModalData = _useState32[0],
5598
+ setAddModalData = _useState32[1];
5169
5599
  var onAddModalClose = function onAddModalClose() {
5170
5600
  setAddModalData(_extends({}, defaultAddModalData));
5171
5601
  };
@@ -5342,7 +5772,6 @@ var UserAddEdit = function UserAddEdit(props) {
5342
5772
  _value = args._value,
5343
5773
  _isError = args._isError,
5344
5774
  _errorMsg = args._errorMsg;
5345
- console.log(_name, _value);
5346
5775
  setEmployeeInfoInput(_extends({}, employeeInfoInput, (_extends8 = {}, _extends8[_name] = _value, _extends8)));
5347
5776
  updateError(_name, _isError, _errorMsg);
5348
5777
  if (Object.hasOwnProperty.call(inputChangeLog, _name)) {
@@ -5376,7 +5805,6 @@ var UserAddEdit = function UserAddEdit(props) {
5376
5805
  var _extends12;
5377
5806
  var _name = _ref3._name,
5378
5807
  _value = _ref3._value;
5379
- console.log(_name, _value, 'travel');
5380
5808
  setTravelApproversInput(_extends({}, travelApproversInput, (_extends12 = {}, _extends12[_name] = _value, _extends12)));
5381
5809
  };
5382
5810
  var onExpenseApproversInputChange = function onExpenseApproversInputChange(_ref4) {
@@ -5574,6 +6002,7 @@ var UserAddEdit = function UserAddEdit(props) {
5574
6002
  useEffect(function () {
5575
6003
  if (isTokenVerified === true) {
5576
6004
  dispatch(fetchRenderFileds());
6005
+ editUserId ? fetchEditUserCardsDetails(editUserId) : fetchLoggedUserCardsDetails();
5577
6006
  }
5578
6007
  }, [isTokenVerified]);
5579
6008
  useEffect(function () {
@@ -5588,6 +6017,7 @@ var UserAddEdit = function UserAddEdit(props) {
5588
6017
  }
5589
6018
  }));
5590
6019
  dispatch(fetchCountryCodes()).then(function (_res) {
6020
+ setCountryContactCode(_res);
5591
6021
  if (isEditMode) {
5592
6022
  if (!isProfile && !editUserId) return false;
5593
6023
  dispatch(setStaticFieldsVisibility({
@@ -5698,7 +6128,8 @@ var UserAddEdit = function UserAddEdit(props) {
5698
6128
  var products = res.user_product.split('+');
5699
6129
  setProductAccess({
5700
6130
  travel: products.includes('travel'),
5701
- expense: products.includes('expense')
6131
+ expense: products.includes('expense'),
6132
+ cards: products.includes('cards')
5702
6133
  });
5703
6134
  if (products.includes('travel')) {
5704
6135
  var _res$travel_info, _res$travel_info2, _res$travel_info3, _res$travel_info4, _res$travel_info5, _res$travel_info6;
@@ -5909,13 +6340,15 @@ var UserAddEdit = function UserAddEdit(props) {
5909
6340
  IUIToastMessageService$4.warningNotify(checkAnyError);
5910
6341
  return Promise.resolve();
5911
6342
  }
5912
- console.log(employeeInfoInput, 'data');
5913
6343
  if (employeeInfoInput.manager_id.value !== '') {
5914
6344
  employeeInfoInput.manager_id = employeeInfoInput.manager.value;
5915
6345
  }
5916
6346
  if (employeeInfoInput.skip_manager_id.value !== '') {
5917
6347
  employeeInfoInput.skip_manager_id = employeeInfoInput.skip_manager.value;
5918
6348
  }
6349
+ var cardsPayload = {
6350
+ "roles": [cardsRole]
6351
+ };
5919
6352
  var payload = {
5920
6353
  personalInfoInput: personalInfoInput,
5921
6354
  employeeInfoInput: employeeInfoInput,
@@ -5934,7 +6367,9 @@ var UserAddEdit = function UserAddEdit(props) {
5934
6367
  uploadedFiles: uploadedFiles,
5935
6368
  filesForDelete: filesForDelete,
5936
6369
  profilePicDelete: profilePicDelete,
5937
- userTagType: userTagType
6370
+ userTagType: userTagType,
6371
+ cardsRole: cardsRole,
6372
+ isCardsAdmin: isCardsAdmin
5938
6373
  };
5939
6374
  if (verifyUserId) {
5940
6375
  payload.verifyUserId = verifyUserId;
@@ -5946,6 +6381,9 @@ var UserAddEdit = function UserAddEdit(props) {
5946
6381
  employeeInfo = optionalFields.employee_info,
5947
6382
  userTravelInfo = optionalFields.user_travel_info;
5948
6383
  var allMandatoryFields = ['first_name', 'last_name', 'email'];
6384
+ if (cardsErrorMsg) {
6385
+ _isError = true;
6386
+ }
5949
6387
  allMandatoryFields.forEach(function (key, index) {
5950
6388
  if (personalInfoInput[key] === '') {
5951
6389
  _isError = true;
@@ -5973,11 +6411,8 @@ var UserAddEdit = function UserAddEdit(props) {
5973
6411
  }
5974
6412
  }
5975
6413
  for (var _key in employeeInfo) {
5976
- console.log('key', _key);
5977
6414
  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) {
6415
+ 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
6416
  _isError = true;
5982
6417
  if (_errorArray.indexOf(_key) === -1) _errorArray.push(_key);
5983
6418
  _errorMsgs[_key] = ErrorMessages[_key];
@@ -6063,7 +6498,7 @@ var UserAddEdit = function UserAddEdit(props) {
6063
6498
  if (_isError) {
6064
6499
  setErrorArray(_errorArray);
6065
6500
  setErrorMsgs(_errorMsgs);
6066
- var _loop = function _loop() {
6501
+ var _loop3 = function _loop3() {
6067
6502
  if (Object.hasOwnProperty.call(_errorMsgs, _key3)) {
6068
6503
  if (_errorMsgs[_key3]) {
6069
6504
  if (_key3 in passportInfoInput || _key3 in travelPreferenceInfo || _key3 in secureTravelInputInfo) {
@@ -6083,115 +6518,64 @@ var UserAddEdit = function UserAddEdit(props) {
6083
6518
  }
6084
6519
  };
6085
6520
  for (var _key3 in _errorMsgs) {
6086
- if (_loop()) break;
6521
+ if (_loop3()) break;
6087
6522
  }
6088
6523
  }
6524
+ var cardApiflag = false;
6525
+ if (productAccess.cards === false) {
6526
+ cardApiflag = false;
6527
+ } else {
6528
+ cardApiflag = true;
6529
+ }
6089
6530
  if (!_isError) {
6090
6531
  if (isEditMode && editUserId || isProfile) {
6091
6532
  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;
6533
+ if (cardApiflag) {
6534
+ fetch(userAddEditUrl.cardsEditUserDetails(editUserId), {
6535
+ method: 'POST',
6536
+ body: JSON.stringify(cardsPayload),
6537
+ headers: {
6538
+ 'Content-Type': 'application/json',
6539
+ 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
6109
6540
  }
6110
- if (err.passport) {
6111
- err.passport_photo = _extends({}, err.passport);
6112
- delete err.passport;
6113
- }
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;
6541
+ }).then(function (response) {
6542
+ if (response.status === 200) {
6543
+ updateUserApiCall(payload, inputChangeLog);
6544
+ } else {
6545
+ IUIToastMessageService$4.warningNotify('Opps, Something went wrong.');
6137
6546
  }
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
- });
6547
+ })["catch"](function (error) {
6548
+ console.log("errorrr", error);
6549
+ })["finally"](function () {
6550
+ dispatch(stopLoader());
6551
+ });
6552
+ } else {
6553
+ updateUserApiCall(payload, inputChangeLog);
6554
+ }
6146
6555
  } else {
6147
6556
  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;
6557
+ if (cardApiflag === true) {
6558
+ fetch(userAddEditUrl.cardsEditUserDetails(isEditMode ? editUserId : id), {
6559
+ method: 'POST',
6560
+ body: JSON.stringify(cardsPayload),
6561
+ headers: {
6562
+ 'Content-Type': 'application/json',
6563
+ 'authorization': "Bearer " + IUILocalStorageService$5.getAccessToken()
6162
6564
  }
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;
6565
+ }).then(function (response) {
6566
+ if (response.status === 200) {
6567
+ createUserApiCall(payload);
6568
+ } else {
6569
+ IUIToastMessageService$4.warningNotify('Opps, Something went wrong.');
6186
6570
  }
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
- });
6571
+ })["catch"](function (error) {
6572
+ console.log("errorrr", error);
6573
+ })["finally"](function () {
6574
+ dispatch(stopLoader());
6575
+ });
6576
+ } else {
6577
+ createUserApiCall(payload);
6578
+ }
6195
6579
  }
6196
6580
  }
6197
6581
  return Promise.resolve();
@@ -6230,17 +6614,13 @@ var UserAddEdit = function UserAddEdit(props) {
6230
6614
  if (verifyUserId) {
6231
6615
  dispatch(showLoader());
6232
6616
  dispatch(verifyUserInfo(verifyUserId)).then(function (res) {
6617
+ setNewCountryCode(res === null || res === void 0 ? void 0 : res.country_contact_code);
6233
6618
  setPersonalInfoInput(function (prevState) {
6234
6619
  return _extends({}, prevState, {
6235
- first_name: res.fname,
6236
- last_name: res.lname,
6620
+ first_name: res.first_name,
6621
+ last_name: res.last_name,
6237
6622
  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
- }(),
6623
+ contact_number: res === null || res === void 0 ? void 0 : res.contact_number,
6244
6624
  gender: function () {
6245
6625
  if (res.gender === 'male') return 'Male';else if (res.gender === 'female') return 'Female';else if (res.gender === 'others') return 'Others';else return '';
6246
6626
  }()
@@ -6513,7 +6893,7 @@ var UserAddEdit = function UserAddEdit(props) {
6513
6893
  md: 4
6514
6894
  }, /*#__PURE__*/React.createElement(IUILabel, {
6515
6895
  label: "Product access",
6516
- description: isProfile ? '' : 'Select at least one product',
6896
+ description: isProfile ? '' : 'Please select a product. Cards are available along with at least one additional product.',
6517
6897
  headerType: true,
6518
6898
  required: true
6519
6899
  })), /*#__PURE__*/React.createElement(IUIGrid, {
@@ -6619,6 +6999,19 @@ var UserAddEdit = function UserAddEdit(props) {
6619
6999
  isProfile: isProfile,
6620
7000
  editUserId: editUserId,
6621
7001
  roles: renderFields.expenseRoles
7002
+ }), /*#__PURE__*/React.createElement(IUIDivider, {
7003
+ className: styles.dividerColor
7004
+ }), isCardsDetailsRendered && productAccess && productAccess.cards && /*#__PURE__*/React.createElement(CardsField, {
7005
+ cardsConstants: cardsDetails.cardsConstants,
7006
+ type: "cards",
7007
+ isProfile: isProfile,
7008
+ onRoleChange: function onRoleChange(_ref7) {
7009
+ var _value = _ref7._value;
7010
+ return setCardsRole(_value);
7011
+ },
7012
+ roleValue: cardsRole,
7013
+ roles: cardsDetails.cardsRoles,
7014
+ cardsAdmin: isCardsAdmin
6622
7015
  }))) : /*#__PURE__*/React.createElement(VerificationError, {
6623
7016
  config: config,
6624
7017
  errMsg: hasVerificationError
@@ -8427,7 +8820,7 @@ var StickyHeadTable = function StickyHeadTable(props) {
8427
8820
  cell: function cell(row) {
8428
8821
  return /*#__PURE__*/React.createElement(IUIBox, {
8429
8822
  component: "div"
8430
- }, row.products.length > 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IUIBox, {
8823
+ }, row.products.length > 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, row.products[0].role !== "Card Holder" ? /*#__PURE__*/React.createElement(IUIBox, {
8431
8824
  component: "div",
8432
8825
  display: "flex"
8433
8826
  }, /*#__PURE__*/React.createElement(IUITypography, {
@@ -8440,7 +8833,7 @@ var StickyHeadTable = function StickyHeadTable(props) {
8440
8833
  style: {
8441
8834
  whiteSpace: 'nowrap'
8442
8835
  }
8443
- }, "\xA0" + row.products[0].role)), row.products[1] && /*#__PURE__*/React.createElement(IUIBox, {
8836
+ }, "\xA0" + row.products[0].role)) : "", row.products[1] && row.products[1].role !== "Card Holder" && /*#__PURE__*/React.createElement(IUIBox, {
8444
8837
  component: "div",
8445
8838
  display: "flex"
8446
8839
  }, /*#__PURE__*/React.createElement(IUITypography, {
@@ -8453,7 +8846,20 @@ var StickyHeadTable = function StickyHeadTable(props) {
8453
8846
  style: {
8454
8847
  whiteSpace: 'nowrap'
8455
8848
  }
8456
- }, "\xA0" + row.products[1].role))) : '');
8849
+ }, "\xA0" + row.products[1].role)), row.products[2] && row.products[2].role !== "Card Holder" && /*#__PURE__*/React.createElement(IUIBox, {
8850
+ component: "div",
8851
+ display: "flex"
8852
+ }, /*#__PURE__*/React.createElement(IUITypography, {
8853
+ className: clsx(styles$5.rowText, styles$5.textTransform, styles$5.lightColor),
8854
+ style: {
8855
+ whiteSpace: 'nowrap'
8856
+ }
8857
+ }, row.products[2].name + ' / '), /*#__PURE__*/React.createElement(IUITypography, {
8858
+ className: clsx(styles$5.rowText, styles$5.textTransform),
8859
+ style: {
8860
+ whiteSpace: 'nowrap'
8861
+ }
8862
+ }, "\xA0" + row.products[2].role))) : '');
8457
8863
  }
8458
8864
  }, {
8459
8865
  id: 'status',
@@ -8594,17 +9000,17 @@ var SingupRequests = function SingupRequests(props) {
8594
9000
  return dt.getDate() + " " + months[dt.getMonth()] + " " + dt.getFullYear();
8595
9001
  };
8596
9002
  var columns = [{
8597
- id: 'fname',
9003
+ id: 'first_name',
8598
9004
  label: 'Name',
8599
9005
  minWidth: 250,
8600
9006
  sortable: true,
8601
9007
  cell: function cell(row) {
8602
9008
  var _row$profile_pic2;
8603
9009
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IUIProfileBox, {
8604
- firstName: row.fname,
8605
- lastName: row.lname,
9010
+ firstName: row.first_name,
9011
+ lastName: row.last_name,
8606
9012
  isLetterAvatar: row.profile_pic && row.profile_pic.presigned_url ? false : true,
8607
- primaryText: row.fname + ' ' + row.lname,
9013
+ primaryText: row.first_name + ' ' + row.last_name,
8608
9014
  secondaryText: row.email,
8609
9015
  letterAvatarTextColor: "black",
8610
9016
  letterAvatarBackgroundColor: "#d3d3d3",
@@ -8613,7 +9019,7 @@ var SingupRequests = function SingupRequests(props) {
8613
9019
  }));
8614
9020
  }
8615
9021
  }, {
8616
- id: 'created',
9022
+ id: 'created_at',
8617
9023
  label: 'Requested on',
8618
9024
  minWidth: 100,
8619
9025
  sortable: true,
@@ -8623,7 +9029,7 @@ var SingupRequests = function SingupRequests(props) {
8623
9029
  width: 100
8624
9030
  }, /*#__PURE__*/React.createElement(IUITypography, {
8625
9031
  className: clsx(styles$5.rowText, styles$5.textTransform)
8626
- }, formatDate(row.created)));
9032
+ }, formatDate(row.created_at)));
8627
9033
  }
8628
9034
  }, {
8629
9035
  id: 'actions',
@@ -8896,7 +9302,7 @@ var UserList = function UserList(_ref2) {
8896
9302
  var _React$useState11 = React.useState('asc'),
8897
9303
  signup_order = _React$useState11[0],
8898
9304
  setSignUpOrder = _React$useState11[1];
8899
- var _React$useState12 = React.useState('fname'),
9305
+ var _React$useState12 = React.useState('first_name'),
8900
9306
  signup_orderBy = _React$useState12[0],
8901
9307
  setSignUpOrderBy = _React$useState12[1];
8902
9308
  var _useState22 = useState(''),
@@ -8919,7 +9325,11 @@ var UserList = function UserList(_ref2) {
8919
9325
  }),
8920
9326
  signupRequestListInfo = _useSelector3.signupRequestListInfo;
8921
9327
  var redirectToNotifications = function redirectToNotifications() {
8922
- history.push(config.routes.notification.path);
9328
+ if (config.routes.notification) {
9329
+ history.push({
9330
+ pathname: config.routes.notification.path
9331
+ });
9332
+ }
8923
9333
  };
8924
9334
  var openDeactivateModal = function openDeactivateModal() {
8925
9335
  if (Object.values(selected).flat().length === 0 || Object.values(selected).flat() === undefined) {
@@ -9541,7 +9951,7 @@ var UserList = function UserList(_ref2) {
9541
9951
  variant: "body2",
9542
9952
  className: clsx(styles$5.description)
9543
9953
  }, "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,
9954
+ onClick: redirectToNotifications,
9545
9955
  className: clsx(config.routes.notification && 'iui__cursor-pointer iui__border--bottom_solid_black500-1')
9546
9956
  }, "Notifications"))), /*#__PURE__*/React.createElement(SingupRequests, {
9547
9957
  data: signupRequestListInfo,
@@ -10079,7 +10489,6 @@ function EditPanelDialog(_ref) {
10079
10489
  }, [rowData]);
10080
10490
  var history = useHistory();
10081
10491
  var handleAddPageNavigation = function handleAddPageNavigation() {
10082
- console.log(rowData);
10083
10492
  history.push({
10084
10493
  pathname: config.routes.users.add.path,
10085
10494
  state: rowData