authscape 1.0.550 → 1.0.554

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.
@@ -1,113 +1,152 @@
1
1
  import React, {useEffect, useState, useRef} from 'react';
2
2
  import { Box } from '@mui/system';
3
- import { Button, Grid } from '@mui/material';
4
- import Stack from '@mui/material/Stack';
5
- import Table from '@mui/material/Table';
6
- import TableBody from '@mui/material/TableBody';
7
- import TableCell from '@mui/material/TableCell';
8
- import TableContainer from '@mui/material/TableContainer';
9
- import TableHead from '@mui/material/TableHead';
10
- import TableRow from '@mui/material/TableRow';
11
- import Paper from '@mui/material/Paper';
12
- // import { FileUploader, apiService } from 'authscape';
13
- import EditRoundedIcon from '@mui/icons-material/EditRounded';
14
- import DeleteForeverRoundedIcon from '@mui/icons-material/DeleteForeverRounded';
3
+ import { Avatar, Button, Drawer, Grid } from '@mui/material';
15
4
  import IconButton from '@mui/material/IconButton';
16
5
  import UploadRoundedIcon from '@mui/icons-material/UploadRounded';
17
-
6
+ import CloseRoundedIcon from '@mui/icons-material/CloseRounded';
18
7
  import Dialog from '@mui/material/Dialog';
19
8
  import DialogActions from '@mui/material/DialogActions';
20
9
  import DialogContent from '@mui/material/DialogContent';
21
10
  import DialogContentText from '@mui/material/DialogContentText';
22
11
  import DialogTitle from '@mui/material/DialogTitle';
23
12
 
24
- // import { UserEditor } from '../../components/users/userEditor';
25
-
26
13
  export function UserManagement({customFields = null, onUploadCompleted = null}) {
27
14
 
28
15
  const [showUserDetails, setShowUserDetails] = useState(null);
29
- const [newUserDialog, setNewUserDialog] = useState(false);
30
- const [users, setUsers] = useState([]);
31
16
 
17
+ const [dataGridRefreshKey, setDataGridRefreshKey] = useState(0);
32
18
  const [uploadUsersShowDialog, setUploadUsersShowDialog] = useState(false);
33
19
 
34
- useEffect(() => {
35
20
 
36
- const fetchData = async () => {
37
- let response = await apiService().get("/UserManagement/GetUsers");
38
- if (response != null && response.status == 200)
39
- {
40
- setUsers(response.data);
21
+ const userColumns = [
22
+ {
23
+ field: 'fullName',
24
+ headerName: 'Full name',
25
+ flex: 1,
26
+ renderCell: (param) => {
27
+ return param.row.firstName + " " + param.row.lastName;
41
28
  }
42
- }
43
- fetchData();
44
-
45
- }, []);
29
+ },
30
+ { field: 'userName', flex:1, headerName: 'Email', editable: false, headerClassName: 'invoiceHeaderColumn' },
31
+ {
32
+ field: 'company',
33
+ headerName: 'Company',
34
+ flex: 1,
35
+ renderCell: (param) => {
36
+ return param.row.company != null ? param.row.company.title : "";
37
+ }
38
+ },
39
+ {
40
+ field: 'location',
41
+ headerName: 'Location',
42
+ flex: 1,
43
+ renderCell: (param) => {
44
+ return param.row.location != null ? param.row.location.title : "";
45
+ }
46
+ },
47
+ {
48
+ field: 'isActive',
49
+ headerName: 'Status',
50
+ flex: 1,
51
+ renderCell: (param) => {
52
+ return param.row.isActive ? "Active" : "Not Active";
53
+ }
54
+ },
55
+ {
56
+ field: 'roles',
57
+ headerName: 'Roles',
58
+ flex: 1,
59
+ renderCell: (param) => {
60
+ return param.row.roles;
61
+ }
62
+ },
63
+ {
64
+ field: 'permission',
65
+ headerName: 'Permission',
66
+ flex: 1,
67
+ renderCell: (param) => {
68
+ return param.row.permissions;
69
+ }
70
+ },
71
+ ];
46
72
 
47
73
  return (
48
74
  <Box>
49
75
 
50
- <Stack direction="row" spacing={1} sx={{paddingTop:2}}>
76
+
77
+ <Box sx={{textAlign:"right"}}>
51
78
  <Button variant="contained" sx={{width:200}} onClick={async () => {
52
79
 
53
- setNewUserDialog(true);
80
+ setShowUserDetails(-1);
54
81
 
55
82
  }}>Add User</Button>
56
83
 
57
- <Button startIcon={<UploadRoundedIcon/>} variant="contained" sx={{width:200}} onClick={async () => {
84
+
85
+ <Button startIcon={<UploadRoundedIcon/>} variant="contained" sx={{width:200, marginLeft:2}} onClick={async () => {
58
86
  setUploadUsersShowDialog(true);
59
87
  }}>Upload Users</Button>
88
+ </Box>
89
+
90
+ <Box>
91
+ <EditableDatagrid
92
+ key={dataGridRefreshKey}
93
+ pageSize={25}
94
+ // rowsPerPage={[25]}
95
+ url={"/UserManagement/GetUsers"}
96
+ columns={userColumns}
97
+ params={{
98
+ // invoiceId: invoiceId
99
+ }}
100
+ onRowClick={(row) => {
101
+
102
+ setShowUserDetails(row.id);
103
+ }} />
104
+
105
+ <Drawer
106
+ anchor={"right"}
107
+ fullWidth={true}
108
+ width={800}
109
+ open={showUserDetails != null ? true : false}
110
+ onClose={() => {
111
+ setShowUserDetails(null);
112
+ }}>
113
+
114
+ <IconButton size="large" sx={{position:"absolute", right: 10, top: 6}} onClick={() => {
115
+ setShowUserDetails(null);
116
+ }}>
117
+ <CloseRoundedIcon />
118
+ </IconButton>
119
+
120
+ <Grid item xs={12}>
121
+ <Box sx={{padding:2}}>
122
+ User Information
123
+ </Box>
124
+ <hr />
125
+
126
+ <Box sx={{textAlign:"center", display:"flex", justifyContent:"center", padding:2 }}>
127
+ <Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" sx={{ width: 100, height: 100 }} />
128
+ </Box>
129
+
130
+ <Box sx={{ width: '100%' }}>
131
+
132
+
133
+ <UserEditor
134
+ userId={showUserDetails}
135
+ customFields={customFields}
136
+ onSaved={() => {
137
+
138
+ setDataGridRefreshKey(dataGridRefreshKey + 1);
139
+ setShowUserDetails(null);
140
+ }}
141
+ />
60
142
 
61
- </Stack>
62
-
63
- <TableContainer component={Paper} sx={{marginTop:2}}>
64
- <Table sx={{ minWidth: 650 }} aria-label="simple table">
65
- <TableHead>
66
- <TableRow>
67
- <TableCell>Full Name</TableCell>
68
- <TableCell>Email</TableCell>
69
- <TableCell>Company Name</TableCell>
70
- <TableCell>Roles</TableCell>
71
- <TableCell>Permissions</TableCell>
72
- <TableCell>Actions</TableCell>
73
- </TableRow>
74
- </TableHead>
75
- <TableBody>
76
- {users.map((row) => (
77
- <TableRow key={row.id} sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
78
- <TableCell component="th" scope="row">
79
- {row.firstName} {row.lastName}
80
- </TableCell>
81
- <TableCell component="th" scope="row">
82
- {row.userName}
83
- </TableCell>
84
- <TableCell component="th" scope="row">
85
- {row.company.title}
86
- </TableCell>
87
- <TableCell component="th" scope="row">
88
- {row.roles}
89
- </TableCell>
90
- <TableCell component="th" scope="row">
91
- {row.permissions}
92
- </TableCell>
93
- <TableCell component="th" scope="row">
94
-
95
- <IconButton aria-label="delete" size="large" onClick={() => {
96
- setShowUserDetails(row.id);
97
- }}>
98
- <EditRoundedIcon fontSize="inherit" />
99
- </IconButton>
100
-
101
- <IconButton aria-label="delete" size="large">
102
- <DeleteForeverRoundedIcon fontSize="inherit" />
103
- </IconButton>
104
-
105
- </TableCell>
106
- </TableRow>
107
- ))}
108
- </TableBody>
109
- </Table>
110
- </TableContainer>
143
+
144
+ </Box>
145
+
146
+ </Grid>
147
+
148
+ </Drawer>
149
+ </Box>
111
150
 
112
151
  <Dialog
113
152
  open={uploadUsersShowDialog}
@@ -142,26 +181,6 @@ export function UserManagement({customFields = null, onUploadCompleted = null})
142
181
  </DialogActions>
143
182
  </Dialog>
144
183
 
145
-
146
- <Dialog
147
- open={showUserDetails != null ? true : false}
148
- onClose={() => {
149
- setShowUserDetails(null);
150
- }}
151
- maxWidth={"xl"}
152
- fullWidth={true}>
153
- <DialogContent>
154
- <Box>
155
- <UserEditor
156
- userId={showUserDetails}
157
- customFields={customFields}
158
- onSaved={() => {
159
- setShowUserDetails(null);
160
- }} />
161
- </Box>
162
- </DialogContent>
163
- </Dialog>
164
-
165
184
  </Box>
166
185
  );
167
186
  }