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

const initialState = {
  isUserShareMode: false,
  users: [],
  userOptions: null,
  message: '',

  accessLevel: '',
  hubs: [],
  hubOptions: null,
  sendHubsNotification: false,
};

export const slice = createSlice({
  name: '@@bulkActions/share',
  initialState,
  reducers: {
    setAction: (state, action) => {
      Object.keys(action.payload).forEach((key) => {
        state[key] = action.payload[key];
      });
    },
    clearAction: (state) => {
      Object.keys(initialState).forEach((key) => {
        state[key] = initialState[key];
      });
    },
    getUserOptionsAction: (state) => state,
    getHubOptionsAction: (state) => state,
  },
});

export const { setAction, clearAction, getUserOptionsAction, getHubOptionsAction } = slice.actions;
