2024-02-02 22:59:21 +08:00
|
|
|
import { faL } from "@fortawesome/free-solid-svg-icons";
|
|
|
|
import React from "react";
|
|
|
|
import Swal from "sweetalert2";
|
|
|
|
|
|
|
|
// 定义Props类型
|
|
|
|
interface SweetAlertComponentProps {
|
|
|
|
index: number;
|
|
|
|
removeReferenceUpdateIndex: (index: number, rmPg: boolean) => void;
|
|
|
|
}
|
|
|
|
|
2024-02-08 10:28:52 +08:00
|
|
|
const ParagraphDeleteButton: React.FC<any> = ({
|
2024-02-02 22:59:21 +08:00
|
|
|
index,
|
|
|
|
removeReferenceUpdateIndex,
|
2024-02-08 10:28:52 +08:00
|
|
|
isRemovePaper = false,
|
2024-02-09 23:01:05 +08:00
|
|
|
title = "需要同时删除与文献相关的整个段落吗?",
|
2024-02-08 10:28:52 +08:00
|
|
|
text = "根据周围的换行符来判断是否是同一个段落",
|
2024-02-02 22:59:21 +08:00
|
|
|
}) => {
|
2024-02-08 10:28:52 +08:00
|
|
|
//这里传递函数的时候应该把参数先提前弄好 2.7
|
2024-02-02 22:59:21 +08:00
|
|
|
const showAlert = async () => {
|
|
|
|
const result = await Swal.fire({
|
2024-02-08 10:28:52 +08:00
|
|
|
title: title,
|
|
|
|
text: text,
|
2024-02-02 22:59:21 +08:00
|
|
|
icon: "warning",
|
|
|
|
showCancelButton: true,
|
|
|
|
confirmButtonColor: "#3085d6",
|
|
|
|
cancelButtonColor: "#d33",
|
2024-02-13 19:58:43 +08:00
|
|
|
confirmButtonText: "Yes",
|
2024-02-02 22:59:21 +08:00
|
|
|
});
|
|
|
|
if (result.isConfirmed) {
|
2024-02-08 10:28:52 +08:00
|
|
|
if (isRemovePaper) {
|
|
|
|
removeReferenceUpdateIndex(index, true);
|
|
|
|
} else {
|
|
|
|
removeReferenceUpdateIndex();
|
|
|
|
}
|
2024-02-02 22:59:21 +08:00
|
|
|
// Swal.fire("Deleted!", "Your file has been deleted.", "success");
|
|
|
|
} else {
|
2024-02-10 13:25:43 +08:00
|
|
|
if (isRemovePaper) removeReferenceUpdateIndex(index, false);
|
2024-02-02 22:59:21 +08:00
|
|
|
// Swal.fire("Cancelled", "Your imaginary file is safe :)", "error");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
className="text-red-500 hover:text-red-700 ml-4"
|
|
|
|
onClick={showAlert} // 直接使用showAlert而不传递参数
|
|
|
|
>
|
|
|
|
X
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ParagraphDeleteButton;
|