// /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;
