partial update create toggle active product and mutations

This commit is contained in:
2025-06-02 18:51:04 +07:00
parent 6bf8bc4965
commit a881779c4f
22 changed files with 512 additions and 21 deletions

View File

@@ -13,6 +13,7 @@ let table = $("#products-table").DataTable({
{ data: "code", name: "code" },
{ data: "name", name: "name" },
{ data: "category_name", name: "category.name" },
{ data: "unit", name: "unit" },
{ data: "total_stock", name: "total_stock" },
{ data: "action", name: "action", orderable: false, searchable: false },
],
@@ -48,3 +49,37 @@ $(document).on("click", ".btn-destroy-product", function () {
}
});
});
$(document).on("click", ".btn-toggle-active", function () {
let button = $(this);
let url = button.data("url");
Swal.fire({
title: "Status produk?",
text: "Anda yakin ingin mengganti status produk!",
showCancelButton: true,
confirmButtonColor: "#d33",
cancelButtonColor: "#dedede",
confirmButtonText: "Ya",
}).then((result) => {
if (result.value) {
$.ajax({
url: url,
method: "POST",
data: {
_token: $('meta[name="csrf-token"]').attr("content"),
},
success: function (response) {
if (response.success) {
$("#products-table")
.DataTable()
.ajax.reload(null, false);
alert(response.message);
}
},
error: function () {
alert("Gagal mengubah status produk.");
},
});
}
});
});