[deploy] Harden dashboard event listeners for missing elements
All checks were successful
Deploy Discord Bot / deploy (push) Successful in 36s

This commit is contained in:
Pascal Prießnitz
2025-12-04 12:19:26 +01:00
parent 78578fcc1c
commit bebca808b0

View File

@@ -2312,43 +2312,55 @@ router.get('/', (req, res) => {
} }
} }
document.getElementById('settingsForm').addEventListener('submit', async (e) => { const settingsForm = document.getElementById('settingsForm');
e.preventDefault(); if (settingsForm) {
if (!currentGuild) return; settingsForm.addEventListener('submit', async (e) => {
const form = new FormData(e.currentTarget); e.preventDefault();
const payload = Object.fromEntries(form.entries()); if (!currentGuild) return;
payload.supportRoleId = payload.supportRoleId || undefined; const form = new FormData(e.currentTarget as HTMLFormElement);
payload.guildId = currentGuild; const payload: any = Object.fromEntries(form.entries());
const res = await fetch('/api/settings', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(payload) }); payload.supportRoleId = payload.supportRoleId || undefined;
document.getElementById('saveStatus').textContent = res.ok ? 'Gespeichert' : 'Fehler'; payload.guildId = currentGuild;
if (res.ok) { const res = await fetch('/api/settings', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(payload) });
await loadSettings(currentGuild); const saveStatus = document.getElementById('saveStatus');
await loadModules(); if (saveStatus) saveStatus.textContent = res.ok ? 'Gespeichert' : 'Fehler';
} if (res.ok) {
}); await loadSettings(currentGuild);
await loadModules();
}
});
}
document.getElementById('openPanelModal').addEventListener('click', () => { const openPanelModalBtn = document.getElementById('openPanelModal');
document.getElementById('panelStatus').textContent = ''; if (openPanelModalBtn) {
showModal(panelModal); openPanelModalBtn.addEventListener('click', () => {
}); const panelStatus = document.getElementById('panelStatus');
if (panelStatus) panelStatus.textContent = '';
showModal(panelModal);
});
}
if (openSupportLogin) openSupportLogin.addEventListener('click', () => { showModal(supportLoginModal); }); if (openSupportLogin) openSupportLogin.addEventListener('click', () => { showModal(supportLoginModal); });
if (supportLoginSave) supportLoginSave.addEventListener('click', saveSupportLogin); if (supportLoginSave) supportLoginSave.addEventListener('click', saveSupportLogin);
if (refreshSupportStatus) refreshSupportStatus.addEventListener('click', loadSupportLogin); if (refreshSupportStatus) refreshSupportStatus.addEventListener('click', loadSupportLogin);
document.getElementById('panelSubmit').addEventListener('click', async () => { const panelSubmit = document.getElementById('panelSubmit');
if (!currentGuild) return; if (panelSubmit) {
const form = new FormData(document.getElementById('panelForm')); panelSubmit.addEventListener('click', async () => {
const channelId = form.get('channelId'); if (!currentGuild) return;
const panelTitle = form.get('panelTitle'); const formEl = document.getElementById('panelForm') as HTMLFormElement | null;
const panelDescription = form.get('panelDescription'); const form = formEl ? new FormData(formEl) : null;
const panelCategories = form.get('panelCategories'); const channelId = form?.get('channelId');
const status = document.getElementById('panelStatus'); const panelTitle = form?.get('panelTitle');
const ok = await createPanel(channelId, panelTitle, panelDescription, panelCategories); const panelDescription = form?.get('panelDescription');
if (status) status.textContent = ok ? 'Panel gesendet' : 'Fehler beim Senden'; const panelCategories = form?.get('panelCategories');
showToast(ok ? 'Ticket-Panel gesendet' : 'Ticket-Panel Fehler', !ok); const status = document.getElementById('panelStatus');
if (ok) hideModal(); const ok = await createPanel(channelId, panelTitle, panelDescription, panelCategories);
}); if (status) status.textContent = ok ? 'Panel gesendet' : 'Fehler beim Senden';
showToast(ok ? 'Ticket-Panel gesendet' : 'Ticket-Panel Fehler', !ok);
if (ok) hideModal();
});
}
document.querySelectorAll('[data-close-modal]').forEach((btn) => btn.addEventListener('click', hideModal)); document.querySelectorAll('[data-close-modal]').forEach((btn) => btn.addEventListener('click', hideModal));
modalBackdrop.addEventListener('click', hideModal); modalBackdrop.addEventListener('click', hideModal);