Skip to content

Commit

Permalink
Move the tabs implementation in the commons-lib -cacx (#1894)
Browse files Browse the repository at this point in the history
* Move the tabs implementation in the commons-lib -cacx

* remove unused code

* update the imported TabsComponent

* address comments on the PR

* pass the config at the package
  • Loading branch information
lucyjemutai authored Jul 4, 2024
1 parent cc439af commit a5b1671
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,45 +1,16 @@
import React from 'react';
import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react';
import { TabsComponent } from '@ohri/openmrs-esm-ohri-commons-lib';
import { useConfig } from '@openmrs/esm-framework';
import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib';
import cacxConfigSchema from './cacx-config.json';

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

interface OverviewListProps {
patientUuid: string;
}

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} configSchema={cacxConfigSchema} config={config} />;
};

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

interface TabsComponentProps {
patientUuid: string;
configSchema: any;
config: any;
}

export const TabsComponent: React.FC<TabsComponentProps> = ({ patientUuid, configSchema, config }) => {
const tabsConfig = getMenuItemTabConfiguration(configSchema, config);

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;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use '@carbon/styles/scss/spacing';
@import '../root.scss';
@import '../../root.scss';

.tabContainer div[role='tabpanel'] {
padding: 0 !important;
Expand Down
1 change: 1 addition & 0 deletions packages/esm-commons-lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export * from './utils/summary-card-config-builder';
export * from './utils/encounter-tile-config-builder';
export * from './utils/cohort-list-config-builder';
export * from './utils/patient-list-tabs-config-builder';
export * from './components/encounter-list-tabs/encounter-list-tabs.component';
// Workspace registration moved to the index.ts and routes.json
const options = {
featureName: 'ohri-forms-workspace-item',
Expand Down

0 comments on commit a5b1671

Please sign in to comment.