{"size": 760, "ext": "js", "max_stars_repo_path": "client/store/restrictions.js", "max_stars_repo_name": "Grace-Shopper-Proj/ramen", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/store/restrictions.js", "max_issues_repo_name": "Grace-Shopper-Proj/ramen", "max_issues_repo_issues_event_min_datetime": "2018-07-23T21:48:06.000Z", "max_issues_repo_issues_event_max_datetime": "2018-09-02T01:02:34.000Z", "max_forks_repo_path": "client/store/restrictions.js", "max_forks_repo_name": "Grace-Shopper-Proj/ramen", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 86, "max_forks_count": null, "avg_line_length": 19.4871794872, "max_line_length": 58, "alphanum_fraction": 0.6828947368}
import axios from 'axios'

// ACTION TYPES

const GOT_RESTRICTIONS = 'GOT_RESTRICTIONS'

//ACTION CREATORS
export const gotRestrictions = restrictions => ({
  type: GOT_RESTRICTIONS,
  restrictions
})

//THUNK CREATORS
export const getRestrictions = () => {
  return async dispatch => {
    try {
      const response = await axios.get('/api/categories')
      const restrictions = response.data
      dispatch(gotRestrictions(restrictions))
    } catch (err) {
      console.error(err)
    }
  }
}

// INITIAL STATE
const allRestrictions = [] //an array of objects

//Reducer
export default function(state = allRestrictions, action) {
  switch (action.type) {
    case GOT_RESTRICTIONS:
      return action.restrictions

    default:
      return state
  }
}
