From a5b16716fd6c82e7f4989ef971b507b2129e2415 Mon Sep 17 00:00:00 2001 From: Lucy Jemutai <130601439+lucyjemutai@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:31:02 +0300 Subject: [PATCH] Move the tabs implementation in the commons-lib -cacx (#1894) * 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 --- .../cacx-visits-services.component.tsx | 33 +------------- .../encounter-list-tabs.component.tsx | 43 +++++++++++++++++++ .../encounter-list-tabs.scss} | 2 +- packages/esm-commons-lib/src/index.ts | 1 + 4 files changed, 47 insertions(+), 32 deletions(-) create mode 100644 packages/esm-commons-lib/src/components/encounter-list-tabs/encounter-list-tabs.component.tsx rename packages/{esm-cervical-cancer-app/src/cervical-cancer/common.scss => esm-commons-lib/src/components/encounter-list-tabs/encounter-list-tabs.scss} (85%) diff --git a/packages/esm-cervical-cancer-app/src/cervical-cancer/cacx-visits/cacx-visits-services.component.tsx b/packages/esm-cervical-cancer-app/src/cervical-cancer/cacx-visits/cacx-visits-services.component.tsx index 29039051a..a86391ba1 100644 --- a/packages/esm-cervical-cancer-app/src/cervical-cancer/cacx-visits/cacx-visits-services.component.tsx +++ b/packages/esm-cervical-cancer-app/src/cervical-cancer/cacx-visits/cacx-visits-services.component.tsx @@ -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 = ({ patientUuid }) => { const config = useConfig(); - const tabs = getMenuItemTabConfiguration(cacxConfigSchema, config); - return ( -
- - - {tabs.map((tab) => ( - {tab.name} - ))} - - - {tabs.map((tab) => ( - - - - ))} - - -
- ); + return ; }; export default CaCxCervicalCancerServices; diff --git a/packages/esm-commons-lib/src/components/encounter-list-tabs/encounter-list-tabs.component.tsx b/packages/esm-commons-lib/src/components/encounter-list-tabs/encounter-list-tabs.component.tsx new file mode 100644 index 000000000..e53722bed --- /dev/null +++ b/packages/esm-commons-lib/src/components/encounter-list-tabs/encounter-list-tabs.component.tsx @@ -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 = ({ patientUuid, configSchema, config }) => { + const tabsConfig = getMenuItemTabConfiguration(configSchema, config); + + return ( +
+ + + {tabsConfig.map((tab) => ( + {tab.name} + ))} + + + {tabsConfig.map((tab) => ( + + + + ))} + + +
+ ); +}; + +export default TabsComponent; diff --git a/packages/esm-cervical-cancer-app/src/cervical-cancer/common.scss b/packages/esm-commons-lib/src/components/encounter-list-tabs/encounter-list-tabs.scss similarity index 85% rename from packages/esm-cervical-cancer-app/src/cervical-cancer/common.scss rename to packages/esm-commons-lib/src/components/encounter-list-tabs/encounter-list-tabs.scss index 831f26422..b68754591 100644 --- a/packages/esm-cervical-cancer-app/src/cervical-cancer/common.scss +++ b/packages/esm-commons-lib/src/components/encounter-list-tabs/encounter-list-tabs.scss @@ -1,5 +1,5 @@ @use '@carbon/styles/scss/spacing'; -@import '../root.scss'; +@import '../../root.scss'; .tabContainer div[role='tabpanel'] { padding: 0 !important; diff --git a/packages/esm-commons-lib/src/index.ts b/packages/esm-commons-lib/src/index.ts index 25f3548f3..f4982ca46 100644 --- a/packages/esm-commons-lib/src/index.ts +++ b/packages/esm-commons-lib/src/index.ts @@ -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',