Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
CynthiaKamau committed Oct 2, 2024
1 parent 71ce774 commit 5073fa3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { v4 as uuidv4 } from 'uuid';
import { Button, Accordion, AccordionItem, Tile } from '@carbon/react';
import { type DynamicExtensionSlot, type Schema } from '../../types';
import styles from './interactive-builder.scss';
import { getSubMenuSlotDetails } from '../../helpers';

interface InteractiveBuilderProps {
schema: Schema;
Expand Down Expand Up @@ -133,13 +134,6 @@ const InteractiveBuilder = ({ schema, onSchemaChange }: InteractiveBuilderProps)
submenuConfig.add.map((submenuKey) => {
const submenuDetails = submenuConfig.configure[submenuKey];
const subMenuSlot = submenuDetails?.slot;
const getSubMenuSlotDetails = (schema, subMenuSlot) => {
const patientChartApp = schema['@openmrs/esm-patient-chart-app'];
if (patientChartApp && patientChartApp.extensionSlots) {
return patientChartApp.extensionSlots[subMenuSlot];
}
return null;
};
const subMenuSlotDetails = getSubMenuSlotDetails(schema, subMenuSlot);
return (
<Accordion key={submenuKey}>
Expand Down
8 changes: 8 additions & 0 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ export const generateNodeId = (string) =>
return index === 0 ? word.toLowerCase() : word.toUpperCase();
})
.replace(/\s+/g, '');

export const getSubMenuSlotDetails = (schema, subMenuSlot) => {
const patientChartApp = schema['@openmrs/esm-patient-chart-app'];
if (patientChartApp && patientChartApp.extensionSlots) {
return patientChartApp.extensionSlots[subMenuSlot];
}
return null;
};

0 comments on commit 5073fa3

Please sign in to comment.