import { combineReducers } from 'redux';
import { getSuccessActionType } from '../utils';
import { getErrorReducer, getStatusReducer } from './utils/generators';
import { CREATE_REVIEW } from '../constants/review';
import { UPDATE_STUDENT_CARD_RATE } from '../constants/student-card';

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

    case getSuccessActionType(UPDATE_STUDENT_CARD_RATE):
      return { ...state, studentCard: action.payload };

    default:
      return state;
  }
}

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