Skip to content

Commit

Permalink
(fix) Tweak usage of config property in PageHeader
Browse files Browse the repository at this point in the history
Tweaks the usage of the config property in PageHeader to make it more robust. More specifically, this commit removes the destructuring of the config object in the component. Because this is a reusable component, the config schema that will be used is that of the consuming frontend module. Thus, the component should not make any assumptions about the shape of the config object. This commit also adds a check for the config object to make sure that the implementationName paragraph is rendered conditionally, based on whether the config object exists.
  • Loading branch information
denniskigen committed Aug 27, 2024
1 parent bc85c65 commit eb3005f
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,16 @@ export const PageHeader: React.FC<PageHeaderProps> = (props) => {
* ```
*/
export const PageHeaderContent: React.FC<PageHeaderContentProps> = ({ title, illustration, className }) => {
const { implementationName } = useConfig<StyleguideConfigObject>({
const config = useConfig<StyleguideConfigObject>({
// Do not remove this property. See https://github.com/openmrs/openmrs-esm-core/pull/1125#issuecomment-2313230513 for more context.
externalModuleName: '@openmrs/esm-styleguide',
});

return (
<div className={classNames(styles.pageHeaderContent, className)}>
{illustration}
<div className={styles.pageLabels}>
<p>{implementationName}</p>
{config?.implementationName && <p>{config.implementationName}</p>}
<p className={styles.pageName}>{title}</p>
</div>
</div>
Expand Down

0 comments on commit eb3005f

Please sign in to comment.