- Renamed all slice names (createSlice `name` attribute) to match their file names (e.g. loopChartSlice, authSlice, kueDataSlice etc.) - Updated `store.ts` to register each reducer with consistent key names (e.g. state.loopChartSlice instead of state.loopChart) - Adjusted all `useSelector` and Redux state accesses across the codebase - Improves maintainability, searchability and consistency across files and Redux DevTools
36 lines
783 B
TypeScript
36 lines
783 B
TypeScript
// 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;
|