authscape-usermanagement 1.0.64 → 1.0.66
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 +101 -26
- package/package.json +1 -1
- package/src/CompanyEditor.js +71 -6
package/index.js
CHANGED
|
@@ -55,6 +55,7 @@ var CompanyEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
55
55
|
errors = _useForm.formState.errors,
|
|
56
56
|
watch = _useForm.watch,
|
|
57
57
|
setValue = _useForm.setValue;
|
|
58
|
+
var theme = (0, _material.useTheme)();
|
|
58
59
|
var _useState = (0, _react.useState)({}),
|
|
59
60
|
_useState2 = _slicedToArray(_useState, 2),
|
|
60
61
|
editors = _useState2[0],
|
|
@@ -95,30 +96,38 @@ var CompanyEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
95
96
|
setInputLocationValue = _useState18[1];
|
|
96
97
|
var _useState19 = (0, _react.useState)([]),
|
|
97
98
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var _useState21 = (0, _react.useState)(
|
|
99
|
+
domains = _useState20[0],
|
|
100
|
+
setDomains = _useState20[1];
|
|
101
|
+
var _useState21 = (0, _react.useState)(''),
|
|
101
102
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
var _useState23 = (0, _react.useState)(
|
|
103
|
+
domainInput = _useState22[0],
|
|
104
|
+
setDomainInput = _useState22[1];
|
|
105
|
+
var _useState23 = (0, _react.useState)([]),
|
|
105
106
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
customFields = _useState24[0],
|
|
108
|
+
setCustomFields = _useState24[1];
|
|
108
109
|
var _useState25 = (0, _react.useState)(null),
|
|
109
110
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
var _useState27 = (0, _react.useState)(
|
|
111
|
+
user = _useState26[0],
|
|
112
|
+
setUser = _useState26[1];
|
|
113
|
+
var _useState27 = (0, _react.useState)(null),
|
|
113
114
|
_useState28 = _slicedToArray(_useState27, 2),
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
customTabs = _useState28[0],
|
|
116
|
+
setCustomTabs = _useState28[1];
|
|
117
|
+
var _useState29 = (0, _react.useState)(null),
|
|
118
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
|
119
|
+
companyLogo = _useState30[0],
|
|
120
|
+
setCompanyLogo = _useState30[1];
|
|
121
|
+
var _useState31 = (0, _react.useState)([]),
|
|
122
|
+
_useState32 = _slicedToArray(_useState31, 2),
|
|
123
|
+
tabOptions = _useState32[0],
|
|
124
|
+
setTabOptions = _useState32[1];
|
|
116
125
|
var ITEM_HEIGHT = 48;
|
|
117
126
|
var ITEM_PADDING_TOP = 8;
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
tabValue =
|
|
121
|
-
setTabValue =
|
|
127
|
+
var _useState33 = (0, _react.useState)(0),
|
|
128
|
+
_useState34 = _slicedToArray(_useState33, 2),
|
|
129
|
+
tabValue = _useState34[0],
|
|
130
|
+
setTabValue = _useState34[1];
|
|
122
131
|
var handleTabChange = function handleTabChange(event, newValue) {
|
|
123
132
|
setTabValue(newValue);
|
|
124
133
|
};
|
|
@@ -138,6 +147,7 @@ var CompanyEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
138
147
|
if (response != null && response.status == 200) {
|
|
139
148
|
setCompanyLogo(response.data.logo);
|
|
140
149
|
setLocation(response.data.locations);
|
|
150
|
+
setDomains(response.data.emailDomains || []);
|
|
141
151
|
setCompany(response.data);
|
|
142
152
|
if (response.data.customFields != null) {
|
|
143
153
|
setCustomFields(response.data.customFields);
|
|
@@ -270,7 +280,13 @@ var CompanyEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
270
280
|
fetchData();
|
|
271
281
|
}
|
|
272
282
|
}, [companyId]);
|
|
273
|
-
return /*#__PURE__*/_react["default"].createElement(_system.Box,
|
|
283
|
+
return /*#__PURE__*/_react["default"].createElement(_system.Box, {
|
|
284
|
+
sx: {
|
|
285
|
+
backgroundColor: theme.palette.background["default"],
|
|
286
|
+
minHeight: '100vh',
|
|
287
|
+
color: theme.palette.text.primary
|
|
288
|
+
}
|
|
289
|
+
}, /*#__PURE__*/_react["default"].createElement("form", {
|
|
274
290
|
onSubmit: handleSubmit( /*#__PURE__*/function () {
|
|
275
291
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(data) {
|
|
276
292
|
var userCustomFields, response;
|
|
@@ -374,7 +390,8 @@ var CompanyEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
374
390
|
title: data.Title,
|
|
375
391
|
isDeactivated: !data.IsActive,
|
|
376
392
|
customFields: userCustomFields,
|
|
377
|
-
locations: location
|
|
393
|
+
locations: location,
|
|
394
|
+
domains: domains
|
|
378
395
|
});
|
|
379
396
|
case 4:
|
|
380
397
|
response = _context6.sent;
|
|
@@ -402,11 +419,14 @@ var CompanyEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
402
419
|
paddingTop: 2
|
|
403
420
|
}
|
|
404
421
|
}, /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
|
|
405
|
-
size:
|
|
422
|
+
size: {
|
|
423
|
+
xs: 12,
|
|
424
|
+
md: 4
|
|
425
|
+
},
|
|
406
426
|
sx: {
|
|
407
|
-
backgroundColor:
|
|
427
|
+
backgroundColor: theme.palette.background.paper,
|
|
408
428
|
borderRadius: 2,
|
|
409
|
-
border: "1px solid
|
|
429
|
+
border: "1px solid ".concat(theme.palette.divider),
|
|
410
430
|
padding: 2
|
|
411
431
|
}
|
|
412
432
|
}, /*#__PURE__*/_react["default"].createElement(_system.Box, {
|
|
@@ -416,7 +436,7 @@ var CompanyEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
416
436
|
justifyContent: "center",
|
|
417
437
|
padding: 2
|
|
418
438
|
}
|
|
419
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
439
|
+
}, /*#__PURE__*/_react["default"].createElement(DropZone, {
|
|
420
440
|
image: companyLogo != null ? companyLogo : "",
|
|
421
441
|
text: "Drag 'n' drop your logo here, or click to select your logo",
|
|
422
442
|
onDrop: /*#__PURE__*/function () {
|
|
@@ -543,13 +563,68 @@ var CompanyEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
543
563
|
color: option.isAddOption ? "primary" : "text.secondary"
|
|
544
564
|
}, option.title))));
|
|
545
565
|
}
|
|
566
|
+
}), /*#__PURE__*/_react["default"].createElement(_system.Box, {
|
|
567
|
+
sx: {
|
|
568
|
+
fontWeight: "bold",
|
|
569
|
+
paddingTop: 2,
|
|
570
|
+
paddingBottom: 1
|
|
571
|
+
}
|
|
572
|
+
}, "Email Domains"), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
573
|
+
variant: "caption",
|
|
574
|
+
color: "textSecondary",
|
|
575
|
+
sx: {
|
|
576
|
+
display: "block",
|
|
577
|
+
paddingBottom: 1
|
|
578
|
+
}
|
|
579
|
+
}, "Add email domains (e.g., example.org, example.com) to automatically map users to this company when they sign up"), /*#__PURE__*/_react["default"].createElement(_material.Autocomplete, {
|
|
580
|
+
id: "DomainSelect",
|
|
581
|
+
multiple: true,
|
|
582
|
+
freeSolo: true,
|
|
583
|
+
options: [],
|
|
584
|
+
value: domains,
|
|
585
|
+
onChange: function onChange(event, newValue) {
|
|
586
|
+
// Validate and format domains
|
|
587
|
+
var formattedDomains = newValue.map(function (domain) {
|
|
588
|
+
var formatted = domain.trim().toLowerCase();
|
|
589
|
+
// Add @ if not present
|
|
590
|
+
if (formatted && !formatted.startsWith('@')) {
|
|
591
|
+
formatted = '@' + formatted;
|
|
592
|
+
}
|
|
593
|
+
return formatted;
|
|
594
|
+
}).filter(function (domain) {
|
|
595
|
+
return domain.length > 1;
|
|
596
|
+
}); // Remove empty or just @ domains
|
|
597
|
+
|
|
598
|
+
setDomains(formattedDomains);
|
|
599
|
+
},
|
|
600
|
+
renderTags: function renderTags(value, getTagProps) {
|
|
601
|
+
return value.map(function (option, index) {
|
|
602
|
+
return /*#__PURE__*/_react["default"].createElement(_material.Chip, _extends({}, getTagProps({
|
|
603
|
+
index: index
|
|
604
|
+
}), {
|
|
605
|
+
label: option,
|
|
606
|
+
color: "primary",
|
|
607
|
+
variant: "outlined"
|
|
608
|
+
}));
|
|
609
|
+
});
|
|
610
|
+
},
|
|
611
|
+
renderInput: function renderInput(params) {
|
|
612
|
+
return /*#__PURE__*/_react["default"].createElement(_TextField["default"], _extends({}, params, {
|
|
613
|
+
label: "Email Domains",
|
|
614
|
+
placeholder: "Type domain and press Enter (e.g., example.org or example.com)",
|
|
615
|
+
fullWidth: true
|
|
616
|
+
}));
|
|
617
|
+
}
|
|
546
618
|
})), /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
|
|
547
619
|
item: true,
|
|
548
|
-
size:
|
|
620
|
+
size: {
|
|
621
|
+
xs: 12,
|
|
622
|
+
md: 8
|
|
623
|
+
},
|
|
549
624
|
sx: {
|
|
550
|
-
backgroundColor:
|
|
625
|
+
backgroundColor: theme.palette.background.paper,
|
|
551
626
|
borderRadius: 2,
|
|
552
|
-
border: "1px solid
|
|
627
|
+
border: "1px solid ".concat(theme.palette.divider),
|
|
553
628
|
padding: 2
|
|
554
629
|
}
|
|
555
630
|
}, /*#__PURE__*/_react["default"].createElement(_material.Stack, {
|
package/package.json
CHANGED
package/src/CompanyEditor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, {useEffect, useState, useRef, useImperativeHandle, forwardRef } from 'react';
|
|
2
2
|
import { Box } from '@mui/system';
|
|
3
|
-
import { Autocomplete, Avatar, Button, Chip, Drawer } from '@mui/material';
|
|
3
|
+
import { Autocomplete, Avatar, Button, Chip, Drawer, useTheme } from '@mui/material';
|
|
4
4
|
import { useForm, Controller } from 'react-hook-form';
|
|
5
5
|
import { Tab, Tabs, Stack } from '@mui/material';
|
|
6
6
|
import { apiService } from 'authscape';
|
|
@@ -8,7 +8,6 @@ import TextField from '@mui/material/TextField';
|
|
|
8
8
|
import BusinessRoundedIcon from '@mui/icons-material/BusinessRounded';
|
|
9
9
|
import Typography from '@mui/material/Typography';
|
|
10
10
|
import Grid from '@mui/material/Grid2';
|
|
11
|
-
import { DropZone } from 'authscape';
|
|
12
11
|
|
|
13
12
|
// remove when publishing
|
|
14
13
|
// import {renderCustomField, renderSystemField } from './EditorFields';
|
|
@@ -18,6 +17,7 @@ import { DropZone } from 'authscape';
|
|
|
18
17
|
const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = null, onCustomTabs = null}, ref) => {
|
|
19
18
|
|
|
20
19
|
const {control, register, handleSubmit, formState: { errors }, watch, setValue } = useForm();
|
|
20
|
+
const theme = useTheme();
|
|
21
21
|
|
|
22
22
|
const [editors, setEditors] = useState({});
|
|
23
23
|
|
|
@@ -36,6 +36,9 @@ const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = nul
|
|
|
36
36
|
const [location, setLocation] = useState({});
|
|
37
37
|
const [inputLocationValue, setInputLocationValue] = useState('');
|
|
38
38
|
|
|
39
|
+
const [domains, setDomains] = useState([]);
|
|
40
|
+
const [domainInput, setDomainInput] = useState('');
|
|
41
|
+
|
|
39
42
|
const [customFields, setCustomFields] = useState([]);
|
|
40
43
|
|
|
41
44
|
const [user, setUser] = useState(null);
|
|
@@ -65,6 +68,7 @@ const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = nul
|
|
|
65
68
|
setCompanyLogo(response.data.logo);
|
|
66
69
|
|
|
67
70
|
setLocation(response.data.locations);
|
|
71
|
+
setDomains(response.data.emailDomains || []);
|
|
68
72
|
setCompany(response.data);
|
|
69
73
|
|
|
70
74
|
if (response.data.customFields != null)
|
|
@@ -162,7 +166,11 @@ const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = nul
|
|
|
162
166
|
}, [companyId]);
|
|
163
167
|
|
|
164
168
|
return (
|
|
165
|
-
<Box
|
|
169
|
+
<Box sx={{
|
|
170
|
+
backgroundColor: theme.palette.background.default,
|
|
171
|
+
minHeight: '100vh',
|
|
172
|
+
color: theme.palette.text.primary
|
|
173
|
+
}}>
|
|
166
174
|
|
|
167
175
|
<form onSubmit={handleSubmit(async (data) => {
|
|
168
176
|
|
|
@@ -242,7 +250,8 @@ const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = nul
|
|
|
242
250
|
title: data.Title,
|
|
243
251
|
isDeactivated: !data.IsActive,
|
|
244
252
|
customFields: userCustomFields,
|
|
245
|
-
locations: location
|
|
253
|
+
locations: location,
|
|
254
|
+
domains: domains
|
|
246
255
|
});
|
|
247
256
|
|
|
248
257
|
if (response != null && response.status == 200)
|
|
@@ -256,7 +265,12 @@ const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = nul
|
|
|
256
265
|
})} noValidate autoComplete="off">
|
|
257
266
|
|
|
258
267
|
<Grid container spacing={2} sx={{paddingTop:2}}>
|
|
259
|
-
<Grid size={
|
|
268
|
+
<Grid size={{ xs: 12, md: 4 }} sx={{
|
|
269
|
+
backgroundColor: theme.palette.background.paper,
|
|
270
|
+
borderRadius: 2,
|
|
271
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
272
|
+
padding: 2
|
|
273
|
+
}}>
|
|
260
274
|
<Box sx={{textAlign:"center", display:"flex", justifyContent:"center", padding:2 }}>
|
|
261
275
|
|
|
262
276
|
<DropZone image={companyLogo != null ? companyLogo : ""} text={"Drag 'n' drop your logo here, or click to select your logo"} onDrop={async (blob) => {
|
|
@@ -347,9 +361,60 @@ const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = nul
|
|
|
347
361
|
)}
|
|
348
362
|
/>
|
|
349
363
|
|
|
364
|
+
<Box sx={{fontWeight:"bold", paddingTop:2, paddingBottom: 1}}>
|
|
365
|
+
Email Domains
|
|
366
|
+
</Box>
|
|
367
|
+
<Typography variant="caption" color="textSecondary" sx={{display:"block", paddingBottom: 1}}>
|
|
368
|
+
Add email domains (e.g., example.org, example.com) to automatically map users to this company when they sign up
|
|
369
|
+
</Typography>
|
|
370
|
+
|
|
371
|
+
<Autocomplete
|
|
372
|
+
id="DomainSelect"
|
|
373
|
+
multiple
|
|
374
|
+
freeSolo
|
|
375
|
+
options={[]}
|
|
376
|
+
value={domains}
|
|
377
|
+
onChange={(event, newValue) => {
|
|
378
|
+
// Validate and format domains
|
|
379
|
+
const formattedDomains = newValue.map(domain => {
|
|
380
|
+
let formatted = domain.trim().toLowerCase();
|
|
381
|
+
// Add @ if not present
|
|
382
|
+
if (formatted && !formatted.startsWith('@')) {
|
|
383
|
+
formatted = '@' + formatted;
|
|
384
|
+
}
|
|
385
|
+
return formatted;
|
|
386
|
+
}).filter(domain => domain.length > 1); // Remove empty or just @ domains
|
|
387
|
+
|
|
388
|
+
setDomains(formattedDomains);
|
|
389
|
+
}}
|
|
390
|
+
renderTags={(value, getTagProps) =>
|
|
391
|
+
value.map((option, index) => (
|
|
392
|
+
<Chip
|
|
393
|
+
{...getTagProps({ index })}
|
|
394
|
+
label={option}
|
|
395
|
+
color="primary"
|
|
396
|
+
variant="outlined"
|
|
397
|
+
/>
|
|
398
|
+
))
|
|
399
|
+
}
|
|
400
|
+
renderInput={(params) => (
|
|
401
|
+
<TextField
|
|
402
|
+
{...params}
|
|
403
|
+
label="Email Domains"
|
|
404
|
+
placeholder="Type domain and press Enter (e.g., example.org or example.com)"
|
|
405
|
+
fullWidth
|
|
406
|
+
/>
|
|
407
|
+
)}
|
|
408
|
+
/>
|
|
409
|
+
|
|
350
410
|
|
|
351
411
|
</Grid>
|
|
352
|
-
<Grid item size={
|
|
412
|
+
<Grid item size={{ xs: 12, md: 8 }} sx={{
|
|
413
|
+
backgroundColor: theme.palette.background.paper,
|
|
414
|
+
borderRadius: 2,
|
|
415
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
416
|
+
padding: 2
|
|
417
|
+
}}>
|
|
353
418
|
<Stack spacing={2}>
|
|
354
419
|
<Box>
|
|
355
420
|
<Tabs value={tabValue} onChange={handleTabChange} variant="fullWidth" aria-label="basic tabs example" centered>
|