import {configureStore} from '@reduxjs/toolkit';
import AuthenticationReducer from './slices/Authentication.slice';
import ChannelsReducer from './slices/Channels.slice';
import ChannelsPublishingReducer from './action/channels-publishing';
import ScreensReducer from './action/screens';
import PreferredTimeFormatReducer from './slices/PreferredTimeFormat.slice';
import {authenticateRequestMiddleware, loggerMiddleware, vanillaPromiseMiddleware} from './middlewares';

const store = configureStore({
  reducer: {
    authentication: AuthenticationReducer,
    channels: ChannelsReducer,
    channelsPublishing: ChannelsPublishingReducer,
    screens: ScreensReducer,
    preferredTimeFormat: PreferredTimeFormatReducer
  },
  middleware: getDefaultMiddleware =>
    getDefaultMiddleware({
      thunk: true,
      serializableCheck: false
    }).concat(authenticateRequestMiddleware, vanillaPromiseMiddleware, loggerMiddleware)
});

export default store;
