// /redux/store.ts
import { configureStore } from "@reduxjs/toolkit";
import { useDispatch } from "react-redux";
import authReducer from "./slices/authSlice";
import kueChartModeReducer from "./slices/kueChartModeSlice";
import webVersionReducer from "./slices/webVersionSlice";
import kabelueberwachungChartReducer from "./slices/kabelueberwachungChartSlice";
import last20MessagesReducer from "./slices/last20MessagesSlice";
import systemSettingsReducer from "./slices/systemSettingsSlice";
import opcuaSettingsReducer from "./slices/opcuaSettingsSlice";
import digitalOutputsReducer from "./slices/digitalOutputsSlice";
import brushReducer from "./slices/brushSlice";
import tdrChartReducer from "./slices/tdrChartSlice";
import analogeEingaengeReducer from "./slices/analogeEingaengeSlice";
import digitalInputsReducer from "./slices/digitalInputsSlice";
import tdrReferenceChartReducer from "./slices/tdrReferenceChartSlice";
import loopChartReducer from "./slices/loopChartSlice";
import tdmChartReducer from "./slices/tdmChartSlice";
import tdrDataByIdReducer from "./slices/tdrDataByIdSlice";
import kueDataReducer from "./slices/kueDataSlice";
import selectedChartDataReducer from "./slices/selectedChartDataSlice";

const store = configureStore({
  reducer: {
    auth: authReducer,
    kueChartMode: kueChartModeReducer,
    webVersion: webVersionReducer,
    digitalInputs: digitalInputsReducer,
    kabelueberwachungChart: kabelueberwachungChartReducer,
    last20Messages: last20MessagesReducer,
    systemSettings: systemSettingsReducer,
    opcuaSettings: opcuaSettingsReducer,
    digitalOutputs: digitalOutputsReducer,
    analogeEingaenge: analogeEingaengeReducer,
    brush: brushReducer,
    tdrChart: tdrChartReducer,
    tdrReferenceChart: tdrReferenceChartReducer,
    loopChart: loopChartReducer,
    tdmChart: tdmChartReducer,
    tdrDataById: tdrDataByIdReducer,
    kueData: kueDataReducer,
    selectedChartData: selectedChartDataReducer,
  },
});

export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
export const useAppDispatch: () => AppDispatch = useDispatch; // ✅ Typisierte Dispatch-Funktion

export default store;
