refactor: TDR-Daten in neuen tdrSingleChartSlice ausgelagert und nur pro Slot geladen
- Globalen fetchAllTDRChartData entfernt - Neuen Slice und Thunk pro Slot erstellt - TDRChart liest initiale Daten aus neuem Slice
This commit is contained in:
15
redux/thunks/fetchTDMDataBySlotThunk.ts
Normal file
15
redux/thunks/fetchTDMDataBySlotThunk.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
// /redux/thunks/fetchTDMDataBySlotThunk.ts
|
||||
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchTDMDataBySlot } from "../../services/fetchSingleTDMData";
|
||||
import { setLoopMeasurementCurveChartData } from "../slices/kabelueberwachungChartSlice";
|
||||
|
||||
export const fetchTDMDataBySlotThunk = createAsyncThunk(
|
||||
"tdmChart/fetchSlotData",
|
||||
async (slot: number, { dispatch }) => {
|
||||
const data = await fetchTDMDataBySlot(slot);
|
||||
if (data) {
|
||||
dispatch(setLoopMeasurementCurveChartData(data));
|
||||
}
|
||||
}
|
||||
);
|
||||
13
redux/thunks/fetchTDRChartDataBySlotThunk.ts
Normal file
13
redux/thunks/fetchTDRChartDataBySlotThunk.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// /redux/thunks/fetchTDRChartDataBySlotThunk.ts
|
||||
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchTDRChartDataBySlot } from "../../services/fetchSingleTDRChartData";
|
||||
|
||||
export const fetchTDRChartDataBySlotThunk = createAsyncThunk(
|
||||
"tdrChart/fetchSlotData",
|
||||
async (slot: number) => {
|
||||
const data = await fetchTDRChartDataBySlot(slot);
|
||||
if (!data) throw new Error(`Daten für Slot ${slot} nicht gefunden`);
|
||||
return { slot, data };
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user