This commit is contained in:
Ismail Ali
2025-03-16 12:01:42 +01:00
parent 89994f767a
commit ea0e21892a
5 changed files with 62 additions and 10 deletions

View File

@@ -0,0 +1,40 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
// 🔹 State-Interface
interface TDRChartState {
dateiListe: string[];
sortAscending: boolean;
tdrChartData: { t: number; m: number }[];
}
// 🔹 Anfangsstate
const initialState: TDRChartState = {
dateiListe: [],
sortAscending: true,
tdrChartData: [],
};
// 🔹 Redux Slice
const tdrChartSlice = createSlice({
name: "tdrChart",
initialState,
reducers: {
setDateiListe: (state, action: PayloadAction<string[]>) => {
state.dateiListe = action.payload;
},
toggleSortOrder: (state) => {
state.sortAscending = !state.sortAscending;
state.dateiListe.reverse(); // 🔄 Reihenfolge umkehren
},
setTDRChartData: (
state,
action: PayloadAction<{ t: number; m: number }[]>
) => {
state.tdrChartData = action.payload;
},
},
});
export const { setDateiListe, toggleSortOrder, setTDRChartData } =
tdrChartSlice.actions;
export default tdrChartSlice.reducer;