У меня есть такой вариант возврата одного из case в reducer
const el = state.structure[action.id].childIds[0];
if(el) {
if(action.blockId) {
return {
...state,
structure: {
...state.structure,
[el] : {
...state.structure[el],
visibility: true
},
[action.id] : {
...state.structure[action.id],
render : action.render
},
[action.blockId] : {
...state.structure[action.blockId],
block: action.block,
}
}
};
} else {
return {
...state,
structure: {
...state.structure,
[el] : {
...state.structure[el],
visibility: true
},
[action.id] : {
...state.structure[action.id],
render : action.render
},
}
};
}
} else {
if(action.blockId) {
return {
...state,
structure: {
...state.structure,
[action.id] : {
...state.structure[action.id],
render : action.render
},
[action.blockId] : {
...state.structure[action.blockId],
block: action.block,
}
}
};
} else {
return {
...state,
structure: {
...state.structure,
[action.id] : {
...state.structure[action.id],
render : action.render
}
}
};
}
}
Как можно грамотно его переписать