Spaces:
Sleeping
Sleeping
ichieh commited on
Commit ·
de731eb
1
Parent(s): 4661923
Fix payment status toggle API and button styles
Browse files- templates/admin.html +10 -5
templates/admin.html
CHANGED
|
@@ -211,8 +211,7 @@
|
|
| 211 |
<td>${shortIntro || '-'}</td>
|
| 212 |
<td>
|
| 213 |
<button
|
| 214 |
-
class="btn btn-sm"
|
| 215 |
-
${p.has_paid ? 'btn-success' : 'btn-outline-secondary'}
|
| 216 |
onclick="togglePayment(${p.id})"
|
| 217 |
>
|
| 218 |
${p.has_paid ? '已付款' : '未付款'}
|
|
@@ -357,7 +356,7 @@
|
|
| 357 |
// 切換付款狀態
|
| 358 |
async function togglePayment(participantId) {
|
| 359 |
try {
|
| 360 |
-
const response = await fetch(`/api/admin/participant/${participantId}/
|
| 361 |
method: 'POST',
|
| 362 |
headers: {
|
| 363 |
'Content-Type': 'application/json'
|
|
@@ -367,8 +366,14 @@
|
|
| 367 |
const data = await response.json();
|
| 368 |
|
| 369 |
if (response.ok) {
|
| 370 |
-
Swal.fire(
|
| 371 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 372 |
} else {
|
| 373 |
throw new Error(data.error);
|
| 374 |
}
|
|
|
|
| 211 |
<td>${shortIntro || '-'}</td>
|
| 212 |
<td>
|
| 213 |
<button
|
| 214 |
+
class="btn btn-sm ${p.has_paid ? 'btn-success' : 'btn-danger'}"
|
|
|
|
| 215 |
onclick="togglePayment(${p.id})"
|
| 216 |
>
|
| 217 |
${p.has_paid ? '已付款' : '未付款'}
|
|
|
|
| 356 |
// 切換付款狀態
|
| 357 |
async function togglePayment(participantId) {
|
| 358 |
try {
|
| 359 |
+
const response = await fetch(`/api/admin/participant/${participantId}/payment`, {
|
| 360 |
method: 'POST',
|
| 361 |
headers: {
|
| 362 |
'Content-Type': 'application/json'
|
|
|
|
| 366 |
const data = await response.json();
|
| 367 |
|
| 368 |
if (response.ok) {
|
| 369 |
+
Swal.fire({
|
| 370 |
+
icon: 'success',
|
| 371 |
+
title: '成功',
|
| 372 |
+
text: data.message,
|
| 373 |
+
showConfirmButton: false,
|
| 374 |
+
timer: 1500
|
| 375 |
+
});
|
| 376 |
+
await loadParticipants();
|
| 377 |
} else {
|
| 378 |
throw new Error(data.error);
|
| 379 |
}
|