Skip to content

Commit

Permalink
feat: added orgUnitId and programId to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikhaugstulen committed Sep 12, 2023
1 parent 3cbd281 commit eb5a4b0
Show file tree
Hide file tree
Showing 2 changed files with 7 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 { programId, orgUnitId } = useLocationQuery();

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

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

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

0 comments on commit eb5a4b0

Please sign in to comment.