{"size": 1181, "ext": "js", "max_stars_repo_path": "src/reducers/StudentReducer.js", "max_stars_repo_name": "labs11-studentdata/labs11-studentData-FE", "max_stars_repo_stars_event_min_datetime": "2019-03-20T18:23:37.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-20T18:23:37.000Z", "max_issues_repo_path": "src/reducers/StudentReducer.js", "max_issues_repo_name": "labs11-studentdata/labs11-studentData-FE", "max_issues_repo_issues_event_min_datetime": "2019-03-20T20:01:17.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-03T18:59:56.000Z", "max_forks_repo_path": "src/reducers/StudentReducer.js", "max_forks_repo_name": "labs11-studentdata/labs11-studentData-FE", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 18.746031746, "max_line_length": 72, "alphanum_fraction": 0.5453005927}
import {
  FAIL,
  FETCHING_STUDENTS,
  FETCHED_STUDENTS,
  UPDATING_STUDENT,
  UPDATED_STUDENT
} from '../actions/index';

const initialStudentState = {
  students: [],
  fetching: false,
  fetched: false,
  updating: false,
  updated: false,
  error: null,
  fail: false
}

export const StudentReducer = (state = initialStudentState, action) => {
  switch(action.type) {
    case FETCHING_STUDENTS:
      return{
        ...state,
        fetching: true,
        fetched: false,
        error: null,
        fail: false
      }
    case FETCHED_STUDENTS:
      return{
        ...state,
        fetching: false,
        fetched: true,
        students: action.payload,
        error: null,
        fail: false
      }
    case UPDATING_STUDENT:
      return{
        ...state,
        updating: true,
        updated: false,
        fail: false
      }
    case UPDATED_STUDENT:
      return{
        ...state,
        updating: false,
        updated: true,
        fail: false
      }
    case FAIL:
      return{
        ...state,
        fetching: false,
        fetched: false,
        error: action.payload,
        fail: true
      }
    default:
      return state;
  }
}