Skip to content

Commit

Permalink
Move the tabs implementation in the commons-lib -tb/tpt app (#1898)
Browse files Browse the repository at this point in the history
* Move the tabs implementation in the commons-lib -tb/TPT

* Remove duplication of TPT summary and program management

* fix failing build
  • Loading branch information
lucyjemutai authored Jul 9, 2024
1 parent f561690 commit 41f1f66
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 128 deletions.
36 changes: 0 additions & 36 deletions packages/esm-tb-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,42 +106,6 @@
"slot": "tpt-program-management-summary-slot",
"component": "tptProgramManagementDashboard"
},


{
"name": "tpt-patient-summary",
"slot": "ohri-tpt-slot",
"component": "tptPatientSummaryDashboardLink",
"meta": {
"slot": "tpt-patient-summary-slot",
"columns": 1,
"path": "tpt-patient-summary",
"layoutMode": "anchored"
}
},
{
"name": "tpt-patient-summary-ext",
"slot": "tpt-patient-summary-slot",
"component": "tptPatientSummaryDashboard"
},

{
"name": "tpt-program-management-summary",
"slot": "ohri-tpt-slot",
"component": "tptProgramManagementDashboardLink",
"meta": {
"slot": "tpt-program-management-summary-slot",
"columns": 1,
"path": "tpt-program-management",
"layoutMode": "anchored"
}
},
{
"name": "tpt-program-management-summary-ext",
"slot": "tpt-program-management-summary-slot",
"component": "tptProgramManagementDashboard"
},

{
"name": "tb-treatment-follow-up-summary",
"slot": "ohri-tb-slot",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,18 @@
import React from 'react';
import { EncounterListTabsComponent } from '@ohri/openmrs-esm-ohri-commons-lib';
import { useConfig } from '@openmrs/esm-framework';
import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react';
import { type PatientChartProps, getMenuItemTabConfiguration, EncounterList } from '@ohri/openmrs-esm-ohri-commons-lib';
import { type PatientChartProps } from '@ohri/openmrs-esm-ohri-commons-lib';
import tptProgramManagemetConfigSchema from './tb-program-management-config.json';

import styles from '../common.scss';

const ProgramManagementSummary: React.FC<PatientChartProps> = ({ patientUuid }) => {
const config = useConfig();
const tabs = getMenuItemTabConfiguration(tptProgramManagemetConfigSchema, config);

return (
<div className={styles.tabContainer}>
<Tabs>
<TabList contained>
{tabs.map((tab) => (
<Tab key={tab.name}>{tab.name}</Tab>
))}
</TabList>
<TabPanels>
{tabs.map((tab) => (
<TabPanel>
<EncounterList
patientUuid={patientUuid}
formList={tab.formList}
columns={tab.columns}
encounterType={tab.encounterType}
launchOptions={tab.launchOptions}
headerTitle={tab.headerTitle}
description={tab.description}
/>
</TabPanel>
))}
</TabPanels>
</Tabs>
</div>
<EncounterListTabsComponent
patientUuid={patientUuid}
configSchema={tptProgramManagemetConfigSchema}
config={config}
/>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { EncounterListTabsComponent } from '@ohri/openmrs-esm-ohri-commons-lib';
import { useConfig } from '@openmrs/esm-framework';
import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib';
import tbFollowupConfigSchema from './tb-contact-listing-config.json';

interface OverviewListProps {
Expand All @@ -9,23 +9,8 @@ interface OverviewListProps {

const TbContactTracingList: React.FC<OverviewListProps> = ({ patientUuid }) => {
const config = useConfig();
const tabs = getMenuItemTabConfiguration(tbFollowupConfigSchema, config);

return (
<>
{tabs.map((tab) => (
<EncounterList
patientUuid={patientUuid}
encounterType={tab.encounterType}
formList={tab.formList}
columns={tab.columns}
description={tab.description}
headerTitle={tab.headerTitle}
launchOptions={tab.launchOptions}
/>
))}
</>
);
return <EncounterListTabsComponent patientUuid={patientUuid} configSchema={tbFollowupConfigSchema} config={config} />;
};

export default TbContactTracingList;
Original file line number Diff line number Diff line change
@@ -1,44 +1,21 @@
import React from 'react';
import { useConfig } from '@openmrs/esm-framework';
import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react';
import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib';
import { EncounterListTabsComponent } from '@ohri/openmrs-esm-ohri-commons-lib';
import tptProgramManagemetConfigSchema from './tpt-program-management-config.json';

import styles from '../../common.scss';

interface OverviewListProps {
patientUuid: string;
}

const TptProgramManagementSummary: React.FC<OverviewListProps> = ({ patientUuid }) => {
const config = useConfig();
const tabs = getMenuItemTabConfiguration(tptProgramManagemetConfigSchema, config);

return (
<div className={styles.tabContainer}>
<Tabs>
<TabList contained>
{tabs.map((tab) => (
<Tab key={tab.name}>{tab.name}</Tab>
))}
</TabList>
<TabPanels>
{tabs.map((tab) => (
<TabPanel>
<EncounterList
patientUuid={patientUuid}
formList={tab.formList}
columns={tab.columns}
encounterType={tab.encounterType}
launchOptions={tab.launchOptions}
headerTitle={tab.headerTitle}
description={tab.description}
/>
</TabPanel>
))}
</TabPanels>
</Tabs>
</div>
<EncounterListTabsComponent
patientUuid={patientUuid}
configSchema={tptProgramManagemetConfigSchema}
config={config}
/>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { useConfig } from '@openmrs/esm-framework';
import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib';
import { EncounterListTabsComponent } from '@ohri/openmrs-esm-ohri-commons-lib';
import tbFollowupConfigSchema from './tb-treatment-followup-config.json';

interface OverviewListProps {
Expand All @@ -9,23 +9,8 @@ interface OverviewListProps {

const TbTreatmentFollowUpList: React.FC<OverviewListProps> = ({ patientUuid }) => {
const config = useConfig();
const tabs = getMenuItemTabConfiguration(tbFollowupConfigSchema, config);

return (
<>
{tabs.map((tab) => (
<EncounterList
patientUuid={patientUuid}
encounterType={tab.encounterType}
formList={tab.formList}
columns={tab.columns}
description={tab.description}
headerTitle={tab.headerTitle}
launchOptions={tab.launchOptions}
/>
))}
</>
);
return <EncounterListTabsComponent patientUuid={patientUuid} configSchema={tbFollowupConfigSchema} config={config} />;
};

export default TbTreatmentFollowUpList;

0 comments on commit 41f1f66

Please sign in to comment.