import {configureStore, getDefaultMiddleware} from '@reduxjs/toolkit';
import {createCommonReducer} from '../reducers/common_reducer';
import {downloadReducer} from '../reducers/download_reducer';
import {errorReducer} from '../reducers/error_reducer';
import {installReducer} from '../reducers/install_reducer';
import {createMountReducer} from '../reducers/mount_reducer';
import {releaseVersionReducer} from '../reducers/release_version_reducer';
import {skynetReducer} from '../reducers/skynet_reducer';

export default function createAppStore(platformInfo, version, state) {
  const reducer = {
    common: createCommonReducer(platformInfo, version),
    download: downloadReducer,
    error: errorReducer,
    install: installReducer,
    mounts: createMountReducer(state),
    relver: releaseVersionReducer,
    skynet: skynetReducer,
  };

  const middleware = [...getDefaultMiddleware()];

  return configureStore({
    reducer,
    middleware,
    devTools: process.env.NODE_ENV !== 'production'
  });
}
