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 adminsSlice from "./admins/adminsSlice";
import city_doctorsSlice from "./city_doctors/city_doctorsSlice";
import rural_doctorsSlice from "./rural_doctors/rural_doctorsSlice";
import patientsSlice from "./patients/patientsSlice";
import medical_reportsSlice from "./medical_reports/medical_reportsSlice";
import medicinesSlice from "./medicines/medicinesSlice";
import inventory_updatesSlice from "./inventory_updates/inventory_updatesSlice";
import medicine_dispatchesSlice from "./medicine_dispatches/medicine_dispatchesSlice";
import dispatch_itemsSlice from "./dispatch_items/dispatch_itemsSlice";
import medical_campsSlice from "./medical_camps/medical_campsSlice";
import appointmentsSlice from "./appointments/appointmentsSlice";
import chat_threadsSlice from "./chat_threads/chat_threadsSlice";
import messagesSlice from "./messages/messagesSlice";
import notificationsSlice from "./notifications/notificationsSlice";
import trucksSlice from "./trucks/trucksSlice";
import truck_tracking_eventsSlice from "./truck_tracking_events/truck_tracking_eventsSlice";
import vaccination_remindersSlice from "./vaccination_reminders/vaccination_remindersSlice";
import medicine_remindersSlice from "./medicine_reminders/medicine_remindersSlice";
import ai_chat_sessionsSlice from "./ai_chat_sessions/ai_chat_sessionsSlice";
import ai_chat_messagesSlice from "./ai_chat_messages/ai_chat_messagesSlice";
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,
admins: adminsSlice,
city_doctors: city_doctorsSlice,
rural_doctors: rural_doctorsSlice,
patients: patientsSlice,
medical_reports: medical_reportsSlice,
medicines: medicinesSlice,
inventory_updates: inventory_updatesSlice,
medicine_dispatches: medicine_dispatchesSlice,
dispatch_items: dispatch_itemsSlice,
medical_camps: medical_campsSlice,
appointments: appointmentsSlice,
chat_threads: chat_threadsSlice,
messages: messagesSlice,
notifications: notificationsSlice,
trucks: trucksSlice,
truck_tracking_events: truck_tracking_eventsSlice,
vaccination_reminders: vaccination_remindersSlice,
medicine_reminders: medicine_remindersSlice,
ai_chat_sessions: ai_chat_sessionsSlice,
ai_chat_messages: ai_chat_messagesSlice,
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
