11/* eslint-disable camelcase */
2- import { SyntheticEvent , useEffect , useMemo , useState } from 'react' ;
2+ import { useEffect , useMemo , useState } from 'react' ;
33import { 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' ;
55import { Tenant , TenantOAuth } from '../../../utils/types' ;
66import { 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' ;
88import { notificationsActions } from '../../../store/slices/notificationsSlice' ;
9+ import { TenantProp } from './Tenant' ;
910
10- const TenantOAuthTable = ( ) => {
11+ const TenantOAuthTable = ( props : TenantProp ) => {
12+ const tenantId = props . tenantId ;
1113
1214 const dispatch = useAppDispatch ( ) ;
1315
@@ -71,10 +73,9 @@ const TenantOAuthTable = () => {
7173 const [ data , setData ] = useState ( [ ] ) ;
7274 const [ isLoading , setIsLoading ] = useState ( false ) ;
7375 const [ id , setId ] = useState ( 0 ) ;
74- const [ tenantId , setTenantId ] = useState ( 0 ) ;
7576 const [ profileUrl , setProfileUrl ] = useState ( '' ) ;
7677 const [ wellknown , setWellknown ] = useState ( '' ) ;
77- const [ wellknownEpmty , setWellknownEmpty ] = useState ( true ) ;
78+ const [ wellknownEmpty , setWellknownEmpty ] = useState ( true ) ;
7879
7980 const [ key , setKey ] = useState ( '' ) ;
8081 const [ secret , setSecret ] = useState ( '' ) ;
@@ -83,8 +84,7 @@ const TenantOAuthTable = () => {
8384 const [ scope , setScope ] = useState ( '' ) ;
8485 const [ scopeDelimeter , setScopeDelimeter ] = useState ( '' ) ;
8586 const [ redirect , setRedirect ] = useState ( '' ) ;
86- const [ tenantIdOption , setTenantIdOption ] = useState < Tenant | undefined > ( ) ;
87-
87+
8888 async function fetchProduct ( ) {
8989 setIsLoading ( true ) ;
9090
@@ -96,7 +96,7 @@ const TenantOAuthTable = () => {
9696 } ) ;
9797
9898 // eslint-disable-next-line @typescript-eslint/no-explicit-any
99- dispatch ( getData ( 'tenantOAuths' ) ) . then ( ( tdata : any ) => {
99+ dispatch ( getDataByID ( tenantId , 'tenantOAuths' ) ) . then ( ( tdata : any ) => {
100100 if ( tdata != undefined ) {
101101 setData ( tdata . data ) ;
102102 }
@@ -114,16 +114,13 @@ const TenantOAuthTable = () => {
114114
115115 const handleClickOpen = ( ) => {
116116 setId ( 0 ) ;
117- setTenantId ( 0 ) ;
118117 setProfileUrl ( 'https://edumeet.example.com/kc/realms/<realm>/protocol/openid-connect/userinfo' ) ;
119118 setKey ( 'edumeet-dev-client' ) ;
120119 setSecret ( '' ) ;
121120 setAuthorizeUrl ( 'https://edumeet.example.com/kc/realms/<realm>/protocol/openid-connect/auth' ) ;
122121 setAccessUrl ( 'https://edumeet.example.com/kc/realms/<realm>/protocol/openid-connect/token' ) ;
123122 setScope ( 'openid profile email' ) ;
124123 setScopeDelimeter ( ' ' ) ;
125- setTenantIdOption ( undefined ) ;
126- setTenantId ( 0 ) ;
127124 setRedirect ( 'https://edumeet.example.com/mgmt/oauth/tenant/callback' ) ;
128125 setOpen ( true ) ;
129126 } ;
@@ -132,13 +129,6 @@ const TenantOAuthTable = () => {
132129 setOpen ( true ) ;
133130 } ;
134131
135- const handleTenantIdChange = ( event : SyntheticEvent < Element , Event > , newValue : Tenant ) => {
136- if ( newValue ) {
137- setTenantId ( newValue . id ) ;
138- setTenantIdOption ( newValue ) ;
139- }
140- } ;
141-
142132 const handleProfileUrlChange = ( event : { target : { value : React . SetStateAction < string > ; } ; } ) => {
143133 setProfileUrl ( event . target . value ) ;
144134 } ;
@@ -289,16 +279,6 @@ const TenantOAuthTable = () => {
289279 onChange={handleTenantIdChange}
290280 value={tenantId}
291281 /> */ }
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- />
302282 < TextField
303283 margin = "dense"
304284 required
@@ -309,7 +289,7 @@ const TenantOAuthTable = () => {
309289 value = { wellknown }
310290 onChange = { handleWellknownChange }
311291 />
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 >
313293 < TextField
314294 margin = "dense"
315295 required
@@ -409,7 +389,7 @@ const TenantOAuthTable = () => {
409389 const r = row . getAllCells ( ) ;
410390
411391 const tid = r [ 0 ] . getValue ( ) ;
412- const ttenantId = r [ 1 ] . getValue ( ) ;
392+ // const ttenantId= r[1].getValue();
413393 const taccess = r [ 2 ] . getValue ( ) ;
414394 const tauthorize = r [ 3 ] . getValue ( ) ;
415395 const tprofile = r [ 4 ] . getValue ( ) ;
@@ -420,17 +400,6 @@ const TenantOAuthTable = () => {
420400 if ( typeof tid === 'number' ) {
421401 setId ( tid ) ;
422402 }
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-
434403 if ( typeof tprofile === 'string' ) { setProfileUrl ( tprofile ) ; } else {
435404 setProfileUrl ( '' ) ;
436405 }
0 commit comments