import { Trash } from "iconsax-react";
import { FC, useState } from "react";
import ModalConfrim from "./ModalConfrim";

interface Props {
  onDelete: () => void;
  isLoading?: boolean;
  size?: number;
  color?: string;
}

const TrashWithConfrim: FC<Props> = ({ onDelete, isLoading = false, size = 20, color = "#888" }) => {
  const [isConfirm, setIsConfirm] = useState(false);
  return (
    <div>
      <Trash onClick={() => setIsConfirm(true)} color={color} size={size} />

      <ModalConfrim isOpen={isConfirm} close={() => setIsConfirm(false)} onConfrim={() => onDelete()} isLoading={isLoading} />
    </div>
  );
};

export default TrashWithConfrim;
