diff --git a/src/client/Elements/Select.jsx b/src/client/Elements/Select.jsx index 17eb48f..54ff536 100644 --- a/src/client/Elements/Select.jsx +++ b/src/client/Elements/Select.jsx @@ -2,25 +2,17 @@ import { Form, Select as AntSelect } from 'antd'; import { Status } from 'core/types/statuses'; import React from 'react'; -const Select = ({ - value, - setCurrentValue, - status, - options, - filter, - ...props -}) => { +const Select = ({ value, setCurrentValue, status, options, ...props }) => { return ( setCurrentValue(val)} > - {(filter ? filter(options) : options).map((option, i) => { + {options.map((option, i) => { if (option) return ( diff --git a/src/client/hocs/withStore.js b/src/client/hocs/withStore.js index c3981aa..bafed5d 100644 --- a/src/client/hocs/withStore.js +++ b/src/client/hocs/withStore.js @@ -28,7 +28,7 @@ export const withStoreValue = Component => ({ validator: () => {}, }, }); - const { options, filter } = useOptions(name); + const { options } = useOptions(name); return ( ({ validateStatus={validateStatus} message={message} options={options} - filter={filter} {...params} /> ); diff --git a/src/client/hooks/useOptions.js b/src/client/hooks/useOptions.js index 26cceca..e426b16 100644 --- a/src/client/hooks/useOptions.js +++ b/src/client/hooks/useOptions.js @@ -6,24 +6,22 @@ export const useOptions = elementName => { const filter = calculationStore.filters[elementName]; return { - options, - filter, + options: filter ? filter(options) : options, }; }; export const useTableOptions = ({ tableName, rowIndex, propName }) => { const { calculationStore } = useStores(); const options = - calculationStore.tables[tableName].options && - calculationStore.tables[tableName].options && - calculationStore.tables[tableName].options[propName] - ? calculationStore.tables[tableName].options[propName] - : []; + (calculationStore.tables[tableName].options && + calculationStore.tables[tableName].options && + calculationStore.tables[tableName].options[propName]) || + []; const filter = calculationStore.tables[tableName].filters && calculationStore.tables[tableName].filters[rowIndex] && - calculationStore.tables[tableName].filters[rowIndex][propName] - ? calculationStore.tables[tableName].filters[rowIndex][propName] - : []; - return { options, filter }; + calculationStore.tables[tableName].filters[rowIndex][propName]; + return { + options: filter ? filter(options) : options, + }; };