authscape-usermanagement 1.0.24 → 1.0.26

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.
package/index.js CHANGED
@@ -239,8 +239,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
239
239
  function UserEditor(_ref) {
240
240
  var _ref$userId = _ref.userId,
241
241
  userId = _ref$userId === void 0 ? null : _ref$userId,
242
- _ref$customFields = _ref.customFields,
243
- customFields = _ref$customFields === void 0 ? null : _ref$customFields,
244
242
  _ref$onSaved = _ref.onSaved,
245
243
  onSaved = _ref$onSaved === void 0 ? null : _ref$onSaved,
246
244
  _ref$onPasswordChange = _ref.onPasswordChanged,
@@ -292,10 +290,14 @@ function UserEditor(_ref) {
292
290
  _useState20 = _slicedToArray(_useState19, 2),
293
291
  permissions = _useState20[0],
294
292
  setPermissions = _useState20[1];
295
- var _useState21 = (0, _react.useState)(null),
293
+ var _useState21 = (0, _react.useState)([]),
296
294
  _useState22 = _slicedToArray(_useState21, 2),
297
- user = _useState22[0],
298
- setUser = _useState22[1];
295
+ customFields = _useState22[0],
296
+ setCustomFields = _useState22[1];
297
+ var _useState23 = (0, _react.useState)(null),
298
+ _useState24 = _slicedToArray(_useState23, 2),
299
+ user = _useState24[0],
300
+ setUser = _useState24[1];
299
301
  var ITEM_HEIGHT = 48;
300
302
  var ITEM_PADDING_TOP = 8;
301
303
  var MenuProps = {
@@ -306,18 +308,18 @@ function UserEditor(_ref) {
306
308
  }
307
309
  }
308
310
  };
309
- var _useState23 = (0, _react.useState)(""),
310
- _useState24 = _slicedToArray(_useState23, 2),
311
- newPassword = _useState24[0],
312
- setNewPassword = _useState24[1];
313
311
  var _useState25 = (0, _react.useState)(""),
314
312
  _useState26 = _slicedToArray(_useState25, 2),
315
- confirmPassword = _useState26[0],
316
- setConfirmPassword = _useState26[1];
317
- var _useState27 = (0, _react.useState)(0),
313
+ newPassword = _useState26[0],
314
+ setNewPassword = _useState26[1];
315
+ var _useState27 = (0, _react.useState)(""),
318
316
  _useState28 = _slicedToArray(_useState27, 2),
319
- tabValue = _useState28[0],
320
- setTabValue = _useState28[1];
317
+ confirmPassword = _useState28[0],
318
+ setConfirmPassword = _useState28[1];
319
+ var _useState29 = (0, _react.useState)(0),
320
+ _useState30 = _slicedToArray(_useState29, 2),
321
+ tabValue = _useState30[0],
322
+ setTabValue = _useState30[1];
321
323
  var handleTabChange = function handleTabChange(event, newValue) {
322
324
  setTabValue(newValue);
323
325
  };
@@ -374,6 +376,9 @@ function UserEditor(_ref) {
374
376
  if (response.data.location != null) {
375
377
  setLocation(response.data.location);
376
378
  }
379
+ if (response.data.userCustomFields != null) {
380
+ setCustomFields(response.data.userCustomFields);
381
+ }
377
382
 
378
383
  // assign all selected roles
379
384
  if (response.data.roles != null) {
@@ -440,7 +445,7 @@ function UserEditor(_ref) {
440
445
  item: true,
441
446
  xs: 6
442
447
  }, /*#__PURE__*/_react["default"].createElement(_reactHookForm.Controller, {
443
- name: field.name,
448
+ name: field.customFieldId,
444
449
  control: control,
445
450
  rules: {
446
451
  required: field.isRequired
@@ -453,7 +458,7 @@ function UserEditor(_ref) {
453
458
  defaultValue: result,
454
459
  margin: "normal",
455
460
  fullWidth: true
456
- }, register(field.name, {
461
+ }, register(field.customFieldId, {
457
462
  required: field.isRequired
458
463
  }), renderField));
459
464
  }
@@ -620,8 +625,11 @@ function UserEditor(_ref) {
620
625
  userCustomFields = [];
621
626
  customFields && customFields.forEach(function (customField) {
622
627
  userCustomFields.push({
628
+ customFieldId: customField.customFieldId,
623
629
  name: customField.name,
624
- value: data[customField.name]
630
+ isRequired: customField.isRequired,
631
+ customFieldType: customField.customFieldType,
632
+ value: data[customField.customFieldId]
625
633
  });
626
634
  });
627
635
  _context5.next = 4;
@@ -1012,9 +1020,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1012
1020
  // import { UserEditor } from './UserEditor'; // remove when done
1013
1021
  // import { CSVUsersUpload } from './CSVUsersUpload'; // remove when done
1014
1022
  function UserManagement(_ref) {
1015
- var _ref$customFields = _ref.customFields,
1016
- customFields = _ref$customFields === void 0 ? null : _ref$customFields,
1017
- _ref$height = _ref.height,
1023
+ var _ref$height = _ref.height,
1018
1024
  height = _ref$height === void 0 ? "50vh" : _ref$height,
1019
1025
  _ref$onUploadComplete = _ref.onUploadCompleted,
1020
1026
  onUploadCompleted = _ref$onUploadComplete === void 0 ? null : _ref$onUploadComplete,
@@ -1202,14 +1208,12 @@ function UserManagement(_ref) {
1202
1208
  }
1203
1209
  }, /*#__PURE__*/_react["default"].createElement(UserEditor, {
1204
1210
  userId: showUserDetails,
1205
- customFields: customFields,
1206
1211
  onPasswordChanged: onPasswordChanged,
1207
1212
  onSaved: function onSaved() {
1208
1213
  setDataGridRefreshKey(dataGridRefreshKey + 1);
1209
1214
  setShowUserDetails(null);
1210
1215
  }
1211
1216
  }))))), /*#__PURE__*/_react["default"].createElement(CSVUsersUpload, {
1212
- customFields: customFields,
1213
1217
  showDialog: uploadUsersShowDialog,
1214
1218
  onClose: function onClose() {
1215
1219
  setUploadUsersShowDialog(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape-usermanagement",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/UserEditor.js CHANGED
@@ -17,7 +17,7 @@ import { Tab, Tabs } from '@mui/material';
17
17
  import BusinessRoundedIcon from '@mui/icons-material/BusinessRounded';
18
18
  import { apiService } from 'authscape';
19
19
 
20
- export function UserEditor({userId = null, customFields = null, onSaved = null, onPasswordChanged = null}) {
20
+ export function UserEditor({userId = null, onSaved = null, onPasswordChanged = null}) {
21
21
 
22
22
  const {control, register, handleSubmit, formState: { errors }, watch, setValue } = useForm();
23
23
 
@@ -35,6 +35,8 @@ export function UserEditor({userId = null, customFields = null, onSaved = null,
35
35
  const [roles, setRole] = useState([]);
36
36
  const [permissions, setPermissions] = useState([]);
37
37
 
38
+ const [customFields, setCustomFields] = useState([]);
39
+
38
40
  const [user, setUser] = useState(null);
39
41
 
40
42
  const ITEM_HEIGHT = 48;
@@ -100,6 +102,11 @@ export function UserEditor({userId = null, customFields = null, onSaved = null,
100
102
  setLocation(response.data.location);
101
103
  }
102
104
 
105
+ if (response.data.userCustomFields != null)
106
+ {
107
+ setCustomFields(response.data.userCustomFields);
108
+ }
109
+
103
110
  // assign all selected roles
104
111
  if (response.data.roles != null)
105
112
  {
@@ -189,7 +196,7 @@ export function UserEditor({userId = null, customFields = null, onSaved = null,
189
196
 
190
197
  return (
191
198
  <Grid item xs={6}>
192
- <Controller name={field.name}
199
+ <Controller name={field.customFieldId}
193
200
  control={control}
194
201
  rules={{
195
202
  required: field.isRequired,
@@ -201,7 +208,7 @@ export function UserEditor({userId = null, customFields = null, onSaved = null,
201
208
  defaultValue={result}
202
209
  margin="normal"
203
210
  fullWidth
204
- {...register(field.name, { required: field.isRequired })}
211
+ {...register(field.customFieldId, { required: field.isRequired })}
205
212
  {...renderField}
206
213
  />
207
214
  }
@@ -353,8 +360,11 @@ export function UserEditor({userId = null, customFields = null, onSaved = null,
353
360
  customFields && customFields.forEach(customField => {
354
361
 
355
362
  userCustomFields.push({
363
+ customFieldId: customField.customFieldId,
356
364
  name: customField.name,
357
- value: data[customField.name]
365
+ isRequired: customField.isRequired,
366
+ customFieldType: customField.customFieldType,
367
+ value: data[customField.customFieldId]
358
368
  });
359
369
  });
360
370
 
@@ -1,6 +1,6 @@
1
- import React, {useEffect, useState} from 'react';
1
+ import React, {useEffect, useState, useRef} from 'react';
2
2
  import { Box } from '@mui/system';
3
- import { Avatar, Button, Drawer, Grid } from '@mui/material';
3
+ import { Avatar, Button, Drawer, Grid, Stack, TextField, Typography } from '@mui/material';
4
4
  import IconButton from '@mui/material/IconButton';
5
5
  import UploadRoundedIcon from '@mui/icons-material/UploadRounded';
6
6
  import CloseRoundedIcon from '@mui/icons-material/CloseRounded';
@@ -8,7 +8,7 @@ import { EditableDatagrid, FileUploader, AutoSaveTextField, apiService } from 'a
8
8
  // import { UserEditor } from './UserEditor'; // remove when done
9
9
  // import { CSVUsersUpload } from './CSVUsersUpload'; // remove when done
10
10
 
11
- export default function UserManagement({customFields = null, height = "50vh", onUploadCompleted = null, onPasswordChanged = null}) {
11
+ export default function UserManagement({height = "50vh", onUploadCompleted = null, onPasswordChanged = null}) {
12
12
 
13
13
  const [showUserDetails, setShowUserDetails] = useState(null);
14
14
 
@@ -151,7 +151,6 @@ export default function UserManagement({customFields = null, height = "50vh", on
151
151
 
152
152
  <UserEditor
153
153
  userId={showUserDetails}
154
- customFields={customFields}
155
154
  onPasswordChanged={onPasswordChanged}
156
155
  onSaved={() => {
157
156
 
@@ -168,7 +167,7 @@ export default function UserManagement({customFields = null, height = "50vh", on
168
167
  </Drawer>
169
168
  </Box>
170
169
 
171
- <CSVUsersUpload customFields={customFields} showDialog={uploadUsersShowDialog} onClose={() => {
170
+ <CSVUsersUpload showDialog={uploadUsersShowDialog} onClose={() => {
172
171
  setUploadUsersShowDialog(false);
173
172
  }} />
174
173