1
- import React , { useEffect , useState } from 'react' ;
1
+ import React from 'react' ;
2
2
import { useSimpleTabularView } from '@opensrp/react-utils' ;
3
3
import { RouteComponentProps } from 'react-router' ;
4
4
import { ILocation } from '@smile-cdr/fhirts/dist/FHIR-R4/interfaces/ILocation' ;
@@ -34,8 +34,12 @@ interface Props {
34
34
LocationPageSize : number ;
35
35
}
36
36
37
- const getSearchParams = ( ) => {
38
- return { _include : 'Location:partof' } ;
37
+ const getSearchParams = ( search : string | null ) => {
38
+ const baseSearchParam = { "_include" : "Location:partof" } ;
39
+ if ( search ) {
40
+ return { "name:contains" : search , ...baseSearchParam }
41
+ }
42
+ return baseSearchParam ;
39
43
} ;
40
44
41
45
export type LocationListPropTypes = Props & RouteComponentProps < RouteParams > ;
@@ -44,24 +48,20 @@ export const AllLocationListFlat: React.FC<LocationListPropTypes> = (props) => {
44
48
const { fhirBaseURL } = props ;
45
49
const { t } = useTranslation ( ) ;
46
50
const history = useHistory ( ) ;
47
- const [ detailId , setDetailId ] = useState < string > ( '' ) ;
48
51
const { addParam, sParams } = useSearchParams ( ) ;
49
52
const userRole = useUserRole ( ) ;
50
- const resourceId = sParams . get ( viewDetailsQuery ) ?? undefined ;
51
53
52
54
const {
53
- queryValues : { data, isFetching, isLoading, error, refetch } ,
55
+ queryValues : { data, isFetching, isLoading, error} ,
54
56
tablePaginationProps,
55
57
searchFormProps,
56
- } = useSimpleTabularView < ILocation > ( fhirBaseURL , locationResourceType , getSearchParams ( ) ) ;
58
+ } = useSimpleTabularView < ILocation > ( fhirBaseURL , locationResourceType , getSearchParams ) ;
57
59
58
60
if ( error && ! data ) {
59
61
return < BrokenPage errorMessage = { ( error as Error ) . message } /> ;
60
62
}
61
63
62
- useEffect ( ( ) => { } , [ data , isFetching , isLoading , error ] ) ;
63
-
64
- const tableData : any [ ] = ( data ?. records ?? [ ] ) . map ( ( datum : Dictionary ) => ( {
64
+ const tableData = ( data ?. records ?? [ ] ) . map ( ( datum : Dictionary ) => ( {
65
65
key : datum . id ,
66
66
id : datum . id ,
67
67
name : datum . name ,
0 commit comments