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

export const notificationConfig = {
  status: false,
  message: "",
  type: "",
  timeout: null,
};

export const notificationSlice = createSlice({
  name: "notification",
  initialState: {
    notification: notificationConfig,
  },
  reducers: {
    setNotification: (state, action) => {
      state.notification = action.payload;
    },

    resetNotification: (state) => {
      state.notification = notificationConfig;
    },
  },
  selectors: {
    selectNotification: (state) => state.notification,
  },
});

export const { setNotification, resetNotification } = notificationSlice.actions;
export const { selectNotification } = notificationSlice.selectors;

export default notificationSlice.reducer;
