Skip to content

Commit

Permalink
rename target group page prop dataToInitialValues to input2State
Browse files Browse the repository at this point in the history
  • Loading branch information
RainbowBunchie committed Jan 30, 2024
1 parent 1cb7c7e commit c23831d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion demo/admin/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const additionalPageTreeNodeFieldsFragment = {
};

export const additionalFormConfig = {
dataToInitialValues: (values?: { filters: { SALUTATION: Array<GQLBrevoContactSalutation> } }) => {
input2State: (values?: { filters: { SALUTATION: Array<GQLBrevoContactSalutation> } }) => {
return {
filters: {
SALUTATION: values?.filters?.SALUTATION ?? [],
Expand Down
10 changes: 5 additions & 5 deletions packages/admin/src/targetGroups/TargetGroupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -70,12 +70,12 @@ export function TargetGroupForm({ id, scope, additionalFormFields, dataToInitial
const initialValues = React.useMemo<Partial<EditTargetGroupFinalFormValues>>(() => {
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 () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/admin/src/targetGroups/TargetGroupsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -41,7 +41,7 @@ export function createTargetGroupsPage({ scopeParts, additionalFormFields, nodeF
scope={scope}
additionalFormFields={additionalFormFields}
nodeFragment={nodeFragment}
dataToInitialValues={dataToInitialValues}
input2State={input2State}
/>
)}
</StackPage>
Expand All @@ -53,7 +53,7 @@ export function createTargetGroupsPage({ scopeParts, additionalFormFields, nodeF
scope={scope}
additionalFormFields={additionalFormFields}
nodeFragment={nodeFragment}
dataToInitialValues={dataToInitialValues}
input2State={input2State}
/>
</StackPage>
</StackSwitch>
Expand Down

0 comments on commit c23831d

Please sign in to comment.