Skip to content

Commit

Permalink
[B2BP-715] Refactor Form component and add it to Strapi (#383)
Browse files Browse the repository at this point in the history
* Start refactoring work

* Refactor Form component and add it to Strapi

---------

Co-authored-by: Simone Salsi <[email protected]>
  • Loading branch information
simosalsi and Simone Salsi authored Jul 25, 2024
1 parent 271a06b commit 867e79b
Show file tree
Hide file tree
Showing 17 changed files with 443 additions and 342 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-hotels-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"strapi-cms": patch
---

Add Form section
5 changes: 5 additions & 0 deletions .changeset/tricky-weeks-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": patch
---

Refactor Form component and implement call to newsletter service
2 changes: 2 additions & 0 deletions apps/nextjs-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
"@mui/lab": "^5.0.0-alpha.170",
"@mui/material": "^5.14.14",
"@pagopa/mui-italia": "^1.0.1",
"@types/react-google-recaptcha": "^2.1.9",
"fp-ts": "^2.16.1",
"html-react-parser": "^5.0.11",
"io-ts": "^2.2.20",
"marked": "^11.1.0",
"next": "14.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-google-recaptcha": "^3.1.0",
"react-slick": "^0.30.2",
"slick-carousel": "^1.8.1"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
Checkbox,
Divider,
Grid,
FormControlLabel,
Radio,
Expand All @@ -9,64 +7,19 @@ import {
} from '@mui/material';
import {
FormCategoryProps,
OptionRowProps,
} from '@react-components/types/Form/Form.types';

export const OptionRow: React.FC<OptionRowProps> = ({
label,
checked,
onChange,
name,
additionalText,
color,
}) => (
<Grid container alignItems='center' justifyContent='space-between'>
<Grid item xs={additionalText ? 10 : true}>
<Typography variant='body1' fontWeight='bold' sx={{ color }}>
{label}
</Typography>
{additionalText && (
<Typography variant='body2' sx={{ color }}>
{additionalText}
</Typography>
)}
</Grid>
<Grid
item
xs={additionalText ? 2 : false}
sx={{ display: 'flex', justifyContent: 'flex-end' }}
>
<Checkbox
checked={checked}
onChange={onChange}
name={name}
sx={{
color: color,
'&.Mui-checked': {
color: color,
},
}}
/>
</Grid>
<Divider sx={{ width: '100%' }} />
</Grid>
);

export const FormCategories = ({
formCategories,
categories,
textColor,
borderColor,
selectedOption,
selectedCategory,
handleRadioChange,
}: FormCategoryProps & {
selectedOption: string;
handleRadioChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
}) => {
}: FormCategoryProps) => {
return (
<RadioGroup value={selectedOption} onChange={handleRadioChange}>
{formCategories.map(({ key, label, additionalLabel }) => (
<RadioGroup value={selectedCategory} onChange={handleRadioChange}>
{categories.map(({ categoryID, label, additionalInfo }) => (
<Grid
key={key}
container
alignItems='center'
justifyContent='space-between'
Expand All @@ -80,15 +33,15 @@ export const FormCategories = ({
>
{label}
</Typography>
{additionalLabel && (
{additionalInfo && (
<Typography variant='body2' sx={{ color: textColor }}>
{additionalLabel}
{additionalInfo}
</Typography>
)}
</Grid>
<Grid item sx={{ textAlign: 'right' }}>
<FormControlLabel
value={key}
value={categoryID}
control={
<Radio
sx={{
Expand Down
Loading

0 comments on commit 867e79b

Please sign in to comment.