From c23831d30073b719fdca309fb65cc8b5c48c030e Mon Sep 17 00:00:00 2001 From: Denise Buder Date: Tue, 30 Jan 2024 12:25:31 +0100 Subject: [PATCH] rename target group page prop dataToInitialValues to input2State --- demo/admin/src/Routes.tsx | 2 +- .../common/brevoModuleConfig/targetGroupFormConfig.tsx | 2 +- packages/admin/src/targetGroups/TargetGroupForm.tsx | 10 +++++----- packages/admin/src/targetGroups/TargetGroupsPage.tsx | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/demo/admin/src/Routes.tsx b/demo/admin/src/Routes.tsx index cfea1bf4..22ff7dfa 100644 --- a/demo/admin/src/Routes.tsx +++ b/demo/admin/src/Routes.tsx @@ -34,7 +34,7 @@ export const Routes: React.FC = () => { scopeParts: ["domain", "language"], additionalFormFields: additionalFormConfig.additionalFormFields, nodeFragment: additionalFormConfig.nodeFragment, - dataToInitialValues: additionalFormConfig.dataToInitialValues, + input2State: additionalFormConfig.input2State, }); return ( diff --git a/demo/admin/src/common/brevoModuleConfig/targetGroupFormConfig.tsx b/demo/admin/src/common/brevoModuleConfig/targetGroupFormConfig.tsx index 6e8302e1..f93dd11b 100644 --- a/demo/admin/src/common/brevoModuleConfig/targetGroupFormConfig.tsx +++ b/demo/admin/src/common/brevoModuleConfig/targetGroupFormConfig.tsx @@ -28,7 +28,7 @@ export const additionalPageTreeNodeFieldsFragment = { }; export const additionalFormConfig = { - dataToInitialValues: (values?: { filters: { SALUTATION: Array } }) => { + input2State: (values?: { filters: { SALUTATION: Array } }) => { return { filters: { SALUTATION: values?.filters?.SALUTATION ?? [], diff --git a/packages/admin/src/targetGroups/TargetGroupForm.tsx b/packages/admin/src/targetGroups/TargetGroupForm.tsx index 2b1eb1c2..110beaab 100644 --- a/packages/admin/src/targetGroups/TargetGroupForm.tsx +++ b/packages/admin/src/targetGroups/TargetGroupForm.tsx @@ -44,10 +44,10 @@ interface FormProps { scope: ContentScopeInterface; additionalFormFields?: React.ReactNode; nodeFragment?: { name: string; fragment: DocumentNode }; - dataToInitialValues?: (values?: EditTargetGroupFinalFormValues) => EditTargetGroupFinalFormValues; + input2State?: (values?: EditTargetGroupFinalFormValues) => EditTargetGroupFinalFormValues; } -export function TargetGroupForm({ id, scope, additionalFormFields, dataToInitialValues, nodeFragment }: FormProps): React.ReactElement { +export function TargetGroupForm({ id, scope, additionalFormFields, input2State, nodeFragment }: FormProps): React.ReactElement { const stackApi = useStackApi(); const client = useApolloClient(); const mode = id ? "edit" : "add"; @@ -70,12 +70,12 @@ export function TargetGroupForm({ id, scope, additionalFormFields, dataToInitial const initialValues = React.useMemo>(() => { let additionalInitialValues = {}; - if (dataToInitialValues) { - additionalInitialValues = dataToInitialValues(data?.targetGroup); + if (input2State) { + additionalInitialValues = input2State(data?.targetGroup); } return data?.targetGroup ? { title: data.targetGroup.title, ...additionalInitialValues } : { ...additionalInitialValues }; - }, [data?.targetGroup, dataToInitialValues]); + }, [data?.targetGroup, input2State]); const saveConflict = useFormSaveConflict({ checkConflict: async () => { diff --git a/packages/admin/src/targetGroups/TargetGroupsPage.tsx b/packages/admin/src/targetGroups/TargetGroupsPage.tsx index c60ee296..c459c7a2 100644 --- a/packages/admin/src/targetGroups/TargetGroupsPage.tsx +++ b/packages/admin/src/targetGroups/TargetGroupsPage.tsx @@ -11,11 +11,11 @@ interface CreateContactsPageOptions { scopeParts: string[]; additionalFormFields?: React.ReactNode; nodeFragment?: { name: string; fragment: DocumentNode }; - dataToInitialValues?: (values?: EditTargetGroupFinalFormValues) => EditTargetGroupFinalFormValues; + input2State?: (values?: EditTargetGroupFinalFormValues) => EditTargetGroupFinalFormValues; valuesToOutput?: (values: EditTargetGroupFinalFormValues) => EditTargetGroupFinalFormValues; } -export function createTargetGroupsPage({ scopeParts, additionalFormFields, nodeFragment, dataToInitialValues }: CreateContactsPageOptions) { +export function createTargetGroupsPage({ scopeParts, additionalFormFields, nodeFragment, input2State }: CreateContactsPageOptions) { function TargetGroupsPage(): JSX.Element { const { scope: completeScope } = useContentScope(); const intl = useIntl(); @@ -41,7 +41,7 @@ export function createTargetGroupsPage({ scopeParts, additionalFormFields, nodeF scope={scope} additionalFormFields={additionalFormFields} nodeFragment={nodeFragment} - dataToInitialValues={dataToInitialValues} + input2State={input2State} /> )} @@ -53,7 +53,7 @@ export function createTargetGroupsPage({ scopeParts, additionalFormFields, nodeF scope={scope} additionalFormFields={additionalFormFields} nodeFragment={nodeFragment} - dataToInitialValues={dataToInitialValues} + input2State={input2State} />