Skip to content

Commit

Permalink
Move the tabs implementation in the commons-lib -cacx
Browse files Browse the repository at this point in the history
  • Loading branch information
lucyjemutai committed Jul 2, 2024
1 parent 7a261df commit 6154c84
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React from 'react';
import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react';
import { useConfig } from '@openmrs/esm-framework';
import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib';
import { getMenuItemTabConfiguration, TabsComponent } from '@ohri/openmrs-esm-ohri-commons-lib';
// import TabsComponent from '../../../../esm-commons-lib/src/components/encounter-tabs/encounter-tabs.component';
import cacxConfigSchema from './cacx-config.json';

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

interface OverviewListProps {
patientUuid: string;
}
Expand All @@ -14,32 +12,7 @@ const CaCxCervicalCancerServices: React.FC<OverviewListProps> = ({ patientUuid }
const config = useConfig();
const tabs = getMenuItemTabConfiguration(cacxConfigSchema, 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>
);
return <TabsComponent patientUuid={patientUuid} tabsConfig={tabs} />;
};

export default CaCxCervicalCancerServices;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';
import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react';
import { EncounterList } from '@ohri/openmrs-esm-ohri-commons-lib';
import styles from '../common.scss';

interface OverviewListProps {
patientUuid: string;
tabsConfig: any[];
}

const TabsComponent = ({ patientUuid, tabsConfig }: OverviewListProps) => {
return (
<div className={styles.tabContainer}>
<Tabs>
<TabList contained>
{tabsConfig.map((tab) => (
<Tab key={tab.name}>{tab.name}</Tab>
))}
</TabList>
<TabPanels>
{tabsConfig.map((tab) => (
<TabPanel key={tab.name}>
<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>
);
};

export default TabsComponent;

0 comments on commit 6154c84

Please sign in to comment.