ichieh commited on
Commit
b959f55
·
1 Parent(s): fe8f9dd

管理後台桌次同步修正

Browse files
Files changed (1) hide show
  1. templates/admin.html +9 -8
templates/admin.html CHANGED
@@ -147,25 +147,26 @@
147
  const seatsPerTable = document.getElementById('seatsPerTable').value;
148
 
149
  try {
150
- const response = await fetch('/api/admin/settings', {
151
  method: 'POST',
152
  headers: {
153
  'Content-Type': 'application/json'
154
  },
155
  body: JSON.stringify({
 
156
  total_tables: parseInt(totalTables),
157
  seats_per_table: parseInt(seatsPerTable)
158
  })
159
  });
160
 
161
- const data = await response.json();
162
-
163
- if (response.ok) {
164
- Swal.fire('成功', '桌次設定已更新', 'success');
165
- loadParticipants(); // 重新載入參與者列表以反映新的桌次設定
166
- } else {
167
- throw new Error(data.error);
168
  }
 
 
 
 
169
  } catch (error) {
170
  console.error('Error:', error);
171
  Swal.fire('錯誤', error.message || '更新設定失敗', 'error');
 
147
  const seatsPerTable = document.getElementById('seatsPerTable').value;
148
 
149
  try {
150
+ const response = await fetch('/api/admin/settings/update', {
151
  method: 'POST',
152
  headers: {
153
  'Content-Type': 'application/json'
154
  },
155
  body: JSON.stringify({
156
+ action: 'update_tables',
157
  total_tables: parseInt(totalTables),
158
  seats_per_table: parseInt(seatsPerTable)
159
  })
160
  });
161
 
162
+ if (!response.ok) {
163
+ const data = await response.json();
164
+ throw new Error(data.error || '更新設定失敗');
 
 
 
 
165
  }
166
+
167
+ const data = await response.json();
168
+ Swal.fire('成功', '桌次設定已更新', 'success');
169
+ loadParticipants(); // 重新載入參與者列表以反映新的桌次設定
170
  } catch (error) {
171
  console.error('Error:', error);
172
  Swal.fire('錯誤', error.message || '更新設定失敗', 'error');