Skip to content

Commit

Permalink
Add defaultCategoryID field to Form (#385)
Browse files Browse the repository at this point in the history
Co-authored-by: Simone Salsi <[email protected]>
  • Loading branch information
simosalsi and Simone Salsi authored Jul 26, 2024
1 parent 5abfa9b commit bb5adf2
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-cars-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": patch
---

Add defaultCategoryID field to Form
5 changes: 5 additions & 0 deletions .changeset/stale-onions-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"strapi-cms": patch
---

Add defaultCategoryID field to Form
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const Form = ({
subtitle,
theme,
categoriesTitle,
defaultCategoryID,
categories,
clientID,
listID,
Expand Down Expand Up @@ -130,7 +131,7 @@ const Form = ({
method: 'POST',
body: JSON.stringify({
recaptchaToken,
groups: [formData.category],
groups: (categories.length > 0 && formData.category !== '') ? [formData.category] : [defaultCategoryID],
email: formData.email,
...(showName && { name: formData.name }),
...(showSurname && { surname: formData.surname }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface FormFields {

interface FormCategories {
readonly categoriesTitle?: string;
readonly defaultCategoryID: string;
readonly categories: {
categoryID: string,
label: string;
Expand Down
1 change: 1 addition & 0 deletions apps/nextjs-website/src/lib/fetch/types/PageSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ const FormSectionCodec = t.strict({
showSurname: t.boolean,
showOrganization: t.boolean,
categoriesTitle: t.union([t.string, t.null]),
defaultCategoryID: t.string,
categories: t.array(FormCategoryCodec),
theme: t.union([t.literal('light'), t.literal('dark')]),
recaptchaSiteKey: t.string,
Expand Down
1 change: 1 addition & 0 deletions apps/nextjs-website/stories/Form/formCommons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const generateFormProps = (theme: 'light' | 'dark'): FormProps => ({
{ label: 'Giornalista', categoryID: '5' },
],
categoriesTitle: 'Vorrei ricevere news sul progetto IO in qualità di*:',
defaultCategoryID: '61',
clientID: 'io',
listID: 'listID',
recaptchaSiteKey: 'sitekey'
Expand Down
4 changes: 4 additions & 0 deletions apps/strapi-cms/src/components/sections/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
"recaptchaSiteKey": {
"type": "string",
"required": true
},
"defaultCategoryID": {
"type": "string",
"required": true
}
}
}
2 changes: 1 addition & 1 deletion apps/strapi-cms/viewconfig.json

Large diffs are not rendered by default.

0 comments on commit bb5adf2

Please sign in to comment.