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

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

    default:
      return state;
  }
}

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