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 plantsSlice from "./plants/plantsSlice";
import warehousesSlice from "./warehouses/warehousesSlice";
import work_centersSlice from "./work_centers/work_centersSlice";
import machinesSlice from "./machines/machinesSlice";
import maintenance_work_ordersSlice from "./maintenance_work_orders/maintenance_work_ordersSlice";
import downtime_eventsSlice from "./downtime_events/downtime_eventsSlice";
import itemsSlice from "./items/itemsSlice";
import item_filesSlice from "./item_files/item_filesSlice";
import bomsSlice from "./boms/bomsSlice";
import bom_linesSlice from "./bom_lines/bom_linesSlice";
import suppliersSlice from "./suppliers/suppliersSlice";
import purchase_ordersSlice from "./purchase_orders/purchase_ordersSlice";
import purchase_order_linesSlice from "./purchase_order_lines/purchase_order_linesSlice";
import inventory_lotsSlice from "./inventory_lots/inventory_lotsSlice";
import inventory_transactionsSlice from "./inventory_transactions/inventory_transactionsSlice";
import production_ordersSlice from "./production_orders/production_ordersSlice";
import production_operationsSlice from "./production_operations/production_operationsSlice";
import material_allocationsSlice from "./material_allocations/material_allocationsSlice";
import quality_inspectionsSlice from "./quality_inspections/quality_inspectionsSlice";
import nonconformancesSlice from "./nonconformances/nonconformancesSlice";
import capa_actionsSlice from "./capa_actions/capa_actionsSlice";
import audit_logsSlice from "./audit_logs/audit_logsSlice";

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

users: usersSlice,
roles: rolesSlice,
permissions: permissionsSlice,
organizations: organizationsSlice,
plants: plantsSlice,
warehouses: warehousesSlice,
work_centers: work_centersSlice,
machines: machinesSlice,
maintenance_work_orders: maintenance_work_ordersSlice,
downtime_events: downtime_eventsSlice,
items: itemsSlice,
item_files: item_filesSlice,
boms: bomsSlice,
bom_lines: bom_linesSlice,
suppliers: suppliersSlice,
purchase_orders: purchase_ordersSlice,
purchase_order_lines: purchase_order_linesSlice,
inventory_lots: inventory_lotsSlice,
inventory_transactions: inventory_transactionsSlice,
production_orders: production_ordersSlice,
production_operations: production_operationsSlice,
material_allocations: material_allocationsSlice,
quality_inspections: quality_inspectionsSlice,
nonconformances: nonconformancesSlice,
capa_actions: capa_actionsSlice,
audit_logs: audit_logsSlice,
  },
})

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