1818 * SPDX-License-Identifier: Apache-2.0
1919 ********************************************************************************/
2020
21- import { useState } from 'react'
21+ import { useEffect , useState } from 'react'
2222import { useTranslation } from 'react-i18next'
2323import { Typography , PageSnackbar } from '@catena-x/portal-shared-components'
24- import { useDispatch } from 'react-redux'
25- import { fetchCompanyDetail } from 'features/admin/registration/actions'
2624import './style.scss'
2725import type { GridCellParams } from '@mui/x-data-grid'
2826import CompanyDetailOverlay from './CompanyDetailOverlay'
@@ -39,7 +37,7 @@ import { ServerResponseOverlay } from 'components/overlays/ServerResponse'
3937import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline'
4038import AddBpnOveraly from './ConfirmationOverlay/AddBpnOverlay'
4139import ConfirmCancelOverlay from './ConfirmationOverlay/ConfirmCancelOverlay'
42- import type { AppDispatch } from 'features/store '
40+ import { useGetCompanyDetailQuery } from 'features/admin/registration/apiSlice '
4341
4442enum TableField {
4543 DETAIL = 'detail' ,
@@ -49,8 +47,6 @@ enum TableField {
4947export default function RegistrationRequests ( ) {
5048 const { t } = useTranslation ( )
5149
52- const dispatch = useDispatch < AppDispatch > ( )
53-
5450 const [ overlayOpen , setOverlayOpen ] = useState < boolean > ( false )
5551
5652 const [ confirmModalOpen , setConfirmModalOpen ] = useState < boolean > ( false )
@@ -79,15 +75,24 @@ export default function RegistrationRequests() {
7975 useState < boolean > ( false )
8076 const [ selectedRequestName , setSelectedRequestName ] = useState < string > ( '' )
8177 const [ selectedActiveTab , setSelectedActiveTab ] = useState < number > ( 0 )
78+
79+ const { refetch } = useGetCompanyDetailQuery ( selectedRequestId ?? '' , {
80+ skip : ! selectedRequestId ,
81+ } )
82+
83+ useEffect ( ( ) => {
84+ if ( selectedRequestId ) {
85+ refetch ( )
86+ }
87+ } , [ selectedRequestId , refetch ] )
88+
8289 const onTableCellClick = ( params : GridCellParams ) => {
83- // Show overlay only when detail field clicked
8490 if (
8591 params . field === TableField . DETAIL ||
8692 params . field === TableField . STATUS
8793 ) {
8894 setSelectedRequestId ( params . row . applicationId )
8995 setSelectedRequest ( params . row )
90- dispatch ( fetchCompanyDetail ( params . row . applicationId ) )
9196 setOverlayOpen ( true )
9297 setSelectedActiveTab ( params . field === TableField . DETAIL ? 0 : 2 )
9398 }
0 commit comments