import { configureStore } from '@reduxjs/toolkit';
import authSlice from './slices/authSlice';
import dashboardSlice from '../pages/Dashboard/redux/dashboardSlice';
import requestsSlice from '../pages/Requests/redux/requestsSlice';
import myRequestsSlice from '../pages/MyRequests/redux/myRequestsSlice';
import openRequestsSlice from '../pages/OpenRequests/redux/openRequestsSlice';
import closedRequestsSlice from '../pages/ClosedRequests/redux/closedRequestsSlice';

export const store = configureStore({
  reducer: {
    auth: authSlice.reducer,
    dashboard: dashboardSlice.reducer,
    requests: requestsSlice.reducer,
    myRequests: myRequestsSlice.reducer,
    openRequests: openRequestsSlice.reducer,
    closedRequests: closedRequestsSlice.reducer,
  },
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware({
      serializableCheck: {
        ignoredActions: ['persist/PERSIST'],
      },
    }),
  devTools: process.env.NODE_ENV !== 'production',
});

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