1
1
/* eslint-disable camelcase */
2
- import { SyntheticEvent , useEffect , useMemo , useState } from 'react' ;
2
+ import { useEffect , useMemo , useState } from 'react' ;
3
3
import { MaterialReactTable , type MRT_ColumnDef } from 'material-react-table' ;
4
- import { Button , Dialog , DialogTitle , DialogContent , DialogContentText , TextField , DialogActions , Autocomplete } from '@mui/material' ;
4
+ import { Button , Dialog , DialogTitle , DialogContent , DialogContentText , TextField , DialogActions } from '@mui/material' ;
5
5
import { Tenant , TenantOAuth } from '../../../utils/types' ;
6
6
import { useAppDispatch } from '../../../store/hooks' ;
7
- import { createData , deleteData , getData , patchData } from '../../../store/actions/managementActions' ;
7
+ import { createData , deleteData , getData , getDataByID , patchData } from '../../../store/actions/managementActions' ;
8
8
import { notificationsActions } from '../../../store/slices/notificationsSlice' ;
9
+ import { TenantProp } from './Tenant' ;
9
10
10
- const TenantOAuthTable = ( ) => {
11
+ const TenantOAuthTable = ( props : TenantProp ) => {
12
+ const tenantId = props . tenantId ;
11
13
12
14
const dispatch = useAppDispatch ( ) ;
13
15
@@ -71,10 +73,9 @@ const TenantOAuthTable = () => {
71
73
const [ data , setData ] = useState ( [ ] ) ;
72
74
const [ isLoading , setIsLoading ] = useState ( false ) ;
73
75
const [ id , setId ] = useState ( 0 ) ;
74
- const [ tenantId , setTenantId ] = useState ( 0 ) ;
75
76
const [ profileUrl , setProfileUrl ] = useState ( '' ) ;
76
77
const [ wellknown , setWellknown ] = useState ( '' ) ;
77
- const [ wellknownEpmty , setWellknownEmpty ] = useState ( true ) ;
78
+ const [ wellknownEmpty , setWellknownEmpty ] = useState ( true ) ;
78
79
79
80
const [ key , setKey ] = useState ( '' ) ;
80
81
const [ secret , setSecret ] = useState ( '' ) ;
@@ -83,8 +84,7 @@ const TenantOAuthTable = () => {
83
84
const [ scope , setScope ] = useState ( '' ) ;
84
85
const [ scopeDelimeter , setScopeDelimeter ] = useState ( '' ) ;
85
86
const [ redirect , setRedirect ] = useState ( '' ) ;
86
- const [ tenantIdOption , setTenantIdOption ] = useState < Tenant | undefined > ( ) ;
87
-
87
+
88
88
async function fetchProduct ( ) {
89
89
setIsLoading ( true ) ;
90
90
@@ -96,7 +96,7 @@ const TenantOAuthTable = () => {
96
96
} ) ;
97
97
98
98
// eslint-disable-next-line @typescript-eslint/no-explicit-any
99
- dispatch ( getData ( 'tenantOAuths' ) ) . then ( ( tdata : any ) => {
99
+ dispatch ( getDataByID ( tenantId , 'tenantOAuths' ) ) . then ( ( tdata : any ) => {
100
100
if ( tdata != undefined ) {
101
101
setData ( tdata . data ) ;
102
102
}
@@ -114,16 +114,13 @@ const TenantOAuthTable = () => {
114
114
115
115
const handleClickOpen = ( ) => {
116
116
setId ( 0 ) ;
117
- setTenantId ( 0 ) ;
118
117
setProfileUrl ( 'https://edumeet.example.com/kc/realms/<realm>/protocol/openid-connect/userinfo' ) ;
119
118
setKey ( 'edumeet-dev-client' ) ;
120
119
setSecret ( '' ) ;
121
120
setAuthorizeUrl ( 'https://edumeet.example.com/kc/realms/<realm>/protocol/openid-connect/auth' ) ;
122
121
setAccessUrl ( 'https://edumeet.example.com/kc/realms/<realm>/protocol/openid-connect/token' ) ;
123
122
setScope ( 'openid profile email' ) ;
124
123
setScopeDelimeter ( ' ' ) ;
125
- setTenantIdOption ( undefined ) ;
126
- setTenantId ( 0 ) ;
127
124
setRedirect ( 'https://edumeet.example.com/mgmt/oauth/tenant/callback' ) ;
128
125
setOpen ( true ) ;
129
126
} ;
@@ -132,13 +129,6 @@ const TenantOAuthTable = () => {
132
129
setOpen ( true ) ;
133
130
} ;
134
131
135
- const handleTenantIdChange = ( event : SyntheticEvent < Element , Event > , newValue : Tenant ) => {
136
- if ( newValue ) {
137
- setTenantId ( newValue . id ) ;
138
- setTenantIdOption ( newValue ) ;
139
- }
140
- } ;
141
-
142
132
const handleProfileUrlChange = ( event : { target : { value : React . SetStateAction < string > ; } ; } ) => {
143
133
setProfileUrl ( event . target . value ) ;
144
134
} ;
@@ -289,16 +279,6 @@ const TenantOAuthTable = () => {
289
279
onChange={handleTenantIdChange}
290
280
value={tenantId}
291
281
/> */ }
292
- < Autocomplete
293
- options = { tenants }
294
- getOptionLabel = { ( option ) => option . name }
295
- fullWidth
296
- disableClearable
297
- onChange = { handleTenantIdChange }
298
- value = { tenantIdOption }
299
- sx = { { marginTop : '8px' } }
300
- renderInput = { ( params ) => < TextField { ...params } label = "Tenant" /> }
301
- />
302
282
< TextField
303
283
margin = "dense"
304
284
required
@@ -309,7 +289,7 @@ const TenantOAuthTable = () => {
309
289
value = { wellknown }
310
290
onChange = { handleWellknownChange }
311
291
/>
312
- < Button onClick = { handleWellknownUpdate } variant = "contained" fullWidth disabled = { wellknownEpmty } > Update parameters from URL</ Button >
292
+ < Button onClick = { handleWellknownUpdate } variant = "contained" fullWidth disabled = { wellknownEmpty } > Update parameters from URL</ Button >
313
293
< TextField
314
294
margin = "dense"
315
295
required
@@ -409,7 +389,7 @@ const TenantOAuthTable = () => {
409
389
const r = row . getAllCells ( ) ;
410
390
411
391
const tid = r [ 0 ] . getValue ( ) ;
412
- const ttenantId = r [ 1 ] . getValue ( ) ;
392
+ // const ttenantId= r[1].getValue();
413
393
const taccess = r [ 2 ] . getValue ( ) ;
414
394
const tauthorize = r [ 3 ] . getValue ( ) ;
415
395
const tprofile = r [ 4 ] . getValue ( ) ;
@@ -420,17 +400,6 @@ const TenantOAuthTable = () => {
420
400
if ( typeof tid === 'number' ) {
421
401
setId ( tid ) ;
422
402
}
423
- if ( typeof ttenantId === 'string' ) {
424
- const ttenant = tenants . find ( ( x ) => x . id === parseInt ( ttenantId ) ) ;
425
-
426
- if ( ttenant ) {
427
- setTenantIdOption ( ttenant ) ;
428
- }
429
- setTenantId ( parseInt ( ttenantId ) ) ;
430
- } else {
431
- setTenantId ( 0 ) ;
432
- }
433
-
434
403
if ( typeof tprofile === 'string' ) { setProfileUrl ( tprofile ) ; } else {
435
404
setProfileUrl ( '' ) ;
436
405
}
0 commit comments