import { toast, Slide } from "react-toastify";

const colorTypes = {
  success: "#0C827B", // Green
  error: "#EF2424", // Red
  info: "#3E7BEA", // Blue
  warning: "#CEBB0F", // Yellow
};

export const notify = (
  message: string,
  colored: boolean,
  id?: string,
  colorType: keyof typeof colorTypes = "info",
) => {
  const color = colorTypes[colorType];

  toast(message, {
    position: "top-right",
    autoClose: 5000,
    hideProgressBar: false,
    closeOnClick: true,
    pauseOnHover: true,
    draggable: true,
    progress: colored ? undefined : 1,
    theme: colored ? "colored" : "light",
    transition: Slide,
    toastId: id,
    style: colored
      ? {
          backgroundColor: color,
          color: "white",
        }
      : {
          backgroundColor: "white",
          color: color,
        },
  });
};
