[deploy] Harden dashboard event listeners for missing elements
All checks were successful
Deploy Discord Bot / deploy (push) Successful in 36s
All checks were successful
Deploy Discord Bot / deploy (push) Successful in 36s
This commit is contained in:
@@ -2312,43 +2312,55 @@ router.get('/', (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('settingsForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
if (!currentGuild) return;
|
||||
const form = new FormData(e.currentTarget);
|
||||
const payload = Object.fromEntries(form.entries());
|
||||
payload.supportRoleId = payload.supportRoleId || undefined;
|
||||
payload.guildId = currentGuild;
|
||||
const res = await fetch('/api/settings', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(payload) });
|
||||
document.getElementById('saveStatus').textContent = res.ok ? 'Gespeichert' : 'Fehler';
|
||||
if (res.ok) {
|
||||
await loadSettings(currentGuild);
|
||||
await loadModules();
|
||||
}
|
||||
});
|
||||
const settingsForm = document.getElementById('settingsForm');
|
||||
if (settingsForm) {
|
||||
settingsForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
if (!currentGuild) return;
|
||||
const form = new FormData(e.currentTarget as HTMLFormElement);
|
||||
const payload: any = Object.fromEntries(form.entries());
|
||||
payload.supportRoleId = payload.supportRoleId || undefined;
|
||||
payload.guildId = currentGuild;
|
||||
const res = await fetch('/api/settings', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(payload) });
|
||||
const saveStatus = document.getElementById('saveStatus');
|
||||
if (saveStatus) saveStatus.textContent = res.ok ? 'Gespeichert' : 'Fehler';
|
||||
if (res.ok) {
|
||||
await loadSettings(currentGuild);
|
||||
await loadModules();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.getElementById('openPanelModal').addEventListener('click', () => {
|
||||
document.getElementById('panelStatus').textContent = '';
|
||||
showModal(panelModal);
|
||||
});
|
||||
const openPanelModalBtn = document.getElementById('openPanelModal');
|
||||
if (openPanelModalBtn) {
|
||||
openPanelModalBtn.addEventListener('click', () => {
|
||||
const panelStatus = document.getElementById('panelStatus');
|
||||
if (panelStatus) panelStatus.textContent = '';
|
||||
showModal(panelModal);
|
||||
});
|
||||
}
|
||||
|
||||
if (openSupportLogin) openSupportLogin.addEventListener('click', () => { showModal(supportLoginModal); });
|
||||
if (supportLoginSave) supportLoginSave.addEventListener('click', saveSupportLogin);
|
||||
if (refreshSupportStatus) refreshSupportStatus.addEventListener('click', loadSupportLogin);
|
||||
|
||||
document.getElementById('panelSubmit').addEventListener('click', async () => {
|
||||
if (!currentGuild) return;
|
||||
const form = new FormData(document.getElementById('panelForm'));
|
||||
const channelId = form.get('channelId');
|
||||
const panelTitle = form.get('panelTitle');
|
||||
const panelDescription = form.get('panelDescription');
|
||||
const panelCategories = form.get('panelCategories');
|
||||
const status = document.getElementById('panelStatus');
|
||||
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();
|
||||
});
|
||||
const panelSubmit = document.getElementById('panelSubmit');
|
||||
if (panelSubmit) {
|
||||
panelSubmit.addEventListener('click', async () => {
|
||||
if (!currentGuild) return;
|
||||
const formEl = document.getElementById('panelForm') as HTMLFormElement | null;
|
||||
const form = formEl ? new FormData(formEl) : null;
|
||||
const channelId = form?.get('channelId');
|
||||
const panelTitle = form?.get('panelTitle');
|
||||
const panelDescription = form?.get('panelDescription');
|
||||
const panelCategories = form?.get('panelCategories');
|
||||
const status = document.getElementById('panelStatus');
|
||||
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));
|
||||
modalBackdrop.addEventListener('click', hideModal);
|
||||
|
||||
Reference in New Issue
Block a user