appbaseio/reactivesearch

View on GitHub
packages/web/examples/withRedux/src/reducers/todos.js

Summary

Maintainability
A
0 mins
Test Coverage
const todos = (state = [], action) => {
    switch (action.type) {
        case 'ADD_TODO':
            return [
                ...state,
                {
                    id: action.id,
                    text: action.text,
                    completed: false,
                },
            ];
        case 'TOGGLE_TODO': // eslint-disable-next-line
            return state.map(
                todo => (todo.id === action.id ? { ...todo, completed: !todo.completed } : todo));
        default:
            return state;
    }
};

export default todos;