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 organization_membershipsSlice from "./organization_memberships/organization_membershipsSlice";
import role_permissionsSlice from "./role_permissions/role_permissionsSlice";
import addressesSlice from "./addresses/addressesSlice";
import customersSlice from "./customers/customersSlice";
import suppliersSlice from "./suppliers/suppliersSlice";
import payment_termsSlice from "./payment_terms/payment_termsSlice";
import taxesSlice from "./taxes/taxesSlice";
import unitsSlice from "./units/unitsSlice";
import categoriesSlice from "./categories/categoriesSlice";
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 price_listsSlice from "./price_lists/price_listsSlice";
import price_list_itemsSlice from "./price_list_items/price_list_itemsSlice";
import sales_ordersSlice from "./sales_orders/sales_ordersSlice";
import sales_order_linesSlice from "./sales_order_lines/sales_order_linesSlice";
import purchase_ordersSlice from "./purchase_orders/purchase_ordersSlice";
import purchase_order_linesSlice from "./purchase_order_lines/purchase_order_linesSlice";
import goods_receiptsSlice from "./goods_receipts/goods_receiptsSlice";
import goods_receipt_linesSlice from "./goods_receipt_lines/goods_receipt_linesSlice";
import shipmentsSlice from "./shipments/shipmentsSlice";
import shipment_linesSlice from "./shipment_lines/shipment_linesSlice";
import invoicesSlice from "./invoices/invoicesSlice";
import invoice_linesSlice from "./invoice_lines/invoice_linesSlice";
import paymentsSlice from "./payments/paymentsSlice";

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

users: usersSlice,
roles: rolesSlice,
permissions: permissionsSlice,
organizations: organizationsSlice,
organization_memberships: organization_membershipsSlice,
role_permissions: role_permissionsSlice,
addresses: addressesSlice,
customers: customersSlice,
suppliers: suppliersSlice,
payment_terms: payment_termsSlice,
taxes: taxesSlice,
units: unitsSlice,
categories: categoriesSlice,
products: productsSlice,
warehouses: warehousesSlice,
inventory_items: inventory_itemsSlice,
inventory_movements: inventory_movementsSlice,
price_lists: price_listsSlice,
price_list_items: price_list_itemsSlice,
sales_orders: sales_ordersSlice,
sales_order_lines: sales_order_linesSlice,
purchase_orders: purchase_ordersSlice,
purchase_order_lines: purchase_order_linesSlice,
goods_receipts: goods_receiptsSlice,
goods_receipt_lines: goods_receipt_linesSlice,
shipments: shipmentsSlice,
shipment_lines: shipment_linesSlice,
invoices: invoicesSlice,
invoice_lines: invoice_linesSlice,
payments: paymentsSlice,
  },
})

// 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
