import { CONNECT, GET_CURRENT_USER_SUCCESS } from './actionTypes'
import { combineReducers } from 'redux'

let isNewLoginValue = false
export const nuxeoReducer = combineReducers({
  connect: (state = { isConnected: false }, action = {}) => {
    switch (action.type) {
      case CONNECT:
        return {
          ...state,
          isConnected: true,
          client: action.client,
        }
      default: // NOTE: do nothing
    }
    return { state } // NOTE: should this be `return state`?
  },

  computeLogin: (
    state = {
      isFetching: false,
      response: {
        get: () => {
          return ''
        },
      },
      success: false,
    },
    action = {}
  ) => {
    switch (action.type) {
      case GET_CURRENT_USER_SUCCESS: {
        const newLoginValue = isNewLoginValue
        isNewLoginValue = false
        return {
          ...state,
          response: action.user,
          isFetching: false,
          success: true,
          isConnected: !action.isAnonymous,
          isNewLogin: newLoginValue,
        }
      }

      default:
        return { ...state, isFetching: false }
    }
  },
})

@@ -410,35 +410,13 @@
 ult:
- // NOTE: do nothing
 %0A    
-%7D%0A
     
@@ -425,58 +425,20 @@
 turn
- %7B
  state
- %7D // NOTE: should this be %60return state%60?
+%0A    %7D
 %0A  %7D

Fix bad return `return { state }` > `return state`