- Renamed all slice names (createSlice `name` attribute) to match their file names (e.g. loopChartSlice, authSlice, kueDataSlice etc.) - Updated `store.ts` to register each reducer with consistent key names (e.g. state.loopChartSlice instead of state.loopChart) - Adjusted all `useSelector` and Redux state accesses across the codebase - Improves maintainability, searchability and consistency across files and Redux DevTools
51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
// /redux/slices/systemSettingsSlice.ts
|
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
|
|
interface SystemSettingsState {
|
|
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;
|
|
appVersion: string | null;
|
|
}
|
|
|
|
const initialState: SystemSettingsState = {
|
|
deviceName: "",
|
|
mac1: "",
|
|
ip: "",
|
|
subnet: "",
|
|
gateway: "",
|
|
cplInternalTimestamp: "",
|
|
ntp1: "",
|
|
ntp2: "",
|
|
ntp3: "",
|
|
ntpTimezone: "",
|
|
ntpActive: false,
|
|
appVersion: "",
|
|
};
|
|
|
|
const systemSettingsSlice = createSlice({
|
|
name: "systemSettingsSlice",
|
|
initialState,
|
|
reducers: {
|
|
setSystemSettings: (
|
|
state,
|
|
action: PayloadAction<Partial<SystemSettingsState>>
|
|
) => {
|
|
return { ...state, ...action.payload };
|
|
},
|
|
resetSystemSettings: () => initialState,
|
|
},
|
|
});
|
|
|
|
export const { setSystemSettings, resetSystemSettings } =
|
|
systemSettingsSlice.actions;
|
|
export default systemSettingsSlice.reducer;
|