Skip to content

Commit

Permalink
feat: [DHIS2-15830] Add orgUnitId to plugin context
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikhaugstulen authored Sep 20, 2023
1 parent 212ecb3 commit b9ec237
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import { usePluginMessages } from './hooks/usePluginMessages';
import { usePluginCallbacks } from './hooks/usePluginCallbacks';
import { usePluginValues } from './hooks/usePluginValues';
import { formatPluginConfig } from './formatPluginConfig';
import { useLocationQuery } from '../../../utils/routing';

export const FormFieldPlugin = (props: ContainerProps) => {
const { pluginSource, fieldsMetadata, formId, onUpdateField, pluginContext } = props;
const metadataByPluginId = useMemo(() => Object.fromEntries(fieldsMetadata), [fieldsMetadata]);
const configuredPluginIds = useMemo(() => Object.keys(metadataByPluginId), [metadataByPluginId]);
const { orgUnitId } = useLocationQuery();

// Plugin related functionality and feedback
const { pluginValues } = usePluginValues(formId, metadataByPluginId, pluginContext);
Expand Down Expand Up @@ -39,6 +41,7 @@ export const FormFieldPlugin = (props: ContainerProps) => {

return (
<FormFieldPluginComponent
orgUnitId={orgUnitId}
pluginSource={pluginSource}
fieldsMetadata={formattedMetadata}
values={pluginValues}
Expand All @@ -50,3 +53,4 @@ export const FormFieldPlugin = (props: ContainerProps) => {
/>
);
};

Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export type ComponentProps = {|
fieldsMetadata: MetadataByPluginId,
formSubmitted: boolean,
values: { [id: string]: any },
orgUnitId: string,
setFieldValue: (SetFieldValueProps) => void,
errors: { [id: string]: Array<string> },
warnings: { [id: string]: Array<string> },
Expand Down

0 comments on commit b9ec237

Please sign in to comment.