diff --git a/src/client/Containers/Calculation/Sections/index.js b/src/client/Containers/Calculation/Sections/index.js index 3e8f2a6..b8d7f8e 100644 --- a/src/client/Containers/Calculation/Sections/index.js +++ b/src/client/Containers/Calculation/Sections/index.js @@ -4,6 +4,7 @@ import Checkbox from 'client/Elements/Checkbox'; import InputNumber from 'client/Elements/InputNumber'; import TextArea from 'client/Elements/TextArea'; import Switch from 'client/Elements/Switch'; +import Select from 'client/Elements/Select'; export default [ { @@ -64,6 +65,13 @@ export default [ name: 'switch', valueName: 'cbx' } + }, + { + Component: withTitle('Cars')(Select), + props: { + name: 'cars', + valueName: 'cars' + } } ] }, diff --git a/src/client/Elements/Select.jsx b/src/client/Elements/Select.jsx index c00b203..377e8c1 100644 --- a/src/client/Elements/Select.jsx +++ b/src/client/Elements/Select.jsx @@ -17,7 +17,7 @@ const Select = ({ name, showSearch, computedValue, valueName }) => { return ( { +export const useOptions = elementName => { const { calculationStore } = useStores(); - const options = calculationStore.options[elementName]; + const options = calculationStore.options[elementName] || []; const filter = calculationStore.filters[elementName]; return { diff --git a/src/client/hooks/useStatus.js b/src/client/hooks/useStatus.js index 44b7722..d1c017d 100644 --- a/src/client/hooks/useStatus.js +++ b/src/client/hooks/useStatus.js @@ -1,6 +1,6 @@ import { useStores } from './useStores'; -export const useStatus = ({ elementName }) => { +export const useStatus = elementName => { const { calculationStore } = useStores(); const status = calculationStore.statuses[elementName]; diff --git a/src/client/stores/CalculationStore/Effects/reaction.ts b/src/client/stores/CalculationStore/Effects/reaction.ts index e8aa50f..ccdcea7 100644 --- a/src/client/stores/CalculationStore/Effects/reaction.ts +++ b/src/client/stores/CalculationStore/Effects/reaction.ts @@ -1,4 +1,5 @@ import { IReactionEffect } from 'core/types/effect'; +import { Status } from 'core/types/elements'; const reactionEffects: IReactionEffect[] = [ calculationStore => ({ @@ -11,7 +12,18 @@ const reactionEffects: IReactionEffect[] = [ }), calculationStore => ({ expression: () => calculationStore.values.cbx, - effect: cbx => console.log('cbx: ', cbx) + effect: cbx => { + if (cbx === true) { + calculationStore.statuses.cars = Status.Disabled; + } else { + calculationStore.statuses.cars = Status.Default; + } + console.log('cbx: ', cbx); + } + }), + calculationStore => ({ + expression: () => calculationStore.values.cars, + effect: cars => console.log('cars: ', cars) }) ]; diff --git a/src/core/config/initialOptions.ts b/src/core/config/initialOptions.ts index 7876799..b31de16 100644 --- a/src/core/config/initialOptions.ts +++ b/src/core/config/initialOptions.ts @@ -1,5 +1,5 @@ const initialOptions: any = { - carsList: [ + cars: [ { name: 'Audi', value: '11111',