36 lines
912 B
TypeScript
36 lines
912 B
TypeScript
// redux/thunks/getAnalogInputsHistoryThunk.ts
|
|
|
|
import { createAsyncThunk } from "@reduxjs/toolkit";
|
|
import { fetchAnalogInputsHistory } from "@/services/fetchAnalogInputsHistoryService";
|
|
import { AnalogInputsHistoryEntry } from "@/redux/slices/analogInputs/analogInputsHistorySlice";
|
|
|
|
export const getAnalogInputsHistoryThunk = createAsyncThunk(
|
|
"analogInputsHistory/fetch",
|
|
async (
|
|
{
|
|
eingang,
|
|
zeitraum,
|
|
vonDatum,
|
|
bisDatum,
|
|
}: {
|
|
eingang: number;
|
|
zeitraum: string;
|
|
vonDatum: string;
|
|
bisDatum: string;
|
|
},
|
|
thunkAPI
|
|
) => {
|
|
try {
|
|
const response = await fetchAnalogInputsHistory(eingang, zeitraum);
|
|
|
|
return {
|
|
eingang,
|
|
zeitraum,
|
|
daten: response.daten as AnalogInputsHistoryEntry[],
|
|
};
|
|
} catch (error: any) {
|
|
return thunkAPI.rejectWithValue(error.message ?? "Fehler beim Laden");
|
|
}
|
|
}
|
|
);
|