Files
CPLv4.0/redux/slices/tdmChartSlice.ts
ISA 20e20dec30 feat(redux): Rename all Redux slices and store keys to match file names for clarity
- 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
2025-04-01 12:26:41 +02:00

43 lines
1.1 KiB
TypeScript

// /redux/slices/tdmChartSlice.ts
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { fetchAllTDMData } from "../thunks/fetchAllTDMThunk";
import type { TDMEntry } from "../types/tdmEntryTypes";
interface TDMChartState {
data: TDMEntry[][]; // 32 Arrays (je Slot)
loading: boolean;
error: string | null;
}
const initialState: TDMChartState = {
data: [],
loading: false,
error: null,
};
const tdmChartSlice = createSlice({
name: "tdmChartSlice",
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchAllTDMData.pending, (state) => {
state.loading = true;
state.error = null;
})
.addCase(
fetchAllTDMData.fulfilled,
(state, action: PayloadAction<TDMEntry[][]>) => {
state.loading = false;
state.data = action.payload;
}
)
.addCase(fetchAllTDMData.rejected, (state, action) => {
state.loading = false;
state.error = action.payload as string;
});
},
});
export default tdmChartSlice.reducer;