import { configureStore } from "@reduxjs/toolkit";
import { dashboard } from "./Service/apiSlice";
import authReducer from "./Service/authSlice";
import { registerUser } from "./Service/register.user.service";
import { deactivatedAccounts } from "./Service/deactivated.account.service";
import { faqs } from "./Service/faqs.service";
import { managePosts } from "./Service/manage.posts.service";
import { manageSubAdmin } from "./Service/manage.subadmin.service";
import { manageJobs } from "./Service/manage.jobs.service";
import { manageGroups } from "./Service/manage.groups.service";
import { manageContactUs } from "./Service/manage.contactus.service";
import { aboutUs } from "./Service/manage.aboutus.service";
import { privacyPolicy } from "./Service/privacy.policy.service";
import { privacy } from "./Service/privacy.service";
import { myProfile } from "./Service/myprofie.service";
import { masterModule } from "./Service/master.module.service";

export const store = configureStore({
  reducer: {
    [dashboard.reducerPath]: dashboard.reducer,
    [registerUser.reducerPath]: registerUser.reducer,
    [deactivatedAccounts.reducerPath]: deactivatedAccounts.reducer,
    [faqs.reducerPath]: faqs.reducer,
    [managePosts.reducerPath]: managePosts.reducer,
    [manageSubAdmin.reducerPath]: manageSubAdmin.reducer,
    [manageJobs.reducerPath]: manageJobs.reducer,
    [manageGroups.reducerPath]: manageGroups.reducer,
    [manageContactUs.reducerPath]: manageContactUs.reducer,
    [aboutUs.reducerPath]: aboutUs.reducer,
    [privacyPolicy.reducerPath]: privacyPolicy.reducer,
    [privacy.reducerPath]: privacy.reducer,
    [myProfile.reducerPath]: myProfile.reducer,
    [masterModule.reducerPath]: masterModule.reducer,
    auth: authReducer,
  },
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware().concat(
      dashboard.middleware, 
      deactivatedAccounts.middleware,
      managePosts.middleware,
      faqs.middleware,
      manageSubAdmin.middleware,
      manageJobs.middleware,
      manageGroups.middleware,
      manageContactUs.middleware,
      aboutUs.middleware,
      privacyPolicy.middleware,
      privacy.middleware,
      myProfile.middleware,
      masterModule.middleware,
      ),
});

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