import { configureStore, combineReducers } from "@reduxjs/toolkit";
import storage from "redux-persist/lib/storage";
import { persistReducer, persistStore } from "redux-persist";
import thunk from "redux-thunk";
import { userSlice } from "./slices/userSlice";
import { appSlice } from "./slices/appSlice";
import { avicultureSlice } from "./slices/avicultureSlice";
import { citySlice } from "./slices/citySlice";
import { slaughterSlice } from "./slices/slaughterSlice";
import { provinceSlice } from "./slices/provinceSlice";
import { fileSlice } from "./slices/fileSlice";
import { vetFarmSlice } from "./slices/vetFarmSlice";
import { auctionSlice } from "./slices/auctionSlice";
import { driverSlice } from "./slices/driverSlice";
import { provinceFinancialSlice } from "./slices/provinceFinancialSlice";
import { messageSlice } from "./slices/messageSlice";
import { inspectorSlice } from "./slices/inspectorSlice";
import { slaughterHouseVetSlice } from "./slices/slaughterHouseVetSlice";
import { ticketSlice } from "./slices/ticketSlice";
import { generalSlice } from "./slices/generalSlice";
import { adminSlice } from "./slices/adminSlice";
import { jahadSlice } from "./slices/jahadSlice";
import { liveStockSlice } from "./slices/liveStockSlice";
import { stewardSlice } from "./slices/stewardSlice";

const reducer = combineReducers({
  userSlice,
  appSlice,
  avicultureSlice,
  citySlice,
  slaughterSlice,
  provinceSlice,
  fileSlice,
  vetFarmSlice,
  auctionSlice,
  driverSlice,
  provinceFinancialSlice,
  messageSlice,
  inspectorSlice,
  slaughterHouseVetSlice,
  ticketSlice,
  generalSlice,
  adminSlice,
  jahadSlice,
  liveStockSlice,
  stewardSlice,
});

const persistConfig = {
  key: "root",
  storage,
};

const persistedReducer = persistReducer(persistConfig, reducer);

export const store = configureStore({
  reducer: persistedReducer,
  // devTools: process.env.NODE_ENV !== 'production',
  middleware: [thunk],
});

export const persistor = persistStore(store);
