const initStateNormalize = {
entities: {
1: {
id: 1,
text: 'Todo one'
}
},
result: [1]
};
const todosNormalized = ( state = initStateNormalize, action ) => {
switch( action.type ) {
case 'ADD_TODO':
return {
entities: {
...state.entities,
[action.payload.id]: action.payload
},
result: state.result.concat([action.payload.id])
}
default:
return state;
}
}