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

export const useronlineSlince = createSlice({
  name: "useronline",
  initialState: {
    user: [],
    visitor: [],
  },
  reducers: {
    setUserOnline: (state, action) => {
      state.user = action.payload;
    },

    setVisitorOnline: (state, action) => {
      state.visitor = action.payload;
    },
  },
  selectors: {
    selectUserOnline: (state) => state.user,
    selectVisitorOnline: (state) => state.visitor,
  },
});

export const { setUserOnline, setVisitorOnline } = useronlineSlince.actions;
export const { selectUserOnline, selectVisitorOnline } =
  useronlineSlince.selectors;

export default useronlineSlince.reducer;
