{"size": 951, "ext": "js", "max_stars_repo_path": "src/reducers/auth.js", "max_stars_repo_name": "martolini/firebase-chat", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/reducers/auth.js", "max_issues_repo_name": "martolini/firebase-chat", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/reducers/auth.js", "max_forks_repo_name": "martolini/firebase-chat", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 17.9433962264, "max_line_length": 48, "alphanum_fraction": 0.5005257624}
const initialState = {
  error: null,
  loading: false,
  user: null,
  uid: null
}

export default (state=initialState, action) => {
  switch(action.type) {
    case 'LOGIN_REQUEST':
      return {
        uid: null,
        user: null,
        error: null,
        loading: true
      }
    case 'LOGIN_SUCCESS':
      return {
        uid: action.uid,
        error: null,
        user: null,
        loading: false
      }
    case 'LOGIN_ERROR':
      return {
        error: action.error,
        user: null,
        loading: false,
        uid: null
      }
    case 'LOG_OUT':
      return initialState
    case 'FETCH_USER_REQUEST':
      return {
        ...state,
        loading: true
      }
    case 'USER_FETCHED':
      return {
        ...state,
        loading: false,
        user: action.user
      }
    case 'USER_CHANGED':
      return {
        ...state,
        user: action.user
      }
    default:
      return state
  }
}
