2016-02-25 12:31:21 -08:00
|
|
|
import Immutable from 'immutable';
|
|
|
|
import { AUTH_REQUEST, AUTH_SUCCESS, AUTH_FAILURE } from '../actions/auth';
|
|
|
|
|
|
|
|
export function auth(state = null, action) {
|
|
|
|
switch (action.type) {
|
|
|
|
case AUTH_REQUEST:
|
|
|
|
return Immutable.Map({isFetching: true});
|
|
|
|
case AUTH_SUCCESS:
|
|
|
|
return Immutable.fromJS({user: action.payload});
|
|
|
|
case AUTH_FAILURE:
|
2016-05-30 16:55:32 -07:00
|
|
|
console.error(action.payload);
|
2016-02-25 12:31:21 -08:00
|
|
|
return Immutable.Map({error: action.payload.toString()});
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|