This commit is contained in:
2026-05-06 23:47:22 +03:00
parent b824144a6a
commit 7f380324d4

View File

@@ -565,6 +565,8 @@
if (!pendingCmd) return; if (!pendingCmd) return;
document.getElementById('btn-confirm').disabled = true; document.getElementById('btn-confirm').disabled = true;
// Capture before closeModal() nulls pendingCmd
const { townId, townName, celType } = pendingCmd;
try { try {
const r = await fetch('/dashboard/culture-command', { const r = await fetch('/dashboard/culture-command', {
method: 'POST', method: 'POST',
@@ -572,15 +574,15 @@
body: JSON.stringify({ body: JSON.stringify({
player_id: PLAYER_ID, player_id: PLAYER_ID,
world_id: WORLD_ID, world_id: WORLD_ID,
town_id: pendingCmd.townId, town_id: townId,
town_name: pendingCmd.townName, town_name: townName,
celebration_type: pendingCmd.celType celebration_type: celType
}) })
}); });
const d = await r.json(); const d = await r.json();
closeModal(); closeModal();
if (r.ok && d.ok) { if (r.ok && d.ok) {
showToast(`✅ Εντολή στάλθηκε — ${TYPE_LABELS[pendingCmd.celType]}`, 'ok'); showToast(`✅ Εντολή στάλθηκε — ${TYPE_LABELS[celType]}`, 'ok');
fetchLog(); fetchLog();
setTimeout(fetchAgora, 3000); setTimeout(fetchAgora, 3000);
} else { } else {