import { configureStore } from '@reduxjs/toolkit'
import {
  TypedUseSelectorHook,
  useDispatch as useDispatchRaw,
  useSelector as useSelectorRaw
} from 'react-redux'
import { hotsReducer } from './hots'
import { sceneReducer } from './scene'

const store = configureStore({
  reducer: {
    hots: hotsReducer,
    scenes: sceneReducer
  }
})

export type StoreState = ReturnType<typeof store.getState>
export type AppDispatch = typeof store.dispatch
export type AppSelector = TypedUseSelectorHook<StoreState>

export const useDispatch: () => AppDispatch = useDispatchRaw as any
export const useSelector: AppSelector = useSelectorRaw as any
export default store