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) => { 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;