@itilite/iui-user-management 0.4.35 → 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';
@@ -1767,7 +1767,7 @@ var verifyUserInfo = function verifyUserInfo(userId) {
1767
1767
  var submitAddModalData = function submitAddModalData(tableName, data) {
1768
1768
  return function (dispatch) {
1769
1769
  return new Promise(function (resolve, reject) {
1770
- 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) {
1771
1771
  resolve(res);
1772
1772
  })["catch"](function (err) {
1773
1773
  var _err$response17, _err$response17$data;
@@ -4871,6 +4871,7 @@ var UserAddEdit = function UserAddEdit(props) {
4871
4871
  isILadmin = _useSelector2.isILadmin,
4872
4872
  companyName = _useSelector2.companyName;
4873
4873
  var history = useHistory();
4874
+ var location = useLocation();
4874
4875
  var _useState = useState({
4875
4876
  travel: false,
4876
4877
  expense: false
@@ -5126,6 +5127,18 @@ var UserAddEdit = function UserAddEdit(props) {
5126
5127
  var onAddModalClose = function onAddModalClose() {
5127
5128
  setAddModalData(_extends({}, defaultAddModalData));
5128
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
+ }, []);
5129
5142
  var onModalOpen = function onModalOpen(e, id) {
5130
5143
  var title = '';
5131
5144
  if (id === 'entity') {
@@ -5151,9 +5164,18 @@ var UserAddEdit = function UserAddEdit(props) {
5151
5164
  }));
5152
5165
  } else {
5153
5166
  dispatch(showLoader());
5154
- dispatch(submitAddModalData(addModalData.id, {
5155
- names: [validatedValue]
5156
- })).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) {
5157
5179
  var _extends2, _extends3;
5158
5180
  setAddModalData(_extends({}, addModalData, {
5159
5181
  isOpen: false
@@ -5161,8 +5183,8 @@ var UserAddEdit = function UserAddEdit(props) {
5161
5183
  IUIToastMessageService$4.sNotify(addModalData.title + " added successfully.");
5162
5184
  var tempKey = addModalData.id === 'employee_level' ? 'emp_level' : addModalData.id;
5163
5185
  setEmployeeInfoInput(_extends({}, employeeInfoInput, (_extends2 = {}, _extends2[tempKey] = {
5164
- value: res.data.value,
5165
- label: res.data.label
5186
+ value: res.data.result.id,
5187
+ label: res.data.result.name
5166
5188
  }, _extends2)));
5167
5189
  updateInputChangeLog(_extends({}, inputChangeLog, (_extends3 = {}, _extends3[tempKey] = true, _extends3)));
5168
5190
  asyncSelectRefs.current[tempKey].current.blur();
@@ -5302,6 +5324,7 @@ var UserAddEdit = function UserAddEdit(props) {
5302
5324
  var _extends11;
5303
5325
  var _name = _ref3._name,
5304
5326
  _value = _ref3._value;
5327
+ console.log(_name, _value, 'travel');
5305
5328
  setTravelApproversInput(_extends({}, travelApproversInput, (_extends11 = {}, _extends11[_name] = _value, _extends11)));
5306
5329
  };
5307
5330
  var onExpenseApproversInputChange = function onExpenseApproversInputChange(_ref4) {
@@ -9521,7 +9544,6 @@ function Listview(_ref) {
9521
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) {
9522
9545
  return data.dept_head_details[0].first_name + ' ' + data.dept_head_details[0].last_name;
9523
9546
  }
9524
- return 'Unassigned';
9525
9547
  };
9526
9548
  var columns = [{
9527
9549
  id: 'name',
@@ -9710,7 +9732,6 @@ function EditPanelDialog(_ref) {
9710
9732
  dialogData = _useSelector.dialogData;
9711
9733
  var deptHeadDetails = function deptHeadDetails(data) {
9712
9734
  var _data$dept_head_detai;
9713
- console.log(data);
9714
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) {
9715
9736
  setHead({
9716
9737
  value: data.dept_head_details[0].id,
@@ -9729,7 +9750,11 @@ function EditPanelDialog(_ref) {
9729
9750
  }, [rowData]);
9730
9751
  var history = useHistory();
9731
9752
  var handleAddPageNavigation = function handleAddPageNavigation() {
9732
- 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
+ });
9733
9758
  };
9734
9759
  return /*#__PURE__*/React.createElement(IUIModal, {
9735
9760
  isDisabledSubmitBtn: isDisabledSubmitBtn,