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

// import {FETCH_STUDENT_DATA} from '../constants/student';

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

    // case getSuccessActionType(FETCH_STUDENT_DATA):
    //   return action.payload.user;

    default:
      return state;
  }
}

const types = [FETCH_USER_DATA];
// const types = [FETCH_USER_DATA, FETCH_STUDENT_DATA];

export default combineReducers({
  status: getStatusReducer(types),
  error: getErrorReducer(types),
  data
});
