header.js 595 Bytes
import { HEADER_FETCH_REQUESTED, HEADER_FETCH_SUCCEEDED, HEADER_FETCH_FAILED } from '../constants/ActionTypes'

const header = (state = {}, action) => {
  switch (action.type) {
    case HEADER_FETCH_REQUESTED:
      return {
        isFetching: true,
        headers: []
      }
    case HEADER_FETCH_SUCCEEDED:
      return {
        isFetching: false,
        headers: action.headers
      }
    case HEADER_FETCH_FAILED:
      return {
        isFetching: false,
        error_message: action.message,
        headers: []
      }
    default:
      return state
  }
}

export default header