import styles from "./ToastCloseButton.module.scss";

import Image from "next/image";
import React from "react";

import closeToastIcon from "../../../public/icons/close-error-toast.svg";
import successToastIcon from "../../../public/icons/close-success-toast.svg";

interface Props {
  closeToast?: any;
  icon: "success" | "error";
}

const getIcon = (icon: "success" | "error") => {
  if (icon === "success") {
    return successToastIcon;
  }

  return closeToastIcon;
};

const ToastCloseButton = ({ closeToast, icon }: Props) => {
  return (
    <button className={styles.toastCloseButton} onClick={closeToast}>
      <Image src={getIcon(icon)} alt="" />
    </button>
  );
};

export default ToastCloseButton;
