import * as types from 'app/types' import { crudState, crudReducer } from 'app/api/crud.reducer' import { applyMiddleware, compose, combineReducers, createStore } from 'redux' import { connectRouter, routerMiddleware } from 'connected-react-router' import { createBrowserHistory } from 'history' import thunk from 'redux-thunk' // import siteReducer from './site/site.reducer' const createRootReducer = history => ( combineReducers([ "media", "upload", "annotation", "paragraph", "episode", "venue", ].reduce((a, type) => { a[type] = crudReducer(type) return a }, { auth: (state = {}) => state, router: connectRouter(history), }) ) const configureStore = (initialState = {}, history) => { const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose const store = createStore( createRootReducer(history), initialState, composeEnhancers( applyMiddleware( thunk, routerMiddleware(history) ), ), ) return store } const history = createBrowserHistory() const store = configureStore({}, history) const { dispatch } = store export { store, history, dispatch }