Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
Add action for cancel an order
Browse files Browse the repository at this point in the history
  • Loading branch information
hardingadonis committed Dec 6, 2023
1 parent e3e4193 commit bdb78b0
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/main/webapp/assets/js/web/purchaseHistoryHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,55 @@ function formatCurrencyVND(amount) {
});

return formatter.format(amount);
}

function handleDeletePurchaseHistory(id) {
Swal.fire({
title: "Hủy đơn hàng?",
text: "Bạn thực sự muốn hủy đơn hàng này?",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Xác nhận!",
cancelButtonText: "Không!"
}).then((result) => {
if (result.isConfirmed) {
const url = "purchase-history?id=" + id;

$.ajax({
url: url,
type: "DELETE",
dataType: "json",
success: function (data) {
if (data.status === "success") {
Swal.fire({
title: "Thành công!",
text: "Bạn đã hủy đơn hàng thành công!",
icon: "success"
}).then((result) => {
if (result.isConfirmed) {
window.location.reload();
}
});
} else {
Swal.fire({
title: "Oops...",
text: "Đã có lỗi xảy ra!",
icon: "error"
});
}
},
error: function () {
Swal.fire({
title: "Oops...",
text: "Đã có lỗi xảy ra khi gửi yêu cầu!",
icon: "error"
});

console.log("error");
}
});
}
});
}

0 comments on commit bdb78b0

Please sign in to comment.