soportes.js 687 Bytes
import { merge } from 'ramda'

import {
  REQUEST_SOPORTES,
  RECEIVE_SOPORTES,
  ERROR_SOPORTES
} from '../actions/soportes'


const soportes = {
  data: [],
  current: null,
  loading: true,
  pages: null,
  busqueda: { page: 1, text: '' },
}

export default (state, action) => {
  switch (action.type) {
    case REQUEST_SOPORTES:
      return merge(state, { loading: true, pages: null })
    case RECEIVE_SOPORTES:
      return merge(
        state,
        { loading: false, data: action.soportes, pages: action.pages })
    case ERROR_SOPORTES:
      return merge(
        state,
        { loading: false, data: [], pages: null })
    default:
      return state || soportes
  }
}