partial update create toggle active product and mutations
This commit is contained in:
@@ -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.");
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user