@itilite/iui-user-management 1.4.4 → 1.4.5

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.
@@ -64,124 +64,126 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
64
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
65
  }
66
66
 
67
- // A type of promise-like that resolves synchronously and supports only one observer
68
- const _Pact = /*#__PURE__*/(function() {
69
- function _Pact() {}
70
- _Pact.prototype.then = function(onFulfilled, onRejected) {
71
- const result = new _Pact();
72
- const state = this.s;
73
- if (state) {
74
- const callback = state & 1 ? onFulfilled : onRejected;
75
- if (callback) {
76
- try {
77
- _settle(result, 1, callback(this.v));
78
- } catch (e) {
79
- _settle(result, 2, e);
80
- }
81
- return result;
82
- } else {
83
- return this;
84
- }
85
- }
86
- this.o = function(_this) {
87
- try {
88
- const value = _this.v;
89
- if (_this.s & 1) {
90
- _settle(result, 1, onFulfilled ? onFulfilled(value) : value);
91
- } else if (onRejected) {
92
- _settle(result, 1, onRejected(value));
93
- } else {
94
- _settle(result, 2, value);
95
- }
96
- } catch (e) {
97
- _settle(result, 2, e);
98
- }
99
- };
100
- return result;
101
- };
102
- return _Pact;
103
- })();
104
-
105
- // Settles a pact synchronously
67
+ var _Pact = /*#__PURE__*/function () {
68
+ function _Pact() {}
69
+ _Pact.prototype.then = function (onFulfilled, onRejected) {
70
+ var result = new _Pact();
71
+ var state = this.s;
72
+ if (state) {
73
+ var callback = state & 1 ? onFulfilled : onRejected;
74
+ if (callback) {
75
+ try {
76
+ _settle(result, 1, callback(this.v));
77
+ } catch (e) {
78
+ _settle(result, 2, e);
79
+ }
80
+ return result;
81
+ } else {
82
+ return this;
83
+ }
84
+ }
85
+ this.o = function (_this) {
86
+ try {
87
+ var value = _this.v;
88
+ if (_this.s & 1) {
89
+ _settle(result, 1, onFulfilled ? onFulfilled(value) : value);
90
+ } else if (onRejected) {
91
+ _settle(result, 1, onRejected(value));
92
+ } else {
93
+ _settle(result, 2, value);
94
+ }
95
+ } catch (e) {
96
+ _settle(result, 2, e);
97
+ }
98
+ };
99
+ return result;
100
+ };
101
+ return _Pact;
102
+ }();
106
103
  function _settle(pact, state, value) {
107
- if (!pact.s) {
108
- if (value instanceof _Pact) {
109
- if (value.s) {
110
- if (state & 1) {
111
- state = value.s;
112
- }
113
- value = value.v;
114
- } else {
115
- value.o = _settle.bind(null, pact, state);
116
- return;
117
- }
118
- }
119
- if (value && value.then) {
120
- value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
121
- return;
122
- }
123
- pact.s = state;
124
- pact.v = value;
125
- const observer = pact.o;
126
- if (observer) {
127
- observer(pact);
128
- }
129
- }
104
+ if (!pact.s) {
105
+ if (value instanceof _Pact) {
106
+ if (value.s) {
107
+ if (state & 1) {
108
+ state = value.s;
109
+ }
110
+ value = value.v;
111
+ } else {
112
+ value.o = _settle.bind(null, pact, state);
113
+ return;
114
+ }
115
+ }
116
+ if (value && value.then) {
117
+ value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
118
+ return;
119
+ }
120
+ pact.s = state;
121
+ pact.v = value;
122
+ var observer = pact.o;
123
+ if (observer) {
124
+ observer(pact);
125
+ }
126
+ }
130
127
  }
131
-
132
128
  function _isSettledPact(thenable) {
133
- return thenable instanceof _Pact && thenable.s & 1;
129
+ return thenable instanceof _Pact && thenable.s & 1;
134
130
  }
135
-
136
- // Asynchronously iterate through an object that has a length property, passing the index as the first argument to the callback (even as the length property changes)
137
131
  function _forTo(array, body, check) {
138
- var i = -1, pact, reject;
139
- function _cycle(result) {
140
- try {
141
- while (++i < array.length && (!check || !check())) {
142
- result = body(i);
143
- if (result && result.then) {
144
- if (_isSettledPact(result)) {
145
- result = result.v;
146
- } else {
147
- result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
148
- return;
149
- }
150
- }
151
- }
152
- if (pact) {
153
- _settle(pact, 1, result);
154
- } else {
155
- pact = result;
156
- }
157
- } catch (e) {
158
- _settle(pact || (pact = new _Pact()), 2, e);
159
- }
160
- }
161
- _cycle();
162
- return pact;
132
+ var i = -1,
133
+ pact,
134
+ reject;
135
+ function _cycle(result) {
136
+ try {
137
+ while (++i < array.length && (!check || !check())) {
138
+ result = body(i);
139
+ if (result && result.then) {
140
+ if (_isSettledPact(result)) {
141
+ result = result.v;
142
+ } else {
143
+ result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
144
+ return;
145
+ }
146
+ }
147
+ }
148
+ if (pact) {
149
+ _settle(pact, 1, result);
150
+ } else {
151
+ pact = result;
152
+ }
153
+ } catch (e) {
154
+ _settle(pact || (pact = new _Pact()), 2, e);
155
+ }
156
+ }
157
+ _cycle();
158
+ return pact;
163
159
  }
164
-
165
- const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
166
-
167
- const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
168
-
169
- // Asynchronously call a function and send errors to recovery continuation
160
+ var _iteratorSymbol = /*#__PURE__*/typeof Symbol !== "undefined" ? Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator")) : "@@iterator";
161
+ var _asyncIteratorSymbol = /*#__PURE__*/typeof Symbol !== "undefined" ? Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator")) : "@@asyncIterator";
170
162
  function _catch(body, recover) {
171
- try {
172
- var result = body();
173
- } catch(e) {
174
- return recover(e);
175
- }
176
- if (result && result.then) {
177
- return result.then(void 0, recover);
178
- }
179
- return result;
163
+ try {
164
+ var result = body();
165
+ } catch (e) {
166
+ return recover(e);
167
+ }
168
+ if (result && result.then) {
169
+ return result.then(void 0, recover);
170
+ }
171
+ return result;
180
172
  }
181
173
 
182
174
  var styles = {"UUIUserManagementAddEdit":"_3n-WG","pageHeader":"_3qWcA","buttonWrapper":"_1IP9P","scrolled":"_m8f96","headingButtonWrapper":"_w9z7b","headingButtonWrapperProfile":"_12Wd9","hintText":"_ySdbZ","heading":"_2Y1Aw","headingLarge":"_2K1NF","headingMedium":"_RUuAz","headingSmall":"_23Dye","additionalInfoContainer":"_1Suhw","additionalInfoTitle":"_56iJF","titleContainer":"_H5nfl","expandIconAlign":"_3F4i0","detailsContainer":"_2G0LW","formWrapper":"_2fPRc","sectionWrapper":"_37Gqp","margin":"_2Sdl7","minGridWidth":"_2D7iu","firstRowMargin":"_1BozG","firstChildMargin":"_2C3Mb","paddingTop":"_DBPjV","backGrdColorOnHover":"_5oE6H","fieldMargin":"_RCWjq","productContainerGap":"_tuCbi","containerWidth":"_1oWos","productItemBroder":"_T0Hcd","headingPadding":"_2MFfQ","emptyFieldContainer":"_3VWtw","emptyFieldDescription":"_2jC5u","rowGap":"_1NJFY","formTitle":"_GAKk2","formDescription":"_3TZ6Z","themeLink":"_eJ_1B","dashedLine":"_3ZOs1","dividerColor":"_2pxEJ","errorTextCls":"_27eth","backdrop":"_Pm0Au","inputWidth":"_ajB82"};
183
175
 
184
- function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
176
+ function r(e) {
177
+ var t,
178
+ f,
179
+ n = "";
180
+ if ("string" == typeof e || "number" == typeof e) n += e;else if ("object" == typeof e) if (Array.isArray(e)) for (t = 0; t < e.length; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);else for (t in e) e[t] && (n && (n += " "), n += t);
181
+ return n;
182
+ }
183
+ function clsx() {
184
+ for (var e, t, f = 0, n = ""; f < arguments.length;) (e = arguments[f++]) && (t = r(e)) && (n && (n += " "), n += t);
185
+ return n;
186
+ }
185
187
 
186
188
  var GetInputType = React.forwardRef(function (props, ref) {
187
189
  var _p = props._p,
@@ -242,7 +244,8 @@ var GetInputType = React.forwardRef(function (props, ref) {
242
244
  hasInfoIcon: !!_p.tooltip,
243
245
  tooltipText: _p.tooltip,
244
246
  required: _p.required,
245
- disableText: _p.disableText
247
+ disableText: _p.disableText,
248
+ className: "test-mudu"
246
249
  }));
247
250
  case 'select':
248
251
  return /*#__PURE__*/React.createElement(IUISelect, {
@@ -821,7 +824,7 @@ var UserRole = function UserRole(_ref) {
821
824
  }));
822
825
  };
823
826
 
824
- var styles$1 = {"card":"_3_S9J","cardNumber":"_36E9M","cardDigit":"_2pm-T","expiryDate":"_2tBnF","cardImage":"_3QvZh","visa":"_1IpBm","mastercard":"_2x6IX","amex":"_2a38S","discover":"_2vksl","diners":"_2kQRs","jcb":"_2bO1f","unionpay":"_2_jfu","is_nothing":"_1Lrzs","addCard":"_3711U","cardDeleteBtn":"_7Da2t","cardLabel":"_PQTex","defaultLabel":"_smjc4","defaultBtn":"_1_ArA","cursonPointer":"_1L115","sectionWrapper":"_VpUCK","margin":"_1Fs_D","minGridWidth":"_1hl-Z","firstRowMargin":"_1WZZj","firstChildMargin":"_IT_O_","paddingTop":"_Mhnl7","dividerColor":"_3ltFd"};
827
+ var styles$1 = {"card":"_3_S9J","defaultCardError":"_1Ixsh","cardNumber":"_36E9M","cardDigit":"_2pm-T","expiryDate":"_2tBnF","cardImage":"_3QvZh","visa":"_1IpBm","mastercard":"_2x6IX","amex":"_2a38S","discover":"_2vksl","diners":"_2kQRs","jcb":"_2bO1f","unionpay":"_2_jfu","is_nothing":"_1Lrzs","addCard":"_3711U","cardDeleteBtn":"_7Da2t","cardLabel":"_PQTex","defaultLabel":"_smjc4","defaultBtn":"_1_ArA","cursonPointer":"_1L115","sectionWrapper":"_VpUCK","margin":"_1Fs_D","minGridWidth":"_1hl-Z","firstRowMargin":"_1WZZj","firstChildMargin":"_IT_O_","paddingTop":"_Mhnl7","dividerColor":"_3ltFd"};
825
828
 
826
829
  var SHOW_LOADER = 'SHOW_LOADER';
827
830
  var STOP_LOADER = 'STOP_LOADER';
@@ -2274,13 +2277,15 @@ var CreditCard = function CreditCard(_ref) {
2274
2277
  }));
2275
2278
  };
2276
2279
  var AddCard = function AddCard(_ref2) {
2277
- var pg = _ref2.pg;
2280
+ var _clsx;
2281
+ var pg = _ref2.pg,
2282
+ defaultCardError = _ref2.defaultCardError;
2278
2283
  var _url = env$3.getPaymentUrl() + ("/api/v1/auth/" + IUILocalStorageService$4.getAccessToken() + "/1/" + pg.entity_id + "/0/" + pg.vendor_id + "/1");
2279
2284
  var handleAddCard = function handleAddCard() {
2280
2285
  window.location.assign(_url);
2281
2286
  };
2282
2287
  return /*#__PURE__*/React.createElement("div", {
2283
- className: clsx(styles$1.card, styles$1.cursonPointer),
2288
+ className: clsx(styles$1.card, styles$1.cursonPointer, (_clsx = {}, _clsx[styles$1.defaultCardError] = defaultCardError, _clsx)),
2284
2289
  onClick: handleAddCard
2285
2290
  }, /*#__PURE__*/React.createElement("div", {
2286
2291
  className: styles$1.addCard
@@ -2288,7 +2293,9 @@ var AddCard = function AddCard(_ref2) {
2288
2293
  };
2289
2294
  var PaymentCards = function PaymentCards(_ref3) {
2290
2295
  var _paymentDetails$pg, _paymentDetails$pg2;
2291
- var paymentDetails = _ref3.paymentDetails;
2296
+ var paymentDetails = _ref3.paymentDetails,
2297
+ _ref3$defaultCardErro = _ref3.defaultCardError,
2298
+ defaultCardError = _ref3$defaultCardErro === void 0 ? null : _ref3$defaultCardErro;
2292
2299
  if (!paymentDetails || Object.keys(paymentDetails).length === 0 || (!paymentDetails.cards || paymentDetails.cards.length === 0) && ((paymentDetails === null || paymentDetails === void 0 ? void 0 : (_paymentDetails$pg = paymentDetails.pg) === null || _paymentDetails$pg === void 0 ? void 0 : _paymentDetails$pg.gateway.toLowerCase()) !== 'stripe' || (paymentDetails === null || paymentDetails === void 0 ? void 0 : (_paymentDetails$pg2 = paymentDetails.pg) === null || _paymentDetails$pg2 === void 0 ? void 0 : _paymentDetails$pg2.save_card_enable) !== 1)) {
2293
2300
  return /*#__PURE__*/React.createElement(React.Fragment, null);
2294
2301
  }
@@ -2297,7 +2304,9 @@ var PaymentCards = function PaymentCards(_ref3) {
2297
2304
  }), /*#__PURE__*/React.createElement(IUIGrid, {
2298
2305
  container: true,
2299
2306
  className: clsx(styles$1.sectionWrapper)
2300
- }, /*#__PURE__*/React.createElement(IUIGrid, {
2307
+ }, /*#__PURE__*/React.createElement("span", {
2308
+ id: "card-details-scroll"
2309
+ }), /*#__PURE__*/React.createElement(IUIGrid, {
2301
2310
  item: true,
2302
2311
  sm: 12,
2303
2312
  md: 4
@@ -2325,9 +2334,14 @@ var PaymentCards = function PaymentCards(_ref3) {
2325
2334
  isDefaultCard: !!+card.metadata.default_card,
2326
2335
  pg: paymentDetails.pg
2327
2336
  });
2328
- }), (!paymentDetails.cards || paymentDetails.cards.length < 10) && paymentDetails.pg.gateway.toLowerCase() === 'stripe' && paymentDetails.pg.save_card_enable === 1 && /*#__PURE__*/React.createElement(AddCard, {
2329
- pg: paymentDetails.pg
2330
- }))))));
2337
+ }), (!paymentDetails.cards || paymentDetails.cards.length < 10) && paymentDetails.pg.gateway.toLowerCase() === 'stripe' && paymentDetails.pg.save_card_enable === 1 && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(AddCard, {
2338
+ pg: paymentDetails.pg,
2339
+ defaultCardError: defaultCardError
2340
+ }), defaultCardError && /*#__PURE__*/React.createElement("p", {
2341
+ style: {
2342
+ color: 'red'
2343
+ }
2344
+ }, ' ', "Please provide default card detail")))))));
2331
2345
  };
2332
2346
 
2333
2347
  function AddIcon(props) {
@@ -2400,7 +2414,9 @@ var TravelExpenseFields = function TravelExpenseFields(props) {
2400
2414
  _props$editUserId = props.editUserId,
2401
2415
  editUserId = _props$editUserId === void 0 ? null : _props$editUserId,
2402
2416
  _props$roles = props.roles,
2403
- roles = _props$roles === void 0 ? [] : _props$roles;
2417
+ roles = _props$roles === void 0 ? [] : _props$roles,
2418
+ _props$errorMsgs = props.errorMsgs,
2419
+ errorMsgs = _props$errorMsgs === void 0 ? null : _props$errorMsgs;
2404
2420
  var _useState = useState({
2405
2421
  product: '',
2406
2422
  approvers: []
@@ -2696,9 +2712,10 @@ var TravelExpenseFields = function TravelExpenseFields(props) {
2696
2712
  isError: !!errMsg[i],
2697
2713
  placeholder: "Example label - \u201CManager\u201D"
2698
2714
  }));
2699
- })))), type === 'travel' && isProfile && paymentDetails && /*#__PURE__*/React.createElement(PaymentCards, {
2700
- paymentDetails: paymentDetails
2701
- }));
2715
+ })))), type === 'travel' && isProfile && paymentDetails && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PaymentCards, {
2716
+ paymentDetails: paymentDetails,
2717
+ defaultCardError: errorMsgs === null || errorMsgs === void 0 ? void 0 : errorMsgs.cards
2718
+ })));
2702
2719
  };
2703
2720
 
2704
2721
  var styles$2 = {"inputWidth":"_1qLG1"};
@@ -4031,6 +4048,18 @@ var setFieldsDisplayAtt = function setFieldsDisplayAtt(objToLoop, visibilityObj,
4031
4048
  if (labelsObj && Object.hasOwnProperty.call(labelsObj, p.name)) {
4032
4049
  p.label = labelsObj[p.name];
4033
4050
  }
4051
+ var isProfilePage = window.location.pathname.includes('/profile');
4052
+ if (isProfilePage) {
4053
+ var searchParams = new URL(document.location).searchParams;
4054
+ var required = searchParams.get('required');
4055
+ if (required === 'dob') {
4056
+ if (p.name === 'dob') {
4057
+ if (required === 'dob') {
4058
+ p.required = true;
4059
+ }
4060
+ }
4061
+ }
4062
+ }
4034
4063
  return p;
4035
4064
  });
4036
4065
  };
@@ -5055,6 +5084,9 @@ var CardsField = function CardsField(props) {
5055
5084
  }, editUserId ? "Only Card admin can change the Card role." : "Only Card admin can change card roles. By default this user will have Card Holder role.")))));
5056
5085
  };
5057
5086
 
5087
+ var isProfilePage = window.location.pathname.includes('/profile');
5088
+ var searchParams = new URL(document.location).searchParams;
5089
+ var required = searchParams.get('required');
5058
5090
  var IUIToastMessageService$4 = services.IUIToastMessageService,
5059
5091
  IUILocalStorageService$5 = services.IUILocalStorageService;
5060
5092
  var env$4 = configs.env;
@@ -5532,7 +5564,8 @@ var UserAddEdit = function UserAddEdit(props) {
5532
5564
  travel_docs: '',
5533
5565
  products: '',
5534
5566
  userTagType: '',
5535
- profile_pic: ''
5567
+ profile_pic: '',
5568
+ cards: ''
5536
5569
  }),
5537
5570
  errorMsgs = _useState27[0],
5538
5571
  setErrorMsgs = _useState27[1];
@@ -6049,6 +6082,32 @@ var UserAddEdit = function UserAddEdit(props) {
6049
6082
  contact_country_code: res.personal_info.contact_country_code || '',
6050
6083
  profile_pic: profilePic || []
6051
6084
  }));
6085
+ if (isProfilePage) {
6086
+ if (required === 'dob') {
6087
+ if (!res.personal_info.dob) {
6088
+ setErrorArray([].concat(errorArray, ['dob']));
6089
+ setErrorMsgs(_extends({}, errorArray, {
6090
+ dob: 'Please enter the valid date of birth'
6091
+ }));
6092
+ }
6093
+ }
6094
+ if (required === 'card') {
6095
+ var _res$payment_details;
6096
+ if ((res === null || res === void 0 ? void 0 : (_res$payment_details = res.payment_details) === null || _res$payment_details === void 0 ? void 0 : _res$payment_details.cards.length) === 0) {
6097
+ setErrorArray([].concat(errorArray, ['cards']));
6098
+ setErrorMsgs(_extends({}, errorArray, {
6099
+ cards: 'Please provide default card detail'
6100
+ }));
6101
+ setTimeout(function () {
6102
+ var cardElement = document.getElementById('card-details-scroll');
6103
+ if (cardElement) window.scrollTo({
6104
+ top: cardElement.offsetTop - 200,
6105
+ behavior: 'smooth'
6106
+ });
6107
+ }, 1500);
6108
+ }
6109
+ }
6110
+ }
6052
6111
  setEmployeeInfoInput(_extends({}, employeeInfoInput, {
6053
6112
  emp_level: res.employee_info.emp_level ? {
6054
6113
  value: res.employee_info.emp_level.id,
@@ -6333,6 +6392,7 @@ var UserAddEdit = function UserAddEdit(props) {
6333
6392
  var formSubmitHandler = function formSubmitHandler() {
6334
6393
  try {
6335
6394
  var checkAnyError = doesFormHasError();
6395
+ console.log(checkAnyError);
6336
6396
  if (checkAnyError) {
6337
6397
  IUIToastMessageService$4.warningNotify(checkAnyError);
6338
6398
  return Promise.resolve();
@@ -6641,6 +6701,7 @@ var UserAddEdit = function UserAddEdit(props) {
6641
6701
  };
6642
6702
  var doesFormHasError = function doesFormHasError() {
6643
6703
  for (var key in errorMsgs) {
6704
+ console.log(Object.hasOwnProperty.call(errorMsgs, key));
6644
6705
  if (Object.hasOwnProperty.call(errorMsgs, key)) {
6645
6706
  if (errorMsgs[key] !== '' && key !== 'passport_photo' && key !== 'travel_docs') {
6646
6707
  return errorMsgs[key];
@@ -7000,7 +7061,8 @@ var UserAddEdit = function UserAddEdit(props) {
7000
7061
  maxApprovers: maxTravelApprovers,
7001
7062
  isProfile: isProfile,
7002
7063
  editUserId: editUserId,
7003
- roles: renderFields.travelRoles
7064
+ roles: renderFields.travelRoles,
7065
+ errorMsgs: errorMsgs
7004
7066
  }), /*#__PURE__*/React.createElement(IUIDivider, {
7005
7067
  className: styles.dividerColor
7006
7068
  }), /*#__PURE__*/React.createElement(AdditionalInfo, {