Sweet Alert
Installation
npm i @sweetalert/with-react
Script
import Swal from "sweetalert2";
const Profile3 = () => {
const questionAlert = () => {
const swalWithBootstrapButtons = Swal.mixin({
customClass: {
cancelButton: "btn btn-outline-primary btn-lg ms-2",
confirmButton: "btn btn-primary btn-lg",
},
buttonsStyling: false,
});
swalWithBootstrapButtons
.fire({
title: "Are you sure?",
text: "You won't be able to revert this!",
icon: "warning",
showCancelButton: true,
cancelButtonText: "cancel",
confirmButtonText: "Yes, delete it!",
reverseButtons: false,
showClass: {
popup: "animate__animated animate__zoomIn",
},
hideClass: {
popup: "animate__animated animate__zoomOut",
},
})
.then((result) => {
if (result.isConfirmed) {
swalWithBootstrapButtons.fire({
title: "Deleted!",
text: "Your Request has been deleted.",
icon: "success",
showClass: {
popup: "animate__animated animate__zoomIn",
},
hideClass: {
popup: "animate__animated animate__zoomOut",
},
});
} else if (
/* Read more about handling dismissals below */
result.dismiss === Swal.DismissReason.cancel
) {
swalWithBootstrapButtons.fire({
title: "Your Request is safe!",
showClass: {
popup: "animate__animated animate__zoomIn",
},
hideClass: {
popup: "animate__animated animate__zoomOut",
},
});
}
});
};
return(
<>
<Link
to="#"
onClick={questionAlert}
className="btn btn-danger-subtle rounded p-1 lh-1"
data-extra-toggle="delete"
data-closest-elem=".item"
>
<i className="material-symbols-outlined font-size-14">
close
</i>
</Link>
</>
)
}