diff --git a/packages/fhir-import/src/containers/ImportDetailOverView/tests/__snapshots__/index.test.tsx.snap b/packages/fhir-import/src/containers/ImportDetailOverView/tests/__snapshots__/index.test.tsx.snap deleted file mode 100644 index 66bb3d084..000000000 --- a/packages/fhir-import/src/containers/ImportDetailOverView/tests/__snapshots__/index.test.tsx.snap +++ /dev/null @@ -1,408 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`1157 - view details errors out for careTeam 3500 1`] = ` -
-
- CareTeam ID -
-
- 3500 -
-
-`; - -exports[`1157 - view details errors out for careTeam 3500 2`] = ` -
-
- Name -
-
- Peter James Charlmers Care team -
-
-`; - -exports[`1157 - view details errors out for careTeam 3500 3`] = ` -
-
- status -
-
- active -
-
-`; - -exports[`1157 - view details errors out for careTeam 3500 4`] = ` -
-
- Participants -
-
- -
-
-`; - -exports[`1157 - view details errors out for careTeam 3500 5`] = ` -
-
- Patient -
-
- -
-
-`; - -exports[`1157 - view details errors out for careTeam 3500 6`] = ` -
-
- Managing organizations -
-
- -
-
-`; - -exports[`Closes on clicking cancel (X) 1`] = ` -
-
- CareTeam ID -
-
- 142534 -
-
-`; - -exports[`Closes on clicking cancel (X) 2`] = ` -
-
- Identifier -
-
- 99c4dde5-3aca-4a4b-8b33-b50142e05da6 -
-
-`; - -exports[`Closes on clicking cancel (X) 3`] = ` -
-
- Name -
-
- Brown Bag -
-
-`; - -exports[`Closes on clicking cancel (X) 4`] = ` -
-
- status -
-
- active -
-
-`; - -exports[`Closes on clicking cancel (X) 5`] = ` -
-
- Participants -
-
- -
-
-`; - -exports[`Closes on clicking cancel (X) 6`] = ` -
-
- Practitioner -
-
- -
-
-`; - -exports[`Closes on clicking cancel (X) 7`] = ` -
-
- Managing organizations -
-
- -
-
-`; - -exports[`works correctly 1`] = ` -
-
- CareTeam ID -
-
- 131411 -
-
-`; - -exports[`works correctly 2`] = ` -
-
- Identifier -
-
- 93bc9c3d-6321-41b0-9b93-1275d7114e22 -
-
-`; - -exports[`works correctly 3`] = ` -
-
- Name -
-
- Care Team One -
-
-`; - -exports[`works correctly 4`] = ` -
-
- status -
-
- active -
-
-`; - -exports[`works correctly 5`] = ` -
-
- Participants -
-
- -
-
-`; - -exports[`works correctly 6`] = ` -
-
- Practitioner -
-
- -
-
-`; - -exports[`works correctly 7`] = ` -
-
- Managing organizations -
-
- -
-
-`; diff --git a/packages/fhir-import/src/containers/ImportDetailOverView/tests/fixtures.ts b/packages/fhir-import/src/containers/ImportDetailOverView/tests/fixtures.ts deleted file mode 100644 index f0ac2811a..000000000 --- a/packages/fhir-import/src/containers/ImportDetailOverView/tests/fixtures.ts +++ /dev/null @@ -1,480 +0,0 @@ -export const careTeamWithIncluded = { - resourceType: 'Bundle', - id: '2fb071f1-cafc-4a84-9d0d-e7bdb2e7875e', - meta: { - lastUpdated: '2022-09-29T20:32:11.641+00:00', - }, - type: 'searchset', - total: 1, - link: [ - { - relation: 'self', - url: 'https://fhir.labs.smartregister.org:443/fhir/CareTeam/_search?_id=131411&_include=CareTeam%3A*', - }, - ], - entry: [ - { - fullUrl: 'https://fhir.labs.smartregister.org:443/fhir/CareTeam/131411', - resource: { - resourceType: 'CareTeam', - id: '131411', - meta: { - versionId: '1', - lastUpdated: '2022-05-30T00:53:35.099+00:00', - source: '#8pT6h5Axyf9VsdQq', - }, - identifier: [ - { - use: 'official', - value: '93bc9c3d-6321-41b0-9b93-1275d7114e22', - }, - ], - status: 'active', - name: 'Care Team One', - subject: { - reference: 'Group/131410', - }, - participant: [ - { - member: { - reference: 'Practitioner/131406', - }, - }, - { - member: { - reference: 'Practitioner/131406', - }, - }, - ], - }, - search: { - mode: 'match', - }, - }, - { - fullUrl: 'https://fhir.labs.smartregister.org:443/fhir/Group/131410', - resource: { - resourceType: 'Group', - id: '131410', - meta: { - versionId: '2', - lastUpdated: '2022-06-27T03:22:27.188+00:00', - source: '#c6f633c24d9e6c4b', - }, - identifier: [ - { - use: 'official', - value: '93bc9c3d-6321-41b0-9b93-1275d7114e34', - }, - ], - active: true, - name: 'ANC patients', - quantity: 1, - member: [ - { - entity: { - reference: 'Patient/131408', - }, - }, - ], - }, - search: { - mode: 'include', - }, - }, - { - fullUrl: 'https://fhir.labs.smartregister.org:443/fhir/Practitioner/131406', - resource: { - resourceType: 'Practitioner', - id: '131406', - meta: { - versionId: '1', - lastUpdated: '2022-05-30T00:38:44.891+00:00', - source: '#R1qpXIa2QDrDkBrn', - }, - identifier: [ - { - use: 'official', - value: 'aace2e430b-64be-477e-9d86-b36c666c0211', - }, - { - use: 'secondary', - value: '40353ad0-6fa0-4da3-9dd6-b2d9d5a09b6a', - }, - ], - active: true, - name: [ - { - use: 'official', - family: 'Tester family', - given: ['Ward test hey', 'N test'], - }, - ], - telecom: [ - { - system: 'email', - value: 'reham.muzzamil@venturedive.com', - }, - ], - }, - search: { - mode: 'include', - }, - }, - ], -}; - -export const careTeam2 = { - resourceType: 'Bundle', - id: '11112110-5942-40cb-b8ca-80650821dba4', - meta: { - lastUpdated: '2022-09-30T06:13:08.311+00:00', - }, - type: 'searchset', - total: 1, - link: [ - { - relation: 'self', - url: 'https://fhir.labs.smartregister.org:443/fhir/CareTeam?_format=json&_id=142534&_include=CareTeam%3A*', - }, - ], - entry: [ - { - fullUrl: 'https://fhir.labs.smartregister.org:443/fhir/CareTeam/142534', - resource: { - resourceType: 'CareTeam', - id: '142534', - meta: { - versionId: '1', - lastUpdated: '2022-09-01T12:44:38.522+00:00', - source: '#532e59e3409867b3', - }, - identifier: [ - { - use: 'official', - value: '99c4dde5-3aca-4a4b-8b33-b50142e05da6', - }, - ], - status: 'active', - name: 'Brown Bag', - participant: [ - { - member: { - reference: 'Practitioner/137469', - }, - }, - ], - }, - search: { - mode: 'match', - }, - }, - { - fullUrl: 'https://fhir.labs.smartregister.org:443/fhir/Practitioner/137469', - resource: { - resourceType: 'Practitioner', - id: '137469', - meta: { - versionId: '1', - lastUpdated: '2022-08-10T13:16:53.838+00:00', - source: '#2c648422b7a6e78e', - }, - identifier: [ - { - use: 'official', - value: '175ceaa4-0f75-4ab3-a8a7-413cc225f761', - }, - { - use: 'secondary', - value: 'b27939dd-4c8f-44c2-83dd-dc40e494f17d', - }, - ], - active: true, - name: [ - { - use: 'official', - family: 'Demo', - given: ['AeHIN'], - }, - ], - telecom: [ - { - system: 'email', - }, - ], - }, - search: { - mode: 'include', - }, - }, - ], -}; - -export const careTeam3500 = { - resourceType: 'Bundle', - id: '964d0cdc-3297-41fa-991f-47d639ff7635', - meta: { - lastUpdated: '2023-02-10T08:22:04.594+00:00', - }, - type: 'searchset', - total: 1, - link: [ - { - relation: 'self', - url: 'https://fhir.labs.smartregister.org/fhir/CareTeam/_search?_id=3500&_include=CareTeam%3A*', - }, - ], - entry: [ - { - fullUrl: 'https://fhir.labs.smartregister.org/fhir/CareTeam/3500', - resource: { - resourceType: 'CareTeam', - id: '3500', - meta: { - versionId: '1', - lastUpdated: '2021-10-12T07:29:44.733+00:00', - source: '#9837ac48046ef77c', - }, - text: { - status: 'generated', - div: '
Care Team
', - }, - contained: [ - { - resourceType: 'Practitioner', - id: '3457', - name: [ - { - family: 'Careful', - given: ['Adam'], - prefix: ['Dr'], - }, - ], - }, - ], - status: 'active', - category: [ - { - coding: [ - { - system: 'http://loinc.org', - code: 'LA27976-2', - display: 'Encounter-focused care team', - }, - ], - }, - ], - name: 'Peter James Charlmers Care team', - subject: { - reference: 'Patient/3455', - display: 'Peter James Chalmers', - }, - encounter: { - reference: 'Encounter/3458', - }, - period: { - end: '2013-01-01', - }, - participant: [ - { - role: [ - { - text: 'responsiblePerson', - }, - ], - member: { - reference: 'Patient/3455', - display: 'Peter James Chalmers', - }, - }, - { - role: [ - { - text: 'adviser', - }, - ], - member: { - reference: '#pr1', - display: 'Dorothy Dietition', - }, - onBehalfOf: { - reference: 'Organization/0000', - }, - period: { - end: '2013-01-01', - }, - }, - ], - managingOrganization: [ - { - reference: 'Organization/3461', - }, - ], - }, - search: { - mode: 'match', - }, - }, - { - fullUrl: 'https://fhir.labs.smartregister.org/fhir/Encounter/3458', - resource: { - resourceType: 'Encounter', - id: '3458', - meta: { - versionId: '2', - lastUpdated: '2021-10-25T06:53:54.230+00:00', - source: '#1350520584a57b46', - }, - text: { - status: 'generated', - div: '
Encounter with patient @example
', - }, - status: 'finished', - class: { - system: 'http://terminology.hl7.org/CodeSystem/v3-ActCode', - code: 'IMP', - display: 'inpatient encounter to check on Obsesity', - }, - subject: { - reference: 'Patient/3455', - }, - }, - search: { - mode: 'include', - }, - }, - { - fullUrl: 'https://fhir.labs.smartregister.org/fhir/Patient/3455', - resource: { - resourceType: 'Patient', - id: '3455', - meta: { - versionId: '3', - lastUpdated: '2021-10-22T13:49:19.121+00:00', - source: '#70532eaf6e0ba7df', - }, - text: { - status: 'generated', - div: '
Peter James CHALMERS
Address534 Erewhon St
PleasantVille Vic
Date of birth25 December 1974
', - }, - active: true, - name: [ - { - use: 'official', - family: 'Chalmers', - given: ['Peter', 'James'], - }, - { - use: 'usual', - given: ['Jim'], - }, - { - use: 'maiden', - family: 'Windsor', - given: ['Peter', 'James'], - period: { - end: '2002', - }, - }, - ], - telecom: [ - { - use: 'home', - }, - { - system: 'phone', - value: '(03) 5555 6473', - use: 'work', - rank: 1, - }, - { - system: 'phone', - value: '(03) 3410 5613', - use: 'mobile', - rank: 2, - }, - { - system: 'phone', - value: '(03) 5555 8834', - use: 'old', - period: { - end: '2014', - }, - }, - ], - gender: 'male', - birthDate: '1974-12-25', - deceasedBoolean: false, - address: [ - { - use: 'home', - type: 'both', - text: '534 Erewhon St PeasantVille, Rainbow, Vic 3999', - line: ['534 Erewhon St'], - city: 'PleasantVille', - district: 'Rainbow', - state: 'Vic', - postalCode: '3999', - period: { - start: '1974-12-25', - }, - }, - ], - contact: [ - { - relationship: [ - { - coding: [ - { - system: 'http://terminology.hl7.org/CodeSystem/v2-0131', - code: 'N', - }, - ], - }, - ], - name: { - family: 'du Marché', - _family: { - extension: [ - { - url: 'http://hl7.org/fhir/StructureDefinition/humanname-own-prefix', - valueString: 'VV', - }, - ], - }, - given: ['Bénédicte'], - }, - telecom: [ - { - system: 'phone', - value: '+33 (237) 998327', - }, - ], - address: { - use: 'home', - type: 'both', - line: ['534 Erewhon St'], - city: 'PleasantVille', - district: 'Rainbow', - state: 'Vic', - postalCode: '3999', - period: { - start: '1974-12-25', - }, - }, - gender: 'female', - period: { - start: '2012', - }, - }, - ], - managingOrganization: { - reference: 'Organization/3454', - }, - }, - search: { - mode: 'include', - }, - }, - ], -}; diff --git a/packages/fhir-import/src/containers/ImportDetailOverView/tests/index.test.tsx b/packages/fhir-import/src/containers/ImportDetailOverView/tests/index.test.tsx deleted file mode 100644 index 0693dc5a3..000000000 --- a/packages/fhir-import/src/containers/ImportDetailOverView/tests/index.test.tsx +++ /dev/null @@ -1,155 +0,0 @@ -import { store } from '@opensrp/store'; -import { authenticateUser } from '@onaio/session-reducer'; -import React from 'react'; -import { Router } from 'react-router'; -import { QueryClientProvider } from 'react-query'; -import { ViewDetails } from '..'; -import { careTeam2, careTeam3500, careTeamWithIncluded } from './fixtures'; -import { createBrowserHistory } from 'history'; -import { createTestQueryClient } from '../../ListView/tests/utils'; -import nock from 'nock'; -import { cleanup, fireEvent, render, waitForElementToBeRemoved } from '@testing-library/react'; -import { createMemoryHistory } from 'history'; -import { URL_CARE_TEAM, careTeamResourceType } from '../../../constants'; - -const history = createBrowserHistory(); - -const testQueryClient = createTestQueryClient(); - -jest.mock('fhirclient', () => { - return jest.requireActual('fhirclient/lib/entry/browser'); -}); - -jest.mock('@opensrp/notifications', () => ({ - __esModule: true, - ...Object.assign({}, jest.requireActual('@opensrp/notifications')), -})); - -const props = { - fhirBaseURL: 'http://test.server.org', - careTeamId: '131411', -}; - -beforeAll(() => { - nock.disableNetConnect(); - store.dispatch( - authenticateUser( - true, - { - email: 'bob@example.com', - name: 'Bobbie', - username: 'RobertBaratheon', - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - { api_token: 'hunter2', oAuth2Data: { access_token: 'sometoken', state: 'abcde' } } - ) - ); -}); - -afterEach(() => { - nock.cleanAll(); - cleanup(); -}); - -afterAll(() => { - nock.enableNetConnect(); -}); - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const AppWrapper = (props: any) => { - return ( - - - - - - ); -}; - -test('works correctly', async () => { - nock(props.fhirBaseURL) - .get(`/${careTeamResourceType}/_search`) - .query({ _id: '131411', _include: 'CareTeam:*' }) - .reply(200, careTeamWithIncluded); - - const { queryByText } = render(); - await waitForElementToBeRemoved(queryByText(/Fetching Care team/i)); - - // see view details contents - const keyValuePairs = document.querySelectorAll( - 'div[data-testid="key-value"] .singleKeyValue-pair__default' - ); - keyValuePairs.forEach((pair) => { - expect(pair).toMatchSnapshot(); - }); - - expect(nock.pendingMocks()).toEqual([]); -}); - -test('Closes on clicking cancel (X) ', async () => { - const history = createMemoryHistory(); - history.push(URL_CARE_TEAM); - - const localProps = { - ...props, - careTeamId: '142534', - }; - - nock(props.fhirBaseURL) - .get(`/${careTeamResourceType}/_search`) - .query({ _id: localProps.careTeamId, _include: 'CareTeam:*' }) - .reply(200, careTeam2); - - const { queryByText } = render(); - await waitForElementToBeRemoved(queryByText(/Fetching Care team/i)); - - // see view details contents - const keyValuePairs = document.querySelectorAll( - 'div[data-testid="key-value"] .singleKeyValue-pair__default' - ); - keyValuePairs.forEach((pair) => { - expect(pair).toMatchSnapshot(); - }); - - // simulate clicking on close button - const button = document.querySelector('.flex-right button'); - fireEvent.click(button); - - expect(history.location.pathname).toEqual('/admin/CareTeams'); -}); - -test('shows broken page if fhir api is down', async () => { - nock(props.fhirBaseURL) - .get(`/${careTeamResourceType}/_search`) - .query({ _id: props.careTeamId, _include: 'CareTeam:*' }) - .replyWithError('coughid'); - - const { getByText, queryByText } = render(); - await waitForElementToBeRemoved(queryByText(/Fetching Care team/i)); - - expect(getByText(/coughid/)).toBeInTheDocument(); -}); - -test('1157 - view details errors out for careTeam 3500', async () => { - const thisProps = { - ...props, - careTeamId: '3500', - }; - nock(props.fhirBaseURL) - .get(`/${careTeamResourceType}/_search`) - .query({ _id: '3500', _include: 'CareTeam:*' }) - .reply(200, careTeam3500); - - const { queryByText } = render(); - await waitForElementToBeRemoved(queryByText(/Fetching Care team/i)); - - // see view details contents - const keyValuePairs = document.querySelectorAll( - 'div[data-testid="key-value"] .singleKeyValue-pair__default' - ); - keyValuePairs.forEach((pair) => { - expect(pair).toMatchSnapshot(); - }); - - expect(nock.pendingMocks()).toEqual([]); -}); diff --git a/packages/fhir-import/src/containers/ImportDetailOverView/index.css b/packages/fhir-import/src/containers/ImportDetailView/index.css similarity index 76% rename from packages/fhir-import/src/containers/ImportDetailOverView/index.css rename to packages/fhir-import/src/containers/ImportDetailView/index.css index a316a09b2..502c78a41 100644 --- a/packages/fhir-import/src/containers/ImportDetailOverView/index.css +++ b/packages/fhir-import/src/containers/ImportDetailView/index.css @@ -20,4 +20,14 @@ margin: 0; color: #fff; /* Color for the terminal text */ +} + +.view-details-container { + display: flex; + flex-direction: column; + align-items: flex-start; + padding: 16px; + gap: 14px; + background: #FFF; + border-radius: 12px; } \ No newline at end of file diff --git a/packages/fhir-import/src/containers/ImportDetailOverView/index.tsx b/packages/fhir-import/src/containers/ImportDetailView/index.tsx similarity index 75% rename from packages/fhir-import/src/containers/ImportDetailOverView/index.tsx rename to packages/fhir-import/src/containers/ImportDetailView/index.tsx index 8887c77c7..27c5b2143 100644 --- a/packages/fhir-import/src/containers/ImportDetailOverView/index.tsx +++ b/packages/fhir-import/src/containers/ImportDetailView/index.tsx @@ -1,16 +1,8 @@ -import React, { Fragment } from 'react'; -import { Col, Button, Alert, Spin, Tabs } from 'antd'; -import { CloseOutlined, SyncOutlined } from '@ant-design/icons'; +import React from 'react'; +import { Spin, Tabs } from 'antd'; import { useQuery } from 'react-query'; import { BrokenPage, - FHIRServiceClass, - getObjLike, - IdentifierUseCodes, - getResourcesFromBundle, - parseFhirHumanName, - viewDetailsQuery, - useSearchParams, } from '@opensrp/react-utils'; import { dataImportRQueryKey, IMPORT_DOMAIN_URI } from '../../constants'; import { useTranslation } from '../../mls'; @@ -27,17 +19,14 @@ export interface RouteComponentProps { } /** - * component that renders the details view to the right side - * of list view + * Details view for a single workflow during bulk uploads. * * @param props - detail view component props */ -export const ImportDetailViewDetails = (props: RouteComponentProps) => { +export const ImportDetailViewDetails = (_: RouteComponentProps) => { const params = useParams(); const workflowId = params.workflowId; const { t } = useTranslation(); - const { removeParam } = useSearchParams(); - console.log("We got here", { workflowId }) const { data, isLoading, error } = useQuery( [dataImportRQueryKey, workflowId], () => { @@ -56,7 +45,7 @@ export const ImportDetailViewDetails = (props: RouteComponentProps) => { } if (error && !data) { - return ; + return ; } if (!data) { @@ -92,18 +81,7 @@ export const ImportDetailViewDetails = (props: RouteComponentProps) => { {pageTitle} -
+
{ + return { + __esModule: true, + ...Object.assign({}, jest.requireActual('../../../constants')), + IMPORT_DOMAIN_URI: 'http://localhost', + }; +}); + +const { QueryClient, QueryClientProvider } = reactQuery; + +const queryClient = new QueryClient({ + defaultOptions: { + queries: { + retry: false, + cacheTime: 0, + }, + }, +}); + +jest.mock('@opensrp/notifications', () => ({ + __esModule: true, + ...Object.assign({}, jest.requireActual('@opensrp/notifications')), +})); + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const AppWrapper = (props: any) => { + return ( + + + + + + {(routeProps) => } + + + + + + ); +}; + +describe('Care Teams list view', () => { + beforeAll(() => { + nock.disableNetConnect(); + store.dispatch( + authenticateUser( + true, + { + email: 'bob@example.com', + name: 'Bobbie', + username: 'RobertBaratheon', + }, + // eslint-disable-next-line @typescript-eslint/naming-convention + { api_token: 'hunter2', oAuth2Data: { access_token: 'sometoken', state: 'abcde' } } + ) + ); + }); + afterAll(() => { + nock.enableNetConnect(); + }); + + afterEach(() => { + jest.resetAllMocks(); + jest.clearAllMocks(); + jest.restoreAllMocks(); + cleanup(); + }); + + it('renders correctly', async () => { + nock(constants.IMPORT_DOMAIN_URI).get('/$import/workflowId').reply(200, workflows[0]).persist(); + + const history = createMemoryHistory(); + history.push(`${constants.DATA_IMPORT_DETAIL_URL}/workflowId`); + + render( + + + + ); + + await waitForElementToBeRemoved(document.querySelector('.ant-spin')); + expect(nock.pendingMocks()).toEqual([]); + + expect(document.querySelector('title')).toMatchInlineSnapshot(` + + View details | 26aae779-0e6f-482d-82c3-a0fad1fd3689_orgToLocationAssignment + + `); + + expect(document.querySelector(".view-details-container")!.textContent).toMatchSnapshot("innerDetailsText"); + + expect(nock.pendingMocks()).toEqual([]); + }); +}); diff --git a/packages/fhir-import/src/containers/ImportListView/index.tsx b/packages/fhir-import/src/containers/ImportListView/index.tsx index 7fc22c0ae..c2410be25 100644 --- a/packages/fhir-import/src/containers/ImportListView/index.tsx +++ b/packages/fhir-import/src/containers/ImportListView/index.tsx @@ -1,39 +1,24 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import React from 'react'; import { Helmet } from 'react-helmet'; -import { Row, Col, Button, Divider, Dropdown, Popconfirm, Tag, Space } from 'antd'; -import type { MenuProps } from 'antd'; +import { Row, Col, Button } from 'antd'; import { BodyLayout, OpenSRPService } from '@opensrp/react-utils'; -import { MoreOutlined, CloudUploadOutlined } from '@ant-design/icons'; +import { CloudUploadOutlined } from '@ant-design/icons'; import { RouteComponentProps } from 'react-router'; import { useHistory, Link } from 'react-router-dom'; import { - FHIRServiceClass, - useSimpleTabularView, BrokenPage, - SearchForm, TableLayout, - useSearchParams, - viewDetailsQuery, } from '@opensrp/react-utils'; import { - DATA_IMPORT_LIST_URL, DATA_IMPORT_DETAIL_URL, DATA_IMPORT_CREATE_URL, dataImportRQueryKey, IMPORT_DOMAIN_URI } from '../../constants'; -import { ImportDetailViewDetails } from '../ImportDetailOverView'; -import { Dictionary } from '@onaio/utils'; -import { sendErrorNotification, sendSuccessNotification } from '@opensrp/notifications'; import { useTranslation } from '../../mls'; -import type { TFunction } from '@opensrp/i18n'; -import { ICareTeam } from '@smile-cdr/fhirts/dist/FHIR-R4/interfaces/ICareTeam'; -import { RbacCheck, useUserRole } from '@opensrp/rbac'; +import { RbacCheck } from '@opensrp/rbac'; import { useQuery } from 'react-query'; -import { customFetch } from 'opensrp-server-service/dist/types'; import { WorkflowDescription, formatTimestamp } from '../../helpers/utils'; -import { SortOrder } from 'antd/es/table/interface'; import { ImportStatusTag } from '../../components/statusTag' @@ -42,26 +27,15 @@ interface RouteParams { workflowId: string | undefined; } -interface Props { } - -export type ImportListPropTypes = Props & RouteComponentProps; - - - +export type ImportListPropTypes = RouteComponentProps; /** - * Function which shows the list of all roles and their details - * - * @param {Object} props - UserRolesList component props - * @returns {Function} returns User Roles list display + * Renders a list view for all bulk upload jobs. */ -export const DataImportList: React.FC = (props: ImportListPropTypes) => { +export const DataImportList = () => { const { t } = useTranslation(); const history = useHistory(); - const { sParams } = useSearchParams() - const resourceId = sParams.get(viewDetailsQuery) ?? undefined; - const { data, isFetching, isLoading, error } = useQuery(dataImportRQueryKey, () => { const service = new OpenSRPService("/$import", IMPORT_DOMAIN_URI) return service.list().then(res => { @@ -74,7 +48,6 @@ export const DataImportList: React.FC = (props: ImportListP } - // TODO - add sort const columns = [ { title: t('Workflow Id'), @@ -114,11 +87,11 @@ export const DataImportList: React.FC = (props: ImportListP render: (_: unknown, record: WorkflowDescription) => ( - <> - - {t('View')} - - + <> + + {t('View')} + + ), @@ -128,7 +101,7 @@ export const DataImportList: React.FC = (props: ImportListP const tableProps = { datasource: (data ?? []), columns, - loading: isFetching || isLoading, // TODO - add pagination + loading: isFetching || isLoading, }; const pageTitle = t('Data imports'); const headerProps = { @@ -148,17 +121,16 @@ export const DataImportList: React.FC = (props: ImportListP
- - - + + +
- {resourceId && } ); diff --git a/packages/fhir-import/src/containers/ImportListView/tests/__snapshots__/index-rtl.test.tsx.snap b/packages/fhir-import/src/containers/ImportListView/tests/__snapshots__/index-rtl.test.tsx.snap deleted file mode 100644 index b10ae19dc..000000000 --- a/packages/fhir-import/src/containers/ImportListView/tests/__snapshots__/index-rtl.test.tsx.snap +++ /dev/null @@ -1,301 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Care Teams list view renders correctly: table row 1 page 1 1`] = ` - - Care Team One - -`; - -exports[`Care Teams list view renders correctly: table row 1 page 1 2`] = ` - - - - Edit - -