text: import {
    LOGIN_REQUEST, LOGIN_SUCCESS, LOGIN_FAILURE, LOGOUT_SUCCESS
  } from './actions'
  
  export default function auth(state = {
      isFetching: false,
      isAuthenticated: sessionStorage.getItem('token') ? true : false
    }, action) {
    switch (action.type) {
      case LOGIN_REQUEST:
        return Object.assign({}, state, {
          isFetching: true,
          isAuthenticated: false,
          user: action.credentials
        })
      case LOGIN_SUCCESS:
        return Object.assign({}, state, {
          isFetching: false,
          isAuthenticated: true,
          user: {},
          error: ''
        })
      case LOGIN_FAILURE:
        return Object.assign({}, state, {
          isFetching: false,
          isAuthenticated: false,
          user: {},
          error: action.error
        })
      case LOGOUT_SUCCESS:
        return Object.assign({}, state, {
          isFetching: true,
          isAuthenticated: false,
          user: {},
          token: '',
          error: ''
        })
      default:
        return state
    }
  }