X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/cf48e928d4d334b0b6434529d7619c616da319f2..09c61f87d52388ebfe97f478d536f4f194755401:/src/store/store.ts diff --git a/src/store/store.ts b/src/store/store.ts index 20ee09d406..6b9c31ff4e 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -2,26 +2,38 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { createStore, applyMiddleware, compose, Middleware } from 'redux'; -import { default as rootReducer, RootState } from "./root-reducer"; +import { createStore, applyMiddleware, compose, Middleware, combineReducers } from 'redux'; +import { routerMiddleware, routerReducer, RouterState } from "react-router-redux"; +import thunkMiddleware from 'redux-thunk'; +import { History } from "history"; +import projectsReducer, { ProjectState } from "./project/project-reducer"; +import authReducer, { AuthState } from "./auth/auth-reducer"; +import collectionsReducer from "./collection/collection-reducer"; const composeEnhancers = (process.env.NODE_ENV === 'development' && window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose; -function configureStore(initialState?: RootState) { - const middlewares: Middleware[] = []; - const enhancer = composeEnhancers(applyMiddleware(...middlewares)); - return createStore(rootReducer, initialState!, enhancer); +export interface RootState { + auth: AuthState; + projects: ProjectState; + router: RouterState; } -const store = configureStore({ - projects: [ - { name: 'Mouse genome', createdAt: '2018-05-01' }, - { name: 'Human body', createdAt: '2018-05-01' }, - { name: 'Secret operation', createdAt: '2018-05-01' } - ] +const rootReducer = combineReducers({ + auth: authReducer, + projects: projectsReducer, + collections: collectionsReducer, + router: routerReducer }); -export default store; + +export default function configureStore(initialState: RootState, history: History) { + const middlewares: Middleware[] = [ + routerMiddleware(history), + thunkMiddleware + ]; + const enhancer = composeEnhancers(applyMiddleware(...middlewares)); + return createStore(rootReducer, initialState!, enhancer); +}