Skip to content

Commit

Permalink
Revert all BasicCheckboxGroup changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ivonne-hernandez committed Aug 28, 2024
1 parent fa760a4 commit 982da60
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/Components/CheckboxGroup/BasicCheckboxGroup.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { FormControlLabel, FormGroup, Checkbox, FormControl, Typography } from '@mui/material';
import { FormControlLabel, FormGroup, Checkbox, FormControl } from '@mui/material';
import { useContext } from 'react';
import { Context } from '../Wrapper/Wrapper.tsx';
import { FormattedMessage } from 'react-intl';

const BasicCheckboxGroup = ({ stateVariable, options }) => {
const { formData: state, setFormData: setState } = useContext(Context);

const handleCheckboxChange = (event) => {
const { name } = event.target;

Expand All @@ -28,25 +28,13 @@ const BasicCheckboxGroup = ({ stateVariable, options }) => {
const optionKeys = Object.keys(options);

const formControlLabels = optionKeys.map((optionKey) => {
const { id: nameId, defaultMessage: nameDefaultMsg } = options[optionKey].name.props;
const { id: descId, defaultMessage: descDefaultMsg } = options[optionKey].description.props;

const createFormLabel = (nameId, nameDefaultMsg, descId, descDefaultMsg) => {
return (
<Typography>
<strong>{<FormattedMessage id={nameId} defaultMessage={nameDefaultMsg} />}: </strong>
<span>{<FormattedMessage id={descId} defaultMessage={descDefaultMsg} />}</span>
</Typography>
);
};

return (
<FormControlLabel
sx={{ alignItems: 'center', marginTop: `1rem` }}
sx={{ alignItems: 'center', marginTop: '1rem' }}
control={
<Checkbox checked={state[stateVariable][optionKey]} onChange={handleCheckboxChange} name={optionKey} />
}
label={createFormLabel(nameId, nameDefaultMsg, descId, descDefaultMsg)}
label={options[optionKey]}
key={optionKey}
/>
);
Expand All @@ -62,4 +50,4 @@ const BasicCheckboxGroup = ({ stateVariable, options }) => {
);
};

export default BasicCheckboxGroup;
export default BasicCheckboxGroup;

0 comments on commit 982da60

Please sign in to comment.