64 lines
3 KiB
TypeScript
64 lines
3 KiB
TypeScript
import Swal from "sweetalert2";
|
|
import trans from "../../modules/trans";
|
|
const elements = document.getElementsByClassName("confirmDeleteTenantTS");
|
|
|
|
if (elements) {
|
|
for (const element of elements) {
|
|
element.addEventListener("submit", (e) => {
|
|
const self = e.target as HTMLFormElement;
|
|
e.preventDefault();
|
|
Swal.fire({
|
|
title: trans.methods.__("Confirmez"),
|
|
text: trans.methods.__("Voulez-vous vraiment supprimer cet élément ?"),
|
|
color: getComputedStyle(document.body).getPropertyValue("--bs-body-color"),
|
|
icon: "error",
|
|
showCancelButton: true,
|
|
confirmButtonText:trans.methods.__("Oui"),
|
|
cancelButtonText: trans.methods.__("Annuler"),
|
|
// * Bootstrap Styling
|
|
customClass: {
|
|
confirmButton: "btn btn-primary mx-1",
|
|
cancelButton: "btn btn-danger mx-1",
|
|
},
|
|
buttonsStyling: false,
|
|
background: getComputedStyle(document.body).getPropertyValue("--bs-body-bg"),
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
Swal.fire({
|
|
title: trans.methods.__("Attention au conséquences"),
|
|
html: "Attention cette action est irréversible, toutes les informations liées à ce tenant seront supprimées !",
|
|
color: getComputedStyle(document.body).getPropertyValue("--bs-body-color"),
|
|
icon: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonText:trans.methods.__("Je comprends le danger et suis conscient que celà aura des conséquences"),
|
|
cancelButtonText: trans.methods.__("Annuler"),
|
|
// * Bootstrap Styling
|
|
customClass: {
|
|
confirmButton: "btn btn-primary mx-1",
|
|
cancelButton: "btn btn-danger mx-1 mt-1",
|
|
},
|
|
buttonsStyling: false,
|
|
background: getComputedStyle(document.body).getPropertyValue("--bs-body-bg"),
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
self?.submit();
|
|
}
|
|
});
|
|
} else if (
|
|
/* Read more about handling dismissals below */
|
|
result.dismiss === Swal.DismissReason.cancel
|
|
) {
|
|
Swal.fire({
|
|
title: trans.methods.__("L'opération n'as pas été effectuée"),
|
|
confirmButtonText: trans.methods.__("Ok"),
|
|
// * Bootstrap Styling
|
|
customClass: {
|
|
confirmButton: "btn btn-primary",
|
|
},
|
|
buttonsStyling: false,
|
|
});
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|