chore(tsconfig): fix moduleResolution and path aliases for Next.js project
This commit is contained in:
35
redux/thunks/getAllTDRChartThunk.ts
Normal file
35
redux/thunks/getAllTDRChartThunk.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
// /redux/thunks/getAllTDRChartThunk.ts
|
||||
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { RootState } from "../store";
|
||||
import isEqual from "lodash/isEqual";
|
||||
import { fetchAllTDRChartDataFromServer } from "@/services/fetchAllTDRChartDataService"; // ✅ importieren
|
||||
|
||||
export const fetchAllTDRChartData = createAsyncThunk(
|
||||
"tdrChart/fetchAllTDRChartData",
|
||||
async (_, { getState, rejectWithValue }) => {
|
||||
const state = getState() as RootState;
|
||||
const currentData = state.tdrChartSlice.data;
|
||||
|
||||
const newData = await fetchAllTDRChartDataFromServer(); // ✅ Service aufrufen
|
||||
|
||||
if (newData.every((d) => d === null || d === undefined)) {
|
||||
console.warn("⚠ Keine gültigen Daten empfangen.");
|
||||
return rejectWithValue("Keine gültigen Daten empfangen.");
|
||||
}
|
||||
|
||||
if (
|
||||
!isEqual(
|
||||
JSON.parse(JSON.stringify(currentData)),
|
||||
JSON.parse(JSON.stringify(newData))
|
||||
) ||
|
||||
currentData.length === 0
|
||||
) {
|
||||
console.log("🔥 Neue Daten erkannt – Redux wird aktualisiert.");
|
||||
return newData;
|
||||
} else {
|
||||
console.log("⚠ Keine signifikanten Änderungen erkannt.");
|
||||
return rejectWithValue("Keine Änderungen in den Daten.");
|
||||
}
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user