import { configureStore } from "@reduxjs/toolkit";
import logger from "redux-logger";
import appReducer from "./app.slice";

const store = configureStore({
  reducer: { app: appReducer },
  middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(logger),
});

// Infer the `RootState` and `AppDispatch` types from the store itself
export type RootState = ReturnType<typeof store.getState>;

// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch;
export type AppStore = typeof store;
export default store;
