// redux/slices/digitalOutputsSlice.ts
import { createSlice, PayloadAction } from "@reduxjs/toolkit";

// Typ für den Zustand der digitalen Ausgänge
interface DigitalOutput {
  id: number;
  label: string;
  status: boolean;
}

interface DigitalOutputsState {
  outputs: DigitalOutput[];
}

// Initialer Zustand
const initialState: DigitalOutputsState = {
  outputs: [],
};

// Slice erstellen
const digitalOutputsSlice = createSlice({
  name: "digitalOutputsSlice",
  initialState,
  reducers: {
    setDigitalOutputs(state, action: PayloadAction<DigitalOutput[]>) {
      state.outputs = action.payload;
    },
  },
});

// Aktionen exportieren
export const { setDigitalOutputs } = digitalOutputsSlice.actions;

// Reducer exportieren
export default digitalOutputsSlice.reducer;
