From 6154c8494b189f7b07dda381acecde8adefdaacc Mon Sep 17 00:00:00 2001 From: lucille Date: Tue, 2 Jul 2024 14:59:39 +0300 Subject: [PATCH 1/5] Move the tabs implementation in the commons-lib -cacx --- .../cacx-visits-services.component.tsx | 33 ++------------- .../components/encounter-tabs}/common.scss | 0 .../encounter-tabs.component.tsx | 40 +++++++++++++++++++ 3 files changed, 43 insertions(+), 30 deletions(-) rename packages/{esm-cervical-cancer-app/src/cervical-cancer => esm-commons-lib/src/components/encounter-tabs}/common.scss (100%) create mode 100644 packages/esm-commons-lib/src/components/encounter-tabs/encounter-tabs.component.tsx 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..3fe18f03b 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,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; } @@ -14,32 +12,7 @@ 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-cervical-cancer-app/src/cervical-cancer/common.scss b/packages/esm-commons-lib/src/components/encounter-tabs/common.scss similarity index 100% rename from packages/esm-cervical-cancer-app/src/cervical-cancer/common.scss rename to packages/esm-commons-lib/src/components/encounter-tabs/common.scss diff --git a/packages/esm-commons-lib/src/components/encounter-tabs/encounter-tabs.component.tsx b/packages/esm-commons-lib/src/components/encounter-tabs/encounter-tabs.component.tsx new file mode 100644 index 000000000..91a37f189 --- /dev/null +++ b/packages/esm-commons-lib/src/components/encounter-tabs/encounter-tabs.component.tsx @@ -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 ( +
+ + + {tabsConfig.map((tab) => ( + {tab.name} + ))} + + + {tabsConfig.map((tab) => ( + + + + ))} + + +
+ ); +}; + +export default TabsComponent; From d43deae4c1e0cd6b581c668ea00318349816084b Mon Sep 17 00:00:00 2001 From: lucille Date: Tue, 2 Jul 2024 15:02:40 +0300 Subject: [PATCH 2/5] remove unused code --- .../cacx-visits/cacx-visits-services.component.tsx | 1 - 1 file changed, 1 deletion(-) 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 3fe18f03b..141e8ed55 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,7 +1,6 @@ import React from 'react'; import { useConfig } from '@openmrs/esm-framework'; 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'; interface OverviewListProps { From 1d53dcbcedaafa29344cab1aa188dce7637bbf06 Mon Sep 17 00:00:00 2001 From: lucille Date: Wed, 3 Jul 2024 08:55:38 +0300 Subject: [PATCH 3/5] update the imported TabsComponent --- .../esm-commons-lib/src/components/encounter-tabs/common.scss | 2 +- .../components/encounter-tabs/encounter-tabs.component.tsx | 4 ++-- packages/esm-commons-lib/src/index.ts | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/esm-commons-lib/src/components/encounter-tabs/common.scss b/packages/esm-commons-lib/src/components/encounter-tabs/common.scss index 831f26422..b68754591 100644 --- a/packages/esm-commons-lib/src/components/encounter-tabs/common.scss +++ b/packages/esm-commons-lib/src/components/encounter-tabs/common.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/components/encounter-tabs/encounter-tabs.component.tsx b/packages/esm-commons-lib/src/components/encounter-tabs/encounter-tabs.component.tsx index 91a37f189..ec8097d05 100644 --- a/packages/esm-commons-lib/src/components/encounter-tabs/encounter-tabs.component.tsx +++ b/packages/esm-commons-lib/src/components/encounter-tabs/encounter-tabs.component.tsx @@ -1,14 +1,14 @@ 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'; +import styles from './common.scss'; interface OverviewListProps { patientUuid: string; tabsConfig: any[]; } -const TabsComponent = ({ patientUuid, tabsConfig }: OverviewListProps) => { +export const TabsComponent: React.FC = ({ patientUuid, tabsConfig }) => { return (
diff --git a/packages/esm-commons-lib/src/index.ts b/packages/esm-commons-lib/src/index.ts index 25f3548f3..7fcaf7dfe 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-tabs/encounter-tabs.component'; // Workspace registration moved to the index.ts and routes.json const options = { featureName: 'ohri-forms-workspace-item', From ea169b5a96be5dd1d505daa4e713285f691cbf7c Mon Sep 17 00:00:00 2001 From: lucille Date: Wed, 3 Jul 2024 11:01:21 +0300 Subject: [PATCH 4/5] address comments on the PR --- .../cacx-visits/cacx-visits-services.component.tsx | 8 ++------ .../encounter-list-tabs.component.tsx} | 14 +++++++++----- .../encounter-list-tabs.scss} | 0 packages/esm-commons-lib/src/index.ts | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) rename packages/esm-commons-lib/src/components/{encounter-tabs/encounter-tabs.component.tsx => encounter-list-tabs/encounter-list-tabs.component.tsx} (67%) rename packages/esm-commons-lib/src/components/{encounter-tabs/common.scss => encounter-list-tabs/encounter-list-tabs.scss} (100%) 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 141e8ed55..06c75db21 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,6 +1,5 @@ import React from 'react'; -import { useConfig } from '@openmrs/esm-framework'; -import { getMenuItemTabConfiguration, TabsComponent } from '@ohri/openmrs-esm-ohri-commons-lib'; +import { TabsComponent } from '@ohri/openmrs-esm-ohri-commons-lib'; import cacxConfigSchema from './cacx-config.json'; interface OverviewListProps { @@ -8,10 +7,7 @@ interface OverviewListProps { } const CaCxCervicalCancerServices: React.FC = ({ patientUuid }) => { - const config = useConfig(); - const tabs = getMenuItemTabConfiguration(cacxConfigSchema, config); - - return ; + return ; }; export default CaCxCervicalCancerServices; diff --git a/packages/esm-commons-lib/src/components/encounter-tabs/encounter-tabs.component.tsx b/packages/esm-commons-lib/src/components/encounter-list-tabs/encounter-list-tabs.component.tsx similarity index 67% rename from packages/esm-commons-lib/src/components/encounter-tabs/encounter-tabs.component.tsx rename to packages/esm-commons-lib/src/components/encounter-list-tabs/encounter-list-tabs.component.tsx index ec8097d05..162d85a44 100644 --- a/packages/esm-commons-lib/src/components/encounter-tabs/encounter-tabs.component.tsx +++ b/packages/esm-commons-lib/src/components/encounter-list-tabs/encounter-list-tabs.component.tsx @@ -1,14 +1,18 @@ 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'; +import { useConfig } from '@openmrs/esm-framework'; +import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; +import styles from './encounter-list-tabs.scss'; -interface OverviewListProps { +interface TabsComponentProps { patientUuid: string; - tabsConfig: any[]; + configSchema: any; } -export const TabsComponent: React.FC = ({ patientUuid, tabsConfig }) => { +export const TabsComponent: React.FC = ({ patientUuid, configSchema }) => { + const config = useConfig(); + const tabsConfig = getMenuItemTabConfiguration(configSchema, config); + return (
diff --git a/packages/esm-commons-lib/src/components/encounter-tabs/common.scss b/packages/esm-commons-lib/src/components/encounter-list-tabs/encounter-list-tabs.scss similarity index 100% rename from packages/esm-commons-lib/src/components/encounter-tabs/common.scss rename to packages/esm-commons-lib/src/components/encounter-list-tabs/encounter-list-tabs.scss diff --git a/packages/esm-commons-lib/src/index.ts b/packages/esm-commons-lib/src/index.ts index 7fcaf7dfe..f4982ca46 100644 --- a/packages/esm-commons-lib/src/index.ts +++ b/packages/esm-commons-lib/src/index.ts @@ -55,7 +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-tabs/encounter-tabs.component'; +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', From ee940b09254a13eb7edab54386bb158ee214a184 Mon Sep 17 00:00:00 2001 From: lucille Date: Thu, 4 Jul 2024 15:00:33 +0300 Subject: [PATCH 5/5] pass the config at the package --- .../cacx-visits/cacx-visits-services.component.tsx | 5 ++++- .../encounter-list-tabs/encounter-list-tabs.component.tsx | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) 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 06c75db21..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,5 +1,6 @@ import React from 'react'; import { TabsComponent } from '@ohri/openmrs-esm-ohri-commons-lib'; +import { useConfig } from '@openmrs/esm-framework'; import cacxConfigSchema from './cacx-config.json'; interface OverviewListProps { @@ -7,7 +8,9 @@ interface OverviewListProps { } const CaCxCervicalCancerServices: React.FC = ({ patientUuid }) => { - return ; + const config = useConfig(); + + 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 index 162d85a44..e53722bed 100644 --- 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 @@ -1,16 +1,15 @@ 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 styles from './encounter-list-tabs.scss'; interface TabsComponentProps { patientUuid: string; configSchema: any; + config: any; } -export const TabsComponent: React.FC = ({ patientUuid, configSchema }) => { - const config = useConfig(); +export const TabsComponent: React.FC = ({ patientUuid, configSchema, config }) => { const tabsConfig = getMenuItemTabConfiguration(configSchema, config); return (