@@ -24,6 +24,8 @@ import SearchIcon from '@material-ui/icons/Search';
24
24
import TodayIcon from '@material-ui/icons/Today' ;
25
25
import AddCircleIcon from '@material-ui/icons/AddCircle' ;
26
26
import IconButton from '@material-ui/core/IconButton' ;
27
+ import CheckIcon from '@material-ui/icons/Check' ;
28
+ import ClearIcon from '@material-ui/icons/Clear' ;
27
29
28
30
import { AppContext } from '../../AppProvider' ;
29
31
import Loading from '../../Assets/LoadingSpinner' ;
@@ -41,7 +43,7 @@ import { DialogTitle, Tooltip } from '@material-ui/core';
41
43
42
44
// Types
43
45
type UserFilter = {
44
- user : 'active' | 'custom' | 'System Admin' | 'Office Admin' ;
46
+ user : 'active' | 'custom' | 'System Admin' | 'Office Admin' | 'Auto Approved' ;
45
47
email ?: string ;
46
48
} ;
47
49
@@ -57,8 +59,11 @@ const userFilterToQuery = (filter: UserFilter): UserQuery => {
57
59
query . role = 'System Admin' ;
58
60
} else if ( filter . user === 'custom' ) {
59
61
query . quota = 'custom' ;
62
+ } else if ( filter . user === 'Auto Approved' ) {
63
+ query . autoApproved = 'true' ;
60
64
}
61
65
66
+ console . log ( 'query' , query ) ;
62
67
return query ;
63
68
} ;
64
69
@@ -81,14 +86,20 @@ const sortData = (data: User[], key: keyof User, order: SortOrder): User[] | und
81
86
: data . sort ( ( a , b ) => a . role . name . localeCompare ( b . role . name ) ) ;
82
87
}
83
88
89
+ if ( key === 'autoApproved' ) {
90
+ return order === 'desc'
91
+ ? data . sort ( ( a , b ) => Number ( b . autoApproved as boolean ) - Number ( a . autoApproved as boolean ) )
92
+ : data . sort ( ( a , b ) => Number ( a . autoApproved as boolean ) - Number ( b . autoApproved as boolean ) ) ;
93
+ }
94
+
84
95
return data ;
85
96
} ;
86
97
87
98
// Component
88
99
const Users : React . FC < RouteComponentProps > = ( ) => {
89
100
// Global state
90
101
const { state, dispatch } = useContext ( AppContext ) ;
91
- const { user } = state ;
102
+ const { config , user } = state ;
92
103
93
104
// Local state
94
105
const [ loading , setLoading ] = useState ( true ) ;
@@ -177,7 +188,8 @@ const Users: React.FC<RouteComponentProps> = () => {
177
188
user === 'active' ||
178
189
user === 'System Admin' ||
179
190
user === 'Office Admin' ||
180
- user === 'custom'
191
+ user === 'custom' ||
192
+ user === 'Auto Approved'
181
193
) {
182
194
setSelectedFilter ( ( filter ) => ( { ...filter , user } ) ) ;
183
195
}
@@ -261,6 +273,9 @@ const Users: React.FC<RouteComponentProps> = () => {
261
273
< MenuItem value = "System Admin" > System Admins</ MenuItem >
262
274
< MenuItem value = "Office Admin" > Office Admins</ MenuItem >
263
275
< MenuItem value = "custom" > With custom quota</ MenuItem >
276
+ { config ?. reasonToBookRequired && (
277
+ < MenuItem value = "Auto Approved" > With auto approved</ MenuItem >
278
+ ) }
264
279
</ Select >
265
280
</ FormControl >
266
281
</ div >
@@ -319,6 +334,17 @@ const Users: React.FC<RouteComponentProps> = () => {
319
334
Role
320
335
</ TableSortLabel >
321
336
</ TableCell >
337
+ { config ?. reasonToBookRequired && (
338
+ < TableCell className = "table-header" >
339
+ < TableSortLabel
340
+ active = { sortBy === 'autoApproved' }
341
+ direction = { sortOrder }
342
+ onClick = { ( ) => handleSort ( 'autoApproved' ) }
343
+ >
344
+ Auto Approved
345
+ </ TableSortLabel >
346
+ </ TableCell >
347
+ ) }
322
348
< TableCell className = "table-header" />
323
349
</ TableRow >
324
350
</ TableHead >
@@ -329,6 +355,11 @@ const Users: React.FC<RouteComponentProps> = () => {
329
355
< TableCell > { user . email } </ TableCell >
330
356
< TableCell > { user . quota } </ TableCell >
331
357
< TableCell > { user . role . name } </ TableCell >
358
+ { config ?. reasonToBookRequired && (
359
+ < TableCell >
360
+ { user . autoApproved ? < CheckIcon /> : < ClearIcon color = "disabled" /> }
361
+ </ TableCell >
362
+ ) }
332
363
< TableCell align = "right" >
333
364
< Tooltip title = { `Edit` } arrow >
334
365
< IconButton onClick = { ( ) => navigate ( `/admin/users/${ user . email } ` ) } >
@@ -351,6 +382,7 @@ const Users: React.FC<RouteComponentProps> = () => {
351
382
< TableCell />
352
383
< TableCell />
353
384
< TableCell />
385
+ { config ?. reasonToBookRequired && < TableCell /> }
354
386
</ TableRow >
355
387
) }
356
388
</ TableBody >
0 commit comments