feat: Projekt von JavaScript zu TypeScript migriert
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// redux/authSlice.js
|
||||
// redux/authSlice.ts
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
const authSlice = createSlice({
|
||||
11
store/rootReducer.ts
Normal file
11
store/rootReducer.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
// store/rootReducer.ts
|
||||
import { combineReducers } from "redux";
|
||||
import variablesReducer from "./variablesSlice";
|
||||
import authReducer from "./authSlice";
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
variables: variablesReducer,
|
||||
auth: authReducer,
|
||||
});
|
||||
|
||||
export default rootReducer;
|
||||
@@ -1,14 +0,0 @@
|
||||
// store/store.js
|
||||
import { configureStore } from "@reduxjs/toolkit";
|
||||
import variablesReducer from "./variablesSlice";
|
||||
import authReducer from "./authSlice";
|
||||
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
variables: variablesReducer,
|
||||
auth: authReducer,
|
||||
},
|
||||
//devTools: process.env.NODE_ENV !== "production", // Aktiviert DevTools nur in der Entwicklung
|
||||
});
|
||||
|
||||
export default store;
|
||||
16
store/store.ts
Normal file
16
store/store.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
// store/store.ts
|
||||
import { configureStore } from "@reduxjs/toolkit";
|
||||
import rootReducer from "./rootReducer";
|
||||
|
||||
const store = configureStore({
|
||||
reducer: rootReducer,
|
||||
//devTools: process.env.NODE_ENV !== "production",
|
||||
});
|
||||
|
||||
// Exportiere den Typ RootState für den gesamten State
|
||||
export type RootState = ReturnType<typeof rootReducer>;
|
||||
export type AppDispatch = typeof store.dispatch;
|
||||
|
||||
export default store;
|
||||
|
||||
//devTools: process.env.NODE_ENV !== "production", // Aktiviert DevTools nur in der Entwicklung
|
||||
@@ -1,64 +0,0 @@
|
||||
// store/variablesSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
const initialState = {
|
||||
last20Messages: null,
|
||||
deviceName: null,
|
||||
mac1: null,
|
||||
ip: null,
|
||||
subnet: null,
|
||||
gateway: null,
|
||||
cplInternalTimestamp: null,
|
||||
ntp1: null,
|
||||
ntp2: null,
|
||||
ntp3: null,
|
||||
ntpTimezone: null,
|
||||
ntpActive: null,
|
||||
de: null,
|
||||
counter: null,
|
||||
flutter: null,
|
||||
kueOnline: [],
|
||||
kueID: [],
|
||||
kueIso: [],
|
||||
kuePSTmMinus96V: [],
|
||||
kueAlarm1: [],
|
||||
kueAlarm2: [],
|
||||
kueResidence: [],
|
||||
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,
|
||||
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, updateValues } =
|
||||
variablesSlice.actions;
|
||||
export default variablesSlice.reducer;
|
||||
148
store/variablesSlice.ts
Normal file
148
store/variablesSlice.ts
Normal file
@@ -0,0 +1,148 @@
|
||||
// store/variablesSlice.ts
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
// Typ für den State
|
||||
export interface VariablesState {
|
||||
//------------
|
||||
kueBezeichnungen: string[];
|
||||
isolationsgrenzwerte: number[];
|
||||
verzoegerung: number[];
|
||||
untereSchleifenGrenzwerte: number[];
|
||||
obereSchleifenGrenzwerte: number[];
|
||||
schleifenintervall: number[];
|
||||
//---------------
|
||||
last20Messages: string | null;
|
||||
deviceName: string | null;
|
||||
mac1: string | null;
|
||||
ip: string | null;
|
||||
subnet: string | null;
|
||||
gateway: string | null;
|
||||
cplInternalTimestamp: string | null;
|
||||
ntp1: string | null;
|
||||
ntp2: string | null;
|
||||
ntp3: string | null;
|
||||
ntpTimezone: string | null;
|
||||
ntpActive: boolean | null;
|
||||
de: string | null;
|
||||
counter: number | null;
|
||||
flutter: string | null;
|
||||
kueOnline: string[];
|
||||
kueID: string[];
|
||||
kueIso: string[];
|
||||
kuePSTmMinus96V: string[];
|
||||
kueAlarm1: string[];
|
||||
kueAlarm2: string[];
|
||||
kueResidence: string[];
|
||||
kueCableBreak: string[];
|
||||
kueGroundFault: string[];
|
||||
kueLimit1: number | null;
|
||||
kueLimit2Low: number | null;
|
||||
kueDelay1: number | null;
|
||||
kueLoopInterval: number | null;
|
||||
kueVersion: number[] | null;
|
||||
tdrAtten: number | null;
|
||||
tdrPulse: number | null;
|
||||
tdrSpeed: number | null;
|
||||
tdrAmp: number | null;
|
||||
tdrTrigger: number | null;
|
||||
tdrLocation: number | null;
|
||||
tdrActive: boolean | null;
|
||||
kueOverflow: string | null;
|
||||
tdrLast: string | null;
|
||||
appVersion: string | null;
|
||||
win_analogeEingaenge1: string | null;
|
||||
win_analogeEingaenge2: string | null;
|
||||
win_analogeEingaenge3: string | null;
|
||||
win_analogeEingaenge4: string | null;
|
||||
win_analogeEingaenge5: string | null;
|
||||
win_analogeEingaenge6: string | null;
|
||||
win_analogeEingaenge7: string | null;
|
||||
win_analogeEingaenge8: string | null;
|
||||
}
|
||||
|
||||
// Initialer Zustand
|
||||
const initialState: VariablesState = {
|
||||
//------------
|
||||
kueBezeichnungen: [],
|
||||
isolationsgrenzwerte: [],
|
||||
verzoegerung: [],
|
||||
untereSchleifenGrenzwerte: [],
|
||||
obereSchleifenGrenzwerte: [],
|
||||
schleifenintervall: [],
|
||||
//---------------
|
||||
last20Messages: null,
|
||||
deviceName: null,
|
||||
mac1: null,
|
||||
ip: null,
|
||||
subnet: null,
|
||||
gateway: null,
|
||||
cplInternalTimestamp: null,
|
||||
ntp1: null,
|
||||
ntp2: null,
|
||||
ntp3: null,
|
||||
ntpTimezone: null,
|
||||
ntpActive: null,
|
||||
de: null,
|
||||
counter: null,
|
||||
flutter: null,
|
||||
kueOnline: [],
|
||||
kueID: [],
|
||||
kueIso: [],
|
||||
kuePSTmMinus96V: [],
|
||||
kueAlarm1: [],
|
||||
kueAlarm2: [],
|
||||
kueResidence: [],
|
||||
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,
|
||||
tdrLast: null,
|
||||
appVersion: null,
|
||||
win_analogeEingaenge1: null,
|
||||
win_analogeEingaenge2: null,
|
||||
win_analogeEingaenge3: null,
|
||||
win_analogeEingaenge4: null,
|
||||
win_analogeEingaenge5: null,
|
||||
win_analogeEingaenge6: null,
|
||||
win_analogeEingaenge7: null,
|
||||
win_analogeEingaenge8: null,
|
||||
};
|
||||
|
||||
// Slice erstellen
|
||||
const variablesSlice = createSlice({
|
||||
name: "variables",
|
||||
initialState,
|
||||
reducers: {
|
||||
setVariable(
|
||||
state,
|
||||
action: PayloadAction<{
|
||||
key: keyof VariablesState;
|
||||
value: VariablesState[keyof VariablesState];
|
||||
}>
|
||||
) {
|
||||
const { key, value } = action.payload;
|
||||
(state[key] as VariablesState[keyof VariablesState]) = value;
|
||||
},
|
||||
setVariables(state, action: PayloadAction<Partial<VariablesState>>) {
|
||||
Object.entries(action.payload).forEach(([key, value]) => {
|
||||
(state[
|
||||
key as keyof VariablesState
|
||||
] as VariablesState[keyof VariablesState]) = value!;
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setVariable, setVariables } = variablesSlice.actions;
|
||||
export default variablesSlice.reducer;
|
||||
Reference in New Issue
Block a user