Skip to content

Commit d49601e

Browse files
committed
Add location details view
1 parent 09e4e11 commit d49601e

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

.vscode/settings.json

-2
This file was deleted.

packages/fhir-location-management/src/components/AllLocationListFlat/index.tsx

+13-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
22
import { useSimpleTabularView } from '@opensrp/react-utils';
33
import { RouteComponentProps } from 'react-router';
44
import { ILocation } from '@smile-cdr/fhirts/dist/FHIR-R4/interfaces/ILocation';
@@ -9,9 +9,7 @@ import {
99
} from '../../constants';
1010
import {
1111
BrokenPage,
12-
useSearchParams,
1312
TableLayout,
14-
viewDetailsQuery,
1513
PageHeader,
1614
SearchForm,
1715
} from '@opensrp/react-utils';
@@ -20,7 +18,7 @@ import { Helmet } from 'react-helmet';
2018
import { useTranslation } from '../../mls';
2119
import { Row, Col, Button, Divider, Dropdown } from 'antd';
2220
import { useHistory, Link } from 'react-router-dom';
23-
import { RbacCheck, useUserRole } from '@opensrp/rbac';
21+
import { RbacCheck } from '@opensrp/rbac';
2422
import type { MenuProps } from 'antd';
2523
import { MoreOutlined, PlusOutlined } from '@ant-design/icons';
2624
import { LocationUnitDetail } from '../LocationUnitDetail';
@@ -48,8 +46,7 @@ export const AllLocationListFlat: React.FC<LocationListPropTypes> = (props) => {
4846
const { fhirBaseURL } = props;
4947
const { t } = useTranslation();
5048
const history = useHistory();
51-
const { addParam, sParams } = useSearchParams();
52-
const userRole = useUserRole();
49+
const [detailId, setDetailId] = useState<string>();
5350

5451
const {
5552
queryValues: { data, isFetching, isLoading, error},
@@ -76,20 +73,13 @@ export const AllLocationListFlat: React.FC<LocationListPropTypes> = (props) => {
7673
return [
7774
{
7875
key: '1',
79-
permissions: [],
8076
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')}
8379
</Button>
8480
),
8581
},
86-
]
87-
.filter((item) => userRole.hasPermissions(item.permissions))
88-
.map((item) => {
89-
const { permissions, ...rest } = item;
90-
return rest;
91-
});
92-
};
82+
]};
9383

9484
const columns = [
9585
{
@@ -168,6 +158,13 @@ export const AllLocationListFlat: React.FC<LocationListPropTypes> = (props) => {
168158
</div>
169159
<TableLayout {...tableProps} />
170160
</Col>
161+
{detailId ? (
162+
<LocationUnitDetail
163+
fhirBaseUrl={fhirBaseURL}
164+
onClose={() => setDetailId('')}
165+
detailId={detailId}
166+
/>
167+
) : null}
171168
</Row>
172169
</div>
173170
);

0 commit comments

Comments
 (0)