import { configureStore, getDefaultMiddleware } from "@reduxjs/toolkit";
import rootReducer from './reducer'
import { persistStore, persistReducer } from 'redux-persist'
import sessionStorage from "redux-persist/es/storage/session";


const persistConfig = {
  key: 'root',
  storage: sessionStorage,
  version: 1,
}

const persistedReducer = persistReducer(persistConfig, rootReducer)

const store = configureStore({
    reducer: {root: persistedReducer},
    middleware: (getDefaultMiddleware) => getDefaultMiddleware({ serializableCheck: false }),
  })

const persistor = persistStore(store)

export default store;
export {persistor};
