@itilite/iui-user-management 0.4.34 → 0.4.36

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.
@@ -9,7 +9,7 @@ import { combineReducers, createStore, applyMiddleware } from 'redux';
9
9
  import thunk from 'redux-thunk';
10
10
  import moment from 'moment';
11
11
  import { composeWithDevTools } from 'redux-devtools-extension';
12
- import { useHistory } from 'react-router-dom';
12
+ import { useHistory, useLocation } from 'react-router-dom';
13
13
  import { withStyles, makeStyles } from '@material-ui/core/styles';
14
14
  import Tooltip from '@material-ui/core/Tooltip';
15
15
  import Switch from '@material-ui/core/Switch';
@@ -1102,6 +1102,12 @@ var setSignUpRequestList = function setSignUpRequestList(payload) {
1102
1102
  payload: payload
1103
1103
  };
1104
1104
  };
1105
+ var setUserActiveStatus = function setUserActiveStatus(payload) {
1106
+ return {
1107
+ type: SET_ACTIVE_STATUS,
1108
+ payload: payload
1109
+ };
1110
+ };
1105
1111
  var setBulkDeactivatedUsers = function setBulkDeactivatedUsers(payload) {
1106
1112
  return {
1107
1113
  type: SET_BULK_DEACTIVATED_USERS,
@@ -1194,6 +1200,27 @@ var updateTabValue = function updateTabValue(tabId) {
1194
1200
  payload: tabId
1195
1201
  };
1196
1202
  };
1203
+ var updateActiveStatus = function updateActiveStatus(activateVal, id) {
1204
+ return function (dispatch) {
1205
+ return new Promise(function (resolve, reject) {
1206
+ api$1.get(userListUrl.updateActiveStatus + 'user_id=' + id + '&activate=' + activateVal).then(function (res) {
1207
+ dispatch(setUserActiveStatus({
1208
+ is_active: activateVal !== 0,
1209
+ id: id
1210
+ }));
1211
+ IUIToastMessageService.sNotify(res.data.message);
1212
+ resolve(res);
1213
+ })["catch"](function (err) {
1214
+ if (!err.response.data.status) {
1215
+ IUIToastMessageService.warningNotify(err.response.data.message);
1216
+ reject(err);
1217
+ return;
1218
+ }
1219
+ reject(err);
1220
+ });
1221
+ });
1222
+ };
1223
+ };
1197
1224
 
1198
1225
  var api$2 = configs.api;
1199
1226
  var IUIToastMessageService$1 = services.IUIToastMessageService,
@@ -1740,7 +1767,7 @@ var verifyUserInfo = function verifyUserInfo(userId) {
1740
1767
  var submitAddModalData = function submitAddModalData(tableName, data) {
1741
1768
  return function (dispatch) {
1742
1769
  return new Promise(function (resolve, reject) {
1743
- api$2.post(userAddEditUrl.dropdownList() + ("?action=add&table=" + tableName), data).then(function (res) {
1770
+ api$2.post(tableName === 'department' ? departmentUrl.departmentUrl() : userAddEditUrl.dropdownList() + ("?action=add&table=" + tableName), data).then(function (res) {
1744
1771
  resolve(res);
1745
1772
  })["catch"](function (err) {
1746
1773
  var _err$response17, _err$response17$data;
@@ -4844,6 +4871,7 @@ var UserAddEdit = function UserAddEdit(props) {
4844
4871
  isILadmin = _useSelector2.isILadmin,
4845
4872
  companyName = _useSelector2.companyName;
4846
4873
  var history = useHistory();
4874
+ var location = useLocation();
4847
4875
  var _useState = useState({
4848
4876
  travel: false,
4849
4877
  expense: false
@@ -5099,6 +5127,18 @@ var UserAddEdit = function UserAddEdit(props) {
5099
5127
  var onAddModalClose = function onAddModalClose() {
5100
5128
  setAddModalData(_extends({}, defaultAddModalData));
5101
5129
  };
5130
+ useEffect(function () {
5131
+ var _location$state, _location$state2;
5132
+ if (location !== null && location !== void 0 && (_location$state = location.state) !== null && _location$state !== void 0 && _location$state.id && location !== null && location !== void 0 && (_location$state2 = location.state) !== null && _location$state2 !== void 0 && _location$state2.name) {
5133
+ var _location$state3, _location$state4;
5134
+ setEmployeeInfoInput(_extends({}, employeeInfoInput, {
5135
+ department: {
5136
+ value: location === null || location === void 0 ? void 0 : (_location$state3 = location.state) === null || _location$state3 === void 0 ? void 0 : _location$state3.id,
5137
+ label: location === null || location === void 0 ? void 0 : (_location$state4 = location.state) === null || _location$state4 === void 0 ? void 0 : _location$state4.name
5138
+ }
5139
+ }));
5140
+ }
5141
+ }, []);
5102
5142
  var onModalOpen = function onModalOpen(e, id) {
5103
5143
  var title = '';
5104
5144
  if (id === 'entity') {
@@ -5124,9 +5164,18 @@ var UserAddEdit = function UserAddEdit(props) {
5124
5164
  }));
5125
5165
  } else {
5126
5166
  dispatch(showLoader());
5127
- dispatch(submitAddModalData(addModalData.id, {
5128
- names: [validatedValue]
5129
- })).then(function (res) {
5167
+ var dataObj;
5168
+ if (addModalData.id === 'department') {
5169
+ dataObj = {
5170
+ name: validatedValue,
5171
+ department_head_id: null
5172
+ };
5173
+ } else {
5174
+ dataObj = {
5175
+ names: [validatedValue]
5176
+ };
5177
+ }
5178
+ dispatch(submitAddModalData(addModalData.id, dataObj)).then(function (res) {
5130
5179
  var _extends2, _extends3;
5131
5180
  setAddModalData(_extends({}, addModalData, {
5132
5181
  isOpen: false
@@ -5134,8 +5183,8 @@ var UserAddEdit = function UserAddEdit(props) {
5134
5183
  IUIToastMessageService$4.sNotify(addModalData.title + " added successfully.");
5135
5184
  var tempKey = addModalData.id === 'employee_level' ? 'emp_level' : addModalData.id;
5136
5185
  setEmployeeInfoInput(_extends({}, employeeInfoInput, (_extends2 = {}, _extends2[tempKey] = {
5137
- value: res.data.value,
5138
- label: res.data.label
5186
+ value: res.data.result.id,
5187
+ label: res.data.result.name
5139
5188
  }, _extends2)));
5140
5189
  updateInputChangeLog(_extends({}, inputChangeLog, (_extends3 = {}, _extends3[tempKey] = true, _extends3)));
5141
5190
  asyncSelectRefs.current[tempKey].current.blur();
@@ -5275,6 +5324,7 @@ var UserAddEdit = function UserAddEdit(props) {
5275
5324
  var _extends11;
5276
5325
  var _name = _ref3._name,
5277
5326
  _value = _ref3._value;
5327
+ console.log(_name, _value, 'travel');
5278
5328
  setTravelApproversInput(_extends({}, travelApproversInput, (_extends11 = {}, _extends11[_name] = _value, _extends11)));
5279
5329
  };
5280
5330
  var onExpenseApproversInputChange = function onExpenseApproversInputChange(_ref4) {
@@ -8857,7 +8907,17 @@ var UserList = function UserList(_ref2) {
8857
8907
  setSortingChangeTemp(!isSortingChangeTemp);
8858
8908
  };
8859
8909
  var handleActiveUser = function handleActiveUser(e, id, page) {
8860
- setDeactivateSingle(true);
8910
+ var isActive = e.target.checked;
8911
+ dispatch(updateActiveStatus(e.target.checked ? 1 : 0, e.target.id)).then(function () {
8912
+ if (!isActive) {
8913
+ if (Object.values(selected).flat().includes(id.toString())) {
8914
+ var _extends5;
8915
+ var selectedTemp = _extends({}, selected);
8916
+ selectedTemp[page].splice(selectedTemp[page].indexOf(id.toString()), 1);
8917
+ setSelected(_extends({}, selected, (_extends5 = {}, _extends5[page] = selectedTemp[page], _extends5)));
8918
+ }
8919
+ }
8920
+ });
8861
8921
  };
8862
8922
  var handleDeactivateUsers = function handleDeactivateUsers() {
8863
8923
  dispatch(deActivateUsers(Object.values(selected).flat()));
@@ -9484,7 +9544,6 @@ function Listview(_ref) {
9484
9544
  if ((data === null || data === void 0 ? void 0 : (_data$dept_head_detai = data.dept_head_details) === null || _data$dept_head_detai === void 0 ? void 0 : _data$dept_head_detai.length) > 0) {
9485
9545
  return data.dept_head_details[0].first_name + ' ' + data.dept_head_details[0].last_name;
9486
9546
  }
9487
- return 'Unassigned';
9488
9547
  };
9489
9548
  var columns = [{
9490
9549
  id: 'name',
@@ -9673,7 +9732,6 @@ function EditPanelDialog(_ref) {
9673
9732
  dialogData = _useSelector.dialogData;
9674
9733
  var deptHeadDetails = function deptHeadDetails(data) {
9675
9734
  var _data$dept_head_detai;
9676
- console.log(data);
9677
9735
  if ((data === null || data === void 0 ? void 0 : (_data$dept_head_detai = data.dept_head_details) === null || _data$dept_head_detai === void 0 ? void 0 : _data$dept_head_detai.length) > 0) {
9678
9736
  setHead({
9679
9737
  value: data.dept_head_details[0].id,
@@ -9692,7 +9750,11 @@ function EditPanelDialog(_ref) {
9692
9750
  }, [rowData]);
9693
9751
  var history = useHistory();
9694
9752
  var handleAddPageNavigation = function handleAddPageNavigation() {
9695
- history.push(config.routes.users.add.path);
9753
+ console.log(rowData);
9754
+ history.push({
9755
+ pathname: config.routes.users.add.path,
9756
+ state: rowData
9757
+ });
9696
9758
  };
9697
9759
  return /*#__PURE__*/React.createElement(IUIModal, {
9698
9760
  isDisabledSubmitBtn: isDisabledSubmitBtn,