Skip to content

Commit e33e5cc

Browse files
authored
Merge pull request #86 from kleqing/dev2.0
Add loading button (#85)
2 parents 59c842e + 451726a commit e33e5cc

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

Dynamics/Areas/Admin/Views/Payments/Details.cshtml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -982,34 +982,47 @@
982982
<script>
983983
$(document).ready(function () {
984984
let withdrawId;
985-
// Lấy ID của lần rút tiền khi modal được mở
985+
986+
// Get Withdraw ID when the modal opens
986987
$('#standard-modal').on('show.bs.modal', function (event) {
987-
let button = $(event.relatedTarget); // Button đã mở modal
988-
withdrawId = button.data('id'); // Lấy giá trị WithdrawID từ thuộc tính data-id của button
988+
let button = $(event.relatedTarget);
989+
withdrawId = button.data('id');
989990
});
990-
// Khi nhấn nút "Confirm" trong modal
991+
991992
$('#confirmWithdrawBtn').click(function () {
992993
if (withdrawId) {
994+
$(this).prop('disabled', true);
995+
$('.btn-primary').hide(); // Hide the original confirm button
996+
$('.btn-loading').show(); // Show the loading button
997+
998+
// Send the AJAX request
993999
$.ajax({
994-
url: '/Admin/Payments/ConfirmWithdraw', // URL đến action ConfirmWithdraw trong controller
1000+
url: '/Admin/Payments/ConfirmWithdraw',
9951001
type: 'POST',
9961002
data: { id: withdrawId },
9971003
success: function (response) {
998-
$('#standard-modal').modal('hide');
999-
if (response.success) {
1000-
window.location.href = '/Admin/Payments'; // Chuyển hướng nếu thành công
1001-
} else {
1002-
alert(response.message); // Thông báo lỗi nếu có
1003-
}
1004+
setTimeout(function () { // Add a delay before redirecting
1005+
$('#standard-modal').modal('hide');
1006+
if (response.success) {
1007+
window.location.href = '/Admin/Payments';
1008+
} else {
1009+
alert(response.message);
1010+
}
1011+
}, 3000);
10041012
},
10051013
error: function (xhr, status, error) {
1006-
alert("An error occurred: " + error); // Thông báo lỗi nếu request thất bại
1014+
alert("An error occurred: " + error);
1015+
// Re-enable the button in case of error
1016+
$('#confirmWithdrawBtn').prop('disabled', false);
1017+
$('.btn-loading').hide();
1018+
$('.btn-primary').show();
10071019
}
10081020
});
10091021
}
10101022
});
10111023
});
10121024
</script>
10131025

1014-
</body>
1026+
1027+
</body>
10151028

package-lock.json

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)