TDRChart
This commit is contained in:
40
redux/slices/tdrChartSlice.ts
Normal file
40
redux/slices/tdrChartSlice.ts
Normal 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;
|
||||
Reference in New Issue
Block a user