reportes.js
764 Bytes
import { merge } from 'ramda'
import {
REPORTE_REQUESTED,
REPORTE_RECEIVED,
REPORTE_FAILED,
REPORTE_POST_SUCCESS,
REPORTE_POSTED,
} from '../actions/reportes'
const reporte = {
data: [],
loading: true,
error: null
}
export default (state, action) => {
switch (action.type) {
case REPORTE_REQUESTED:
return merge(state, reporte)
case REPORTE_RECEIVED:
return merge(state, { loading: false, error: null, data: action.reporte })
case REPORTE_POSTED:
return merge(state, { data: action.reporte })
case REPORTE_POST_SUCCESS:
return merge(state, { data: action.result.reporte })
case REPORTE_FAILED:
return merge(state, { loading: false, data: null, error: action.error })
default:
return state || reporte
}
}