-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from vivid-planet/add-dynamic-fields-to-target…
…-group-form COM-271: Add dynamic fields to target group form
- Loading branch information
Showing
7 changed files
with
135 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
demo/admin/src/common/brevoModuleConfig/targetGroupFormConfig.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { gql } from "@apollo/client"; | ||
import { Field, FinalFormSelect } from "@comet/admin"; | ||
import { MenuItem } from "@mui/material"; | ||
import { GQLBrevoContactSalutation } from "@src/graphql.generated"; | ||
import * as React from "react"; | ||
import { FormattedMessage } from "react-intl"; | ||
|
||
const salutationOptions: Array<{ label: React.ReactNode; value: GQLBrevoContactSalutation }> = [ | ||
{ | ||
label: <FormattedMessage id="targetGroup.filters.salutation.male." defaultMessage="Male" />, | ||
value: "MALE", | ||
}, | ||
{ | ||
label: <FormattedMessage id="targetGroup.filters.salutation.female." defaultMessage="Female" />, | ||
value: "FEMALE", | ||
}, | ||
]; | ||
|
||
export const additionalPageTreeNodeFieldsFragment = { | ||
fragment: gql` | ||
fragment TargetGroupFilters on TargetGroup { | ||
filters { | ||
SALUTATION | ||
} | ||
} | ||
`, | ||
name: "TargetGroupFilters", | ||
}; | ||
|
||
export const additionalFormConfig = { | ||
input2State: (values?: { filters: { SALUTATION: Array<GQLBrevoContactSalutation> } }) => { | ||
return { | ||
filters: { | ||
SALUTATION: values?.filters?.SALUTATION ?? [], | ||
}, | ||
}; | ||
}, | ||
nodeFragment: additionalPageTreeNodeFieldsFragment, | ||
additionalFormFields: ( | ||
<> | ||
<Field label={<FormattedMessage id="targetGroup.fields.salutation" defaultMessage="Salutation" />} name="filters.SALUTATION" fullWidth> | ||
{(props) => ( | ||
<FinalFormSelect {...props} fullWidth multiple clearable> | ||
{salutationOptions.map((option) => ( | ||
<MenuItem value={option.value} key={option.value}> | ||
{option.label} | ||
</MenuItem> | ||
))} | ||
</FinalFormSelect> | ||
)} | ||
</Field> | ||
</> | ||
), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"extends": "@comet/eslint-config/react", | ||
"ignorePatterns": ["src/*.generated.ts", "lib/**"] | ||
"ignorePatterns": ["**/*.generated.ts", "lib/**"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters