import {configureStore} from '@reduxjs/toolkit';
import {patientsApi} from '../Api/patientsApi.js';
import patientsUIReducer from './Slices/patientsSlice.js';
import {lensesApi} from '../Api/lensesApi.js';
import lensesUIReducer from './Slices/lensesSlice.js';
import {setsApi} from "../Api/setsApi.js";
import setsUIReducer from './Slices/setsSlice.js';
import {setContentApi} from "../Api/setContentApi.js";
import {lensIssuesApi} from "../Api/lensIssuesApi.js";
import lensIssuesReducer from "./Slices/lensIssuesSlice.js";
import {lensTypesApi} from "../Api/lensTypesApi.js";
import {appointmentsApi} from "../Api/appointmentsApi.js";
import appointmentsReducer from "./Slices/appointmentsSlice.js";
import {scheduledAppointmentsApi} from "../Api/scheduledAppointmentsApi.js";
import {appointmentTypesApi} from "../Api/appointmentTypesApi.js";
import {usersApi} from "../Api/usersApi.js";
import usersReducer from "./Slices/usersSlice.js";
import {authApi} from "../Api/authApi.js";
import authReducer from "./Slices/authSlice.js";

export const store = configureStore({
    reducer: {
        [patientsApi.reducerPath]: patientsApi.reducer,
        patientsUI: patientsUIReducer,

        [lensesApi.reducerPath]: lensesApi.reducer,
        lensesUI: lensesUIReducer,

        [setsApi.reducerPath]: setsApi.reducer,
        setsUI: setsUIReducer,

        [setContentApi.reducerPath]: setContentApi.reducer,

        [lensTypesApi.reducerPath]: lensTypesApi.reducer,

        [lensIssuesApi.reducerPath]: lensIssuesApi.reducer,
        lensIssuesUI: lensIssuesReducer,

        [appointmentsApi.reducerPath]: appointmentsApi.reducer,
        appointmentsUI: appointmentsReducer,

        [scheduledAppointmentsApi.reducerPath]: scheduledAppointmentsApi.reducer,

        [appointmentTypesApi.reducerPath]: appointmentTypesApi.reducer,

        [usersApi.reducerPath]: usersApi.reducer,
        usersUI: usersReducer,

        auth: authReducer,
        [authApi.reducerPath]: authApi.reducer,
    },
    middleware: (getDefaultMiddleware) => (
        getDefaultMiddleware().concat(
            patientsApi.middleware,
            lensesApi.middleware,
            setsApi.middleware,
            setContentApi.middleware,
            lensTypesApi.middleware,
            lensIssuesApi.middleware,
            appointmentsApi.middleware,
            scheduledAppointmentsApi.middleware,
            appointmentTypesApi.middleware,
            usersApi.middleware,
            authApi.middleware,
        )
    ),
});

export default store;