- 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
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
// /redux/slices/tdrReferenceChartSlice.ts
|
|
|
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
import { fetchAllTDRReferenceChartThunk } from "../thunks/fetchAllTDRReferenceChartThunk";
|
|
|
|
interface TDRReferenceChartState {
|
|
referenceData: any[]; // Array mit Slot-Daten (Index = Slot)
|
|
loading: boolean;
|
|
error: string | null;
|
|
}
|
|
|
|
const initialState: TDRReferenceChartState = {
|
|
referenceData: [],
|
|
loading: false,
|
|
error: null,
|
|
};
|
|
|
|
const tdrReferenceChartSlice = createSlice({
|
|
name: "tdrReferenceChartSlice",
|
|
initialState,
|
|
reducers: {},
|
|
extraReducers: (builder) => {
|
|
builder
|
|
.addCase(fetchAllTDRReferenceChartThunk.pending, (state) => {
|
|
state.loading = true;
|
|
state.error = null;
|
|
})
|
|
.addCase(
|
|
fetchAllTDRReferenceChartThunk.fulfilled,
|
|
(state, action: PayloadAction<any[]>) => {
|
|
state.loading = false;
|
|
state.referenceData = action.payload;
|
|
}
|
|
)
|
|
.addCase(fetchAllTDRReferenceChartThunk.rejected, (state, action) => {
|
|
state.loading = false;
|
|
state.error = action.payload as string | null;
|
|
});
|
|
},
|
|
});
|
|
|
|
export default tdrReferenceChartSlice.reducer;
|