import { combineReducers } from 'redux';
import { getSuccessActionType } from '../utils';
import { getErrorReducer, getStatusReducer } from './utils/generators';
import { FETCH_LESSONS } from '../constants/lesson';

function data(state = {}, action) {
  switch (action.type) {
    case getSuccessActionType(FETCH_LESSONS):
      return action.payload;

    default:
      return state;
  }
}

export default combineReducers({
  status: getStatusReducer([FETCH_LESSONS]),
  error: getErrorReducer([FETCH_LESSONS]),
  data
});
