Skip to content

Commit

Permalink
fixbug
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Aug 19, 2024
1 parent b60aaff commit 837b52a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const ObjectsApiOptionsForm = ({index, name, label, schema, formData, onChange})
const {objectsApiGroup} = schema.properties;
const apiGroupChoices = getChoicesFromSchema(objectsApiGroup.enum, objectsApiGroup.enumNames);
const numErrors = filterErrors(name, validationErrors).length;
const defaultGroup = apiGroupChoices.length === 1 ? apiGroupChoices[0][0] : undefined;

return (
<Field name={name} label={label}>
Expand Down Expand Up @@ -76,10 +77,7 @@ const ObjectsApiOptionsForm = ({index, name, label, schema, formData, onChange})
initialValues={{
...formData,
// Ensure that if there's only one option, it is automatically selected.
objectsApiGroup:
formData.objectsApiGroup ?? apiGroupChoices.length === 1
? apiGroupChoices[0][0]
: undefined,
objectsApiGroup: formData.objectsApiGroup ?? defaultGroup,
}}
onSubmit={(values, actions) => {
onChange({formData: values});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const ZGWOptionsForm = ({index, name, label, schema, formData, onChange}) => {
);

const numErrors = filterErrors(name, validationErrors).length;

const defaultGroup = apiGroupChoices.length === 1 ? apiGroupChoices[0][0] : undefined;
return (
<Field name={name} label={label}>
<>
Expand Down Expand Up @@ -82,10 +82,7 @@ const ZGWOptionsForm = ({index, name, label, schema, formData, onChange}) => {
initialValues={{
...formData,
// Ensure that if there's only one option, it is automatically selected.
zgwApiGroup:
formData.zgwApiGroup ?? apiGroupChoices.length === 1
? apiGroupChoices[0][0]
: undefined,
zgwApiGroup: formData.zgwApiGroup ?? defaultGroup,
}}
onSubmit={(values, actions) => {
onChange({formData: values});
Expand Down Expand Up @@ -136,7 +133,7 @@ ZGWOptionsForm.propTypes = {
}).isRequired,
}).isRequired,
formData: PropTypes.shape({
zgwApiGroup: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
zgwApiGroup: PropTypes.number,
zaaktype: PropTypes.string,
informatieobjecttype: PropTypes.string,
organisatieRsin: PropTypes.string,
Expand Down

0 comments on commit 837b52a

Please sign in to comment.