authscape-usermanagement 1.0.62 → 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 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
- customFields = _useState20[0],
99
- setCustomFields = _useState20[1];
100
- var _useState21 = (0, _react.useState)(null),
99
+ domains = _useState20[0],
100
+ setDomains = _useState20[1];
101
+ var _useState21 = (0, _react.useState)(''),
101
102
  _useState22 = _slicedToArray(_useState21, 2),
102
- user = _useState22[0],
103
- setUser = _useState22[1];
104
- var _useState23 = (0, _react.useState)(null),
103
+ domainInput = _useState22[0],
104
+ setDomainInput = _useState22[1];
105
+ var _useState23 = (0, _react.useState)([]),
105
106
  _useState24 = _slicedToArray(_useState23, 2),
106
- customTabs = _useState24[0],
107
- setCustomTabs = _useState24[1];
107
+ customFields = _useState24[0],
108
+ setCustomFields = _useState24[1];
108
109
  var _useState25 = (0, _react.useState)(null),
109
110
  _useState26 = _slicedToArray(_useState25, 2),
110
- companyLogo = _useState26[0],
111
- setCompanyLogo = _useState26[1];
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
- tabOptions = _useState28[0],
115
- setTabOptions = _useState28[1];
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 _useState29 = (0, _react.useState)(0),
119
- _useState30 = _slicedToArray(_useState29, 2),
120
- tabValue = _useState30[0],
121
- setTabValue = _useState30[1];
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, null, /*#__PURE__*/_react["default"].createElement("form", {
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: 4,
422
+ size: {
423
+ xs: 12,
424
+ md: 4
425
+ },
406
426
  sx: {
407
- backgroundColor: "#f5f8fa",
427
+ backgroundColor: theme.palette.background.paper,
408
428
  borderRadius: 2,
409
- border: "1px solid lightgray",
429
+ border: "1px solid ".concat(theme.palette.divider),
410
430
  padding: 2
411
431
  }
412
432
  }, /*#__PURE__*/_react["default"].createElement(_system.Box, {
@@ -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: 8,
620
+ size: {
621
+ xs: 12,
622
+ md: 8
623
+ },
549
624
  sx: {
550
- backgroundColor: "#f5f8fa",
625
+ backgroundColor: theme.palette.background.paper,
551
626
  borderRadius: 2,
552
- border: "1px solid lightgray",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape-usermanagement",
3
- "version": "1.0.62",
3
+ "version": "1.0.66",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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';
@@ -17,6 +17,7 @@ import Grid from '@mui/material/Grid2';
17
17
  const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = null, onCustomTabs = null}, ref) => {
18
18
 
19
19
  const {control, register, handleSubmit, formState: { errors }, watch, setValue } = useForm();
20
+ const theme = useTheme();
20
21
 
21
22
  const [editors, setEditors] = useState({});
22
23
 
@@ -35,6 +36,9 @@ const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = nul
35
36
  const [location, setLocation] = useState({});
36
37
  const [inputLocationValue, setInputLocationValue] = useState('');
37
38
 
39
+ const [domains, setDomains] = useState([]);
40
+ const [domainInput, setDomainInput] = useState('');
41
+
38
42
  const [customFields, setCustomFields] = useState([]);
39
43
 
40
44
  const [user, setUser] = useState(null);
@@ -64,6 +68,7 @@ const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = nul
64
68
  setCompanyLogo(response.data.logo);
65
69
 
66
70
  setLocation(response.data.locations);
71
+ setDomains(response.data.emailDomains || []);
67
72
  setCompany(response.data);
68
73
 
69
74
  if (response.data.customFields != null)
@@ -161,7 +166,11 @@ const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = nul
161
166
  }, [companyId]);
162
167
 
163
168
  return (
164
- <Box>
169
+ <Box sx={{
170
+ backgroundColor: theme.palette.background.default,
171
+ minHeight: '100vh',
172
+ color: theme.palette.text.primary
173
+ }}>
165
174
 
166
175
  <form onSubmit={handleSubmit(async (data) => {
167
176
 
@@ -241,7 +250,8 @@ const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = nul
241
250
  title: data.Title,
242
251
  isDeactivated: !data.IsActive,
243
252
  customFields: userCustomFields,
244
- locations: location
253
+ locations: location,
254
+ domains: domains
245
255
  });
246
256
 
247
257
  if (response != null && response.status == 200)
@@ -255,7 +265,12 @@ const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = nul
255
265
  })} noValidate autoComplete="off">
256
266
 
257
267
  <Grid container spacing={2} sx={{paddingTop:2}}>
258
- <Grid size={4} sx={{backgroundColor:"#f5f8fa", borderRadius:2, border: "1px solid lightgray", padding:2}}>
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
+ }}>
259
274
  <Box sx={{textAlign:"center", display:"flex", justifyContent:"center", padding:2 }}>
260
275
 
261
276
  <DropZone image={companyLogo != null ? companyLogo : ""} text={"Drag 'n' drop your logo here, or click to select your logo"} onDrop={async (blob) => {
@@ -346,9 +361,60 @@ const CompanyEditor = forwardRef(({companyId = null, platformType, onSaved = nul
346
361
  )}
347
362
  />
348
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
+
349
410
 
350
411
  </Grid>
351
- <Grid item size={8} sx={{backgroundColor:"#f5f8fa", borderRadius:2, border: "1px solid lightgray", padding:2}}>
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
+ }}>
352
418
  <Stack spacing={2}>
353
419
  <Box>
354
420
  <Tabs value={tabValue} onChange={handleTabChange} variant="fullWidth" aria-label="basic tabs example" centered>