import { createSlice } from '@reduxjs/toolkit';

const initialState = {
  rules: [],
  search: '',
  sourcesOptions: null,
  usersOptions: null,
  hubsOptions: null,
};

export const slice = createSlice({
  name: '@@userRulesSettings',
  initialState,

  reducers: {
    getSourcesOptionAction: (state) => state,
    getHubsOptionsAction: (state) => state,
    getUsersOptionsAction: (state) => state,
    saveRulesAction: (state) => state,
    getRulesAction: (state) => state,
    setModuleStateAction: (state, action) => ({
      ...state,
      ...action.payload,
    }),
  },
});

export const {
  getHubsOptionsAction,
  getRulesAction,
  getSourcesOptionAction,
  getUsersOptionsAction,
  saveRulesAction,
  setModuleStateAction,
} = slice.actions;

export default slice.reducer;
