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

const globalVariablesSlice = createSlice({
  name: "globalVariables",
  initialState: {
    loginUser: null,
    currentTenant: null,
    selectedServiceId : null
  },
  reducers: {
    setGlobalVariable: (state, action) => {
      const { key, value } = action.payload;
      state[key] = value;
    },
    setLoginUserPermmisions: (state, action) => {
      state.loginUser = action.payload;
    },
    setCurrentTenant: (state, action) => {
      state.currentTenant = action.payload;
    },
      setService: (state, action) => {
      state.selectedServiceId = action.payload;
    },
  },
});

export const { setGlobalVariable, setLoginUserPermmisions, setCurrentTenant, setService} =
  globalVariablesSlice.actions;
export default globalVariablesSlice.reducer;
