1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { createStore, applyMiddleware, compose, Middleware, combineReducers } from 'redux';
6 import { routerMiddleware, routerReducer, RouterState } from "react-router-redux";
7 import thunkMiddleware from 'redux-thunk';
8 import { History } from "history";
9 import projectsReducer, { ProjectState } from "./project/project-reducer";
10 import authReducer, { AuthState } from "./auth/auth-reducer";
11 import collectionsReducer, { CollectionState } from "./collection/collection-reducer";
13 const composeEnhancers =
14 (process.env.NODE_ENV === 'development' &&
15 window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
18 export interface RootState {
20 projects: ProjectState;
21 collections: CollectionState;
25 const rootReducer = combineReducers({
27 projects: projectsReducer,
28 collections: collectionsReducer,
33 export default function configureStore(initialState: RootState, history: History) {
34 const middlewares: Middleware[] = [
35 routerMiddleware(history),
38 const enhancer = composeEnhancers(applyMiddleware(...middlewares));
39 return createStore(rootReducer, initialState!, enhancer);