import { createStore, applyMiddleware, combineReducers } from 'redux'
import thunk from 'redux-thunk'
import { Provider, connect } from 'react-redux'
import { reducer as auth } from 'actions-client-auth'
import { reducer as errors } from 'actions-client-errors'
import { reducer as loading } from 'actions-client-loading'
import { reducer as admin } from './components/admin'
import { actions } from './actions'

export const reducer = combineReducers({
  auth,
  errors,
  loading,
  admin,
})

export const store = createStore(
  reducer,
  applyMiddleware(thunk)
)

export const storeConnect = connect(state => state, actions)
