import { configureStore } from '@reduxjs/toolkit';
import styleReducer from './styleSlice';
import mainReducer from './mainSlice';
import authSlice from './authSlice';
import openAiSlice from './openAiSlice';

import usersSlice from "./users/usersSlice";
import rolesSlice from "./roles/rolesSlice";
import permissionsSlice from "./permissions/permissionsSlice";
import organizationsSlice from "./organizations/organizationsSlice";
import tenantsSlice from "./tenants/tenantsSlice";
import productsSlice from "./products/productsSlice";
import warehousesSlice from "./warehouses/warehousesSlice";
import inventory_itemsSlice from "./inventory_items/inventory_itemsSlice";
import inventory_movementsSlice from "./inventory_movements/inventory_movementsSlice";
import customersSlice from "./customers/customersSlice";
import ordersSlice from "./orders/ordersSlice";
import order_itemsSlice from "./order_items/order_itemsSlice";
import invoicesSlice from "./invoices/invoicesSlice";
import paymentsSlice from "./payments/paymentsSlice";
import commission_plansSlice from "./commission_plans/commission_plansSlice";
import commission_rulesSlice from "./commission_rules/commission_rulesSlice";
import commissionsSlice from "./commissions/commissionsSlice";
import payoutsSlice from "./payouts/payoutsSlice";
import bonus_programsSlice from "./bonus_programs/bonus_programsSlice";
import referral_linksSlice from "./referral_links/referral_linksSlice";
import reseller_storesSlice from "./reseller_stores/reseller_storesSlice";
import store_pagesSlice from "./store_pages/store_pagesSlice";
import notificationsSlice from "./notifications/notificationsSlice";
import ai_insightsSlice from "./ai_insights/ai_insightsSlice";
import sales_targetsSlice from "./sales_targets/sales_targetsSlice";

export const store = configureStore({
  reducer: {
    style: styleReducer,
    main: mainReducer,
    auth: authSlice,
    openAi: openAiSlice,

users: usersSlice,
roles: rolesSlice,
permissions: permissionsSlice,
organizations: organizationsSlice,
tenants: tenantsSlice,
products: productsSlice,
warehouses: warehousesSlice,
inventory_items: inventory_itemsSlice,
inventory_movements: inventory_movementsSlice,
customers: customersSlice,
orders: ordersSlice,
order_items: order_itemsSlice,
invoices: invoicesSlice,
payments: paymentsSlice,
commission_plans: commission_plansSlice,
commission_rules: commission_rulesSlice,
commissions: commissionsSlice,
payouts: payoutsSlice,
bonus_programs: bonus_programsSlice,
referral_links: referral_linksSlice,
reseller_stores: reseller_storesSlice,
store_pages: store_pagesSlice,
notifications: notificationsSlice,
ai_insights: ai_insightsSlice,
sales_targets: sales_targetsSlice,
  },
})

// Infer the `RootState` and `AppDispatch` types from the store itself
export type RootState = ReturnType<typeof store.getState>
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch
