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

const localVariablesSlice = createSlice({
  name: "localVariables",
  initialState: {
    selectedMaster:"Application Role",
    regularizationCount:0,
     defaultDateRange: {
      startDate: null,
      endDate: null,
    },
    projectId: null,
    reload:false
  
  },
  reducers: {
    changeMaster: (state, action) => {
        state.selectedMaster = action.payload;
    },
    updateRegularizationCount: (state, action) => {
      state.regularizationCount = action.payload;
    },
    setProjectId: (state, action) => { 
      localStorage.setItem("project",null)
      state.projectId = action.payload;
      localStorage.setItem("project",state.projectId)
    },
    refreshData: ( state, action ) =>
    {
      state.reload = action.payload
    },
    setDefaultDateRange: (state, action) => {
      state.defaultDateRange = action.payload;
    },
  },
});

export const { changeMaster ,updateRegularizationCount,setProjectId,refreshData,setDefaultDateRange} = localVariablesSlice.actions;
export default localVariablesSlice.reducer;
