header.js
782 Bytes
import { HEADER_FETCH_REQUESTED, HEADER_FETCH_SUCCEEDED, HEADER_FETCH_FAILED, ADD_REPO } 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: []
}
case ADD_REPO:
return {
isFetching: false,
error_message: null,
headers: [
...state.headers,
action.repo
]
}
default:
return state
}
}
export default header