1
- import React from 'react' ;
1
+ import React , { useState } 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' ;
9
9
} from '../../constants' ;
10
10
import {
11
11
BrokenPage ,
12
- useSearchParams ,
13
12
TableLayout ,
14
- viewDetailsQuery ,
15
13
PageHeader ,
16
14
SearchForm ,
17
15
} from '@opensrp/react-utils' ;
@@ -20,7 +18,7 @@ import { Helmet } from 'react-helmet';
20
18
import { useTranslation } from '../../mls' ;
21
19
import { Row , Col , Button , Divider , Dropdown } from 'antd' ;
22
20
import { useHistory , Link } from 'react-router-dom' ;
23
- import { RbacCheck , useUserRole } from '@opensrp/rbac' ;
21
+ import { RbacCheck } from '@opensrp/rbac' ;
24
22
import type { MenuProps } from 'antd' ;
25
23
import { MoreOutlined , PlusOutlined } from '@ant-design/icons' ;
26
24
import { LocationUnitDetail } from '../LocationUnitDetail' ;
@@ -48,8 +46,7 @@ export const AllLocationListFlat: React.FC<LocationListPropTypes> = (props) => {
48
46
const { fhirBaseURL } = props ;
49
47
const { t } = useTranslation ( ) ;
50
48
const history = useHistory ( ) ;
51
- const { addParam, sParams } = useSearchParams ( ) ;
52
- const userRole = useUserRole ( ) ;
49
+ const [ detailId , setDetailId ] = useState < string > ( ) ;
53
50
54
51
const {
55
52
queryValues : { data, isFetching, isLoading, error} ,
@@ -76,20 +73,13 @@ export const AllLocationListFlat: React.FC<LocationListPropTypes> = (props) => {
76
73
return [
77
74
{
78
75
key : '1' ,
79
- permissions : [ ] ,
80
76
label : (
81
- < Button type = "link" onClick = { ( ) => addParam ( viewDetailsQuery , record . id ) } >
82
- View Details
77
+ < Button type = "link" onClick = { ( ) => setDetailId ( record . id ) } >
78
+ { t ( ' View details' ) }
83
79
</ Button >
84
80
) ,
85
81
} ,
86
- ]
87
- . filter ( ( item ) => userRole . hasPermissions ( item . permissions ) )
88
- . map ( ( item ) => {
89
- const { permissions, ...rest } = item ;
90
- return rest ;
91
- } ) ;
92
- } ;
82
+ ] } ;
93
83
94
84
const columns = [
95
85
{
@@ -168,6 +158,13 @@ export const AllLocationListFlat: React.FC<LocationListPropTypes> = (props) => {
168
158
</ div >
169
159
< TableLayout { ...tableProps } />
170
160
</ Col >
161
+ { detailId ? (
162
+ < LocationUnitDetail
163
+ fhirBaseUrl = { fhirBaseURL }
164
+ onClose = { ( ) => setDetailId ( '' ) }
165
+ detailId = { detailId }
166
+ />
167
+ ) : null }
171
168
</ Row >
172
169
</ div >
173
170
) ;
0 commit comments