Fix add compo to dz action

This commit is contained in:
soupette 2020-01-15 12:35:26 +01:00
parent 89568007f6
commit 16a6975af1
3 changed files with 10 additions and 10 deletions

View File

@ -81,8 +81,6 @@
"dz": {
"type": "dynamiczone",
"components": [
"default.closingperiod",
"default.dish",
"default.openingtimes",
"default.restaurantservice"
]

View File

@ -138,7 +138,7 @@ const MultipleMenuList = ({
const handleChange = ({ target }) => {
const dataTarget = {
name,
components: target.name,
components: [target.name],
shouldAddComponents: target.value,
};

View File

@ -1,4 +1,4 @@
import { fromJS } from 'immutable';
import { fromJS, List } from 'immutable';
import pluralize from 'pluralize';
import { snakeCase } from 'lodash';
import makeUnique from '../../utils/makeUnique';
@ -22,15 +22,17 @@ const reducer = (state, action) => {
const { name, components, shouldAddComponents } = action;
return state.updateIn(['modifiedData', name], list => {
let updatedList = list;
if (shouldAddComponents) {
return makeUnique(list.concat(components));
updatedList = list.concat(components);
} else {
return makeUnique(
list.filter(comp => {
return components.indexOf(comp) === -1;
})
);
updatedList = list.filter(comp => {
return components.indexOf(comp) === -1;
});
}
return List(makeUnique(updatedList.toJS()));
});
}
case 'ON_CHANGE':