redux, redux-toolkit, react-rrdux
This commit is contained in:
11
store/store.js
Normal file
11
store/store.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// store/store.js
|
||||
import { configureStore } from "@reduxjs/toolkit";
|
||||
import variablesReducer from "./variablesSlice";
|
||||
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
variables: variablesReducer,
|
||||
},
|
||||
});
|
||||
|
||||
export default store;
|
||||
58
store/variablesSlice.js
Normal file
58
store/variablesSlice.js
Normal file
@@ -0,0 +1,58 @@
|
||||
// store/variablesSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
const initialState = {
|
||||
last20Messages: null,
|
||||
deviceName: null,
|
||||
mac1: null,
|
||||
mac2: null,
|
||||
ip: null,
|
||||
subnet: null,
|
||||
gateway: null,
|
||||
datetime: null,
|
||||
de: null,
|
||||
counter: null,
|
||||
flutter: null,
|
||||
kueOnline: [],
|
||||
kueID: [],
|
||||
kueAlarm1: [],
|
||||
kueAlarm2: [],
|
||||
kueRes: [],
|
||||
kueCableBreak: [],
|
||||
kueGroundFault: [],
|
||||
kueLimit1: null,
|
||||
kueLimit2Low: null,
|
||||
kueDelay1: null,
|
||||
kueLoopInterval: null,
|
||||
kueVersion: null,
|
||||
tdrAtten: null,
|
||||
tdrPulse: null,
|
||||
tdrSpeed: null,
|
||||
tdrAmp: null,
|
||||
tdrTrigger: null,
|
||||
tdrLocation: null,
|
||||
tdrActive: null,
|
||||
kueOverflow: null,
|
||||
kueResidence: null,
|
||||
tdrLast: null,
|
||||
appVersion: null,
|
||||
};
|
||||
|
||||
const variablesSlice = createSlice({
|
||||
name: "variables",
|
||||
initialState,
|
||||
reducers: {
|
||||
setVariable(state, action) {
|
||||
const { key, value } = action.payload;
|
||||
state[key] = value;
|
||||
},
|
||||
setVariables(state, action) {
|
||||
Object.entries(action.payload).forEach(([key, value]) => {
|
||||
state[key] = value;
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setVariable, setVariables } = variablesSlice.actions;
|
||||
export default variablesSlice.reducer;
|
||||
Reference in New Issue
Block a user