import { configureStore } from "@reduxjs/toolkit"

import { appStateReducer } from "./appState"
import { notificationsReducer } from "./notifications"
import { userReducer } from "./user"

export const store = configureStore({
	reducer: {
		appState: appStateReducer,
		notifications: notificationsReducer,
		user: userReducer,
	},
})

if (typeof window !== "undefined" && process.env.NODE_ENV !== "production") {
	;(window as any).__REDUX_STORE__ = store
}

export type RootState = ReturnType<typeof store.getState>
export type AppDispatch = typeof store.dispatch
