1818 ********************************************************************************/
1919
2020import { Chip , IconButton , Table } from '@catena-x/portal-shared-components'
21- import { useEffect , useState } from 'react'
21+ import { useEffect , useMemo , useState } from 'react'
2222import { useDispatch , useSelector } from 'react-redux'
2323import { Box } from '@mui/material'
2424import { useTranslation } from 'react-i18next'
@@ -60,6 +60,7 @@ export const CompanyAddressList = ({
6060 handleConfirm : ( ) => void
6161} ) => {
6262 const { t } = useTranslation ( )
63+ const [ noRowsMsg , setNoRowsMsg ] = useState < string > ( '' )
6364 const [ page , setPage ] = useState < number > ( 0 )
6465 const {
6566 data,
@@ -80,6 +81,8 @@ export const CompanyAddressList = ({
8081 const dispatch = useDispatch ( )
8182 const refetch = useSelector ( companyRefetch )
8283
84+ const rows = useMemo ( ( ) => inputs . concat ( outputs ) , [ inputs , outputs ] )
85+
8386 const getInputItems = async ( ) => {
8487 const params = sharingStates
8588 ?. filter (
@@ -139,6 +142,12 @@ export const CompanyAddressList = ({
139142 }
140143 } , [ data ] )
141144
145+ useEffect ( ( ) => {
146+ if ( rows && rows . length === 0 ) {
147+ setNoRowsMsg ( t ( 'global.table.emptyDataMsg' ) )
148+ }
149+ } , [ rows ] )
150+
142151 const getStatus = ( id : string ) =>
143152 sharingStates ?. filter ( ( state ) => id === state . externalId ) [ 0 ]
144153 ?. sharingStateType
@@ -212,9 +221,7 @@ export const CompanyAddressList = ({
212221 columnHeadersBackgroundColor = { '#FFFFFF' }
213222 searchDebounce = { 1000 }
214223 noRowsMsg = {
215- ! isFetching && ! isOutputLoading && ! isInputLoading
216- ? t ( 'content.companyData.table.noRowsMsg' )
217- : ''
224+ ! isFetching && ! isOutputLoading && ! isInputLoading ? noRowsMsg : ''
218225 }
219226 title = { t ( 'content.companyData.table.title' ) }
220227 getRowId = { ( row : { [ key : string ] : string } ) => row . createdAt }
0 commit comments