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