import { handleActions, Reducer } from "redux-actions";
import { TOAST_HIDE, TOAST_SHOW } from "../constants/toast";

const toast = handleActions(
  {
    [TOAST_SHOW]: (state, action) => ({
      ...state,
      ...action.payload,
      visible: true,
    }),
    [TOAST_HIDE]: (state) => ({
      ...state,
      visible: false,
    }),
  },
  {
    buttonLabel: "",
    message: "",
    type: "success",
    url: "",
    visible: false,
  },
);

export default toast;
