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

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

    default:
      return state;
  }
}

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