chore: fetch to get in redux thunks files name
This commit is contained in:
15
redux/thunks/getSystemVoltTempThunk.ts
Normal file
15
redux/thunks/getSystemVoltTempThunk.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
// /redux/thunks/getSystemVoltTempThunk.ts
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchSystemVoltTempService } from "../../services/fetchSystemVoltTempService";
|
||||
import { setVoltages, addHistory } from "../slices/systemVoltTempSlice";
|
||||
|
||||
export const getSystemVoltTempThunk = createAsyncThunk(
|
||||
"systemVoltTemp/fetch",
|
||||
async (_, { dispatch }) => {
|
||||
const data = await fetchSystemVoltTempService();
|
||||
if (data) {
|
||||
dispatch(setVoltages(data));
|
||||
dispatch(addHistory({ time: Date.now(), ...data }));
|
||||
}
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user