Skip to content

Commit

Permalink
[FIX] Show custom fields of invalid type (#18794)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellsh authored and sampaiodiego committed Sep 17, 2020
1 parent 0147927 commit 48e8e9d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions client/components/CustomFieldsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,21 @@ const CustomFieldsAssembler = ({ formValues, formHandlers, customFields, ...prop
state: formValues[key],
...value,
};
return value.type === 'text'
? <CustomTextInput {...extraProps} {...props}/>
: <CustomSelect {...extraProps} {...props}/>;

if (value.type === 'select') {
return <CustomSelect {...extraProps} {...props}/>;
}

if (value.type === 'text') {
return <CustomTextInput {...extraProps} {...props}/>;
}

return null;
});

export default function CustomFieldsForm({ customFieldsData, setCustomFieldsData, onLoadFields = () => {}, ...props }) {
const customFieldsJson = useSetting('Accounts_CustomFields');

// TODO: add deps. Left this way so that a possible change in the setting can't crash the page (useForm generates states automatically)
const [customFields] = useState(() => {
try {
return JSON.parse(customFieldsJson || '{}');
Expand Down

0 comments on commit 48e8e9d

Please sign in to comment.