|
982 | 982 | <script>
|
983 | 983 | $(document).ready(function () {
|
984 | 984 | 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 |
986 | 987 | $('#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'); |
989 | 990 | });
|
990 |
| - // Khi nhấn nút "Confirm" trong modal |
| 991 | +
|
991 | 992 | $('#confirmWithdrawBtn').click(function () {
|
992 | 993 | 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 |
993 | 999 | $.ajax({
|
994 |
| - url: '/Admin/Payments/ConfirmWithdraw', // URL đến action ConfirmWithdraw trong controller |
| 1000 | + url: '/Admin/Payments/ConfirmWithdraw', |
995 | 1001 | type: 'POST',
|
996 | 1002 | data: { id: withdrawId },
|
997 | 1003 | 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); |
1004 | 1012 | },
|
1005 | 1013 | 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(); |
1007 | 1019 | }
|
1008 | 1020 | });
|
1009 | 1021 | }
|
1010 | 1022 | });
|
1011 | 1023 | });
|
1012 | 1024 | </script>
|
1013 | 1025 |
|
1014 |
| - </body> |
| 1026 | + |
| 1027 | +</body> |
1015 | 1028 |
|
0 commit comments