{"size": 739, "ext": "js", "max_stars_repo_path": "src/reducers/authenticate.js", "max_stars_repo_name": "yury-dymov/redux-oauth", "max_stars_repo_stars_event_min_datetime": "2016-07-29T17:06:12.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-04T19:41:27.000Z", "max_issues_repo_path": "src/reducers/authenticate.js", "max_issues_repo_name": "yury-dymov/redux-oauth", "max_issues_repo_issues_event_min_datetime": "2016-09-09T00:51:59.000Z", "max_issues_repo_issues_event_max_datetime": "2017-09-13T20:44:22.000Z", "max_forks_repo_path": "src/reducers/authenticate.js", "max_forks_repo_name": "yury-dymov/redux-oauth", "max_forks_repo_forks_event_min_datetime": "2016-09-29T16:42:25.000Z", "max_forks_repo_forks_event_max_datetime": "2019-04-23T07:58:43.000Z"}
{"max_stars_count": 79, "max_issues_count": 10, "max_forks_count": 15, "avg_line_length": 27.3703703704, "max_line_length": 82, "alphanum_fraction": 0.5805142084}
import Immutable                                      from 'immutable';
import { createReducer }                              from 'redux-immutablejs';
import { AUTHENTICATE_COMPLETE, AUTHENTICATE_ERROR }  from 'actions/authenticate';
import { SIGN_OUT }                                   from 'actions/signOut';

const initialState = Immutable.fromJS({
  loading:  false,
  valid:    false,
  errors:   null
});

export default createReducer(initialState, {
  [AUTHENTICATE_COMPLETE]: state => state.merge({
    loading:  false,
    errors:   null,
    valid:    true
  }),

  [AUTHENTICATE_ERROR]: state => state.merge({
    loading:  false,
    errors:   'Invalid token',
    valid:    false
  }),

  [SIGN_OUT]: () => initialState
});
