import { createStore, combineReducers, applyMiddleware, compose } from "redux";
import mainReducer from "./reducers/mainReducer";
import thunk from "redux-thunk";
import {actionLogIn} from './actions/authActions';

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

const enhancer = composeEnhancers(applyMiddleware(thunk));

const store = createStore(mainReducer, enhancer); //вторым параметром идет


if(localStorage.authTocken){//используем для того чтобы перейти на основную страницу (треки) с поля регистрация
    store.dispatch(actionLogIn(localStorage.authTocken))
}
store.subscribe(()=>console.log(store.getState()));

export default store;
