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 companiesSlice from "./companies/companiesSlice";
import plantsSlice from "./plants/plantsSlice";
import suppliersSlice from "./suppliers/suppliersSlice";
import customersSlice from "./customers/customersSlice";
import itemsSlice from "./items/itemsSlice";
import bomsSlice from "./boms/bomsSlice";
import bom_linesSlice from "./bom_lines/bom_linesSlice";
import warehousesSlice from "./warehouses/warehousesSlice";
import locationsSlice from "./locations/locationsSlice";
import lotsSlice from "./lots/lotsSlice";
import inventory_balancesSlice from "./inventory_balances/inventory_balancesSlice";
import inventory_transactionsSlice from "./inventory_transactions/inventory_transactionsSlice";
import machinesSlice from "./machines/machinesSlice";
import machine_downtime_eventsSlice from "./machine_downtime_events/machine_downtime_eventsSlice";
import work_ordersSlice from "./work_orders/work_ordersSlice";
import production_operationsSlice from "./production_operations/production_operationsSlice";
import material_issuesSlice from "./material_issues/material_issuesSlice";
import production_lotsSlice from "./production_lots/production_lotsSlice";
import qa_inspection_plansSlice from "./qa_inspection_plans/qa_inspection_plansSlice";
import qa_characteristicsSlice from "./qa_characteristics/qa_characteristicsSlice";
import qa_inspectionsSlice from "./qa_inspections/qa_inspectionsSlice";
import qa_resultsSlice from "./qa_results/qa_resultsSlice";
import nonconformancesSlice from "./nonconformances/nonconformancesSlice";
import capasSlice from "./capas/capasSlice";
import documentsSlice from "./documents/documentsSlice";
import audit_eventsSlice from "./audit_events/audit_eventsSlice";

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

users: usersSlice,
roles: rolesSlice,
permissions: permissionsSlice,
organizations: organizationsSlice,
companies: companiesSlice,
plants: plantsSlice,
suppliers: suppliersSlice,
customers: customersSlice,
items: itemsSlice,
boms: bomsSlice,
bom_lines: bom_linesSlice,
warehouses: warehousesSlice,
locations: locationsSlice,
lots: lotsSlice,
inventory_balances: inventory_balancesSlice,
inventory_transactions: inventory_transactionsSlice,
machines: machinesSlice,
machine_downtime_events: machine_downtime_eventsSlice,
work_orders: work_ordersSlice,
production_operations: production_operationsSlice,
material_issues: material_issuesSlice,
production_lots: production_lotsSlice,
qa_inspection_plans: qa_inspection_plansSlice,
qa_characteristics: qa_characteristicsSlice,
qa_inspections: qa_inspectionsSlice,
qa_results: qa_resultsSlice,
nonconformances: nonconformancesSlice,
capas: capasSlice,
documents: documentsSlice,
audit_events: audit_eventsSlice,
  },
})

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