function filterUsersList() { const queryInput = document.getElementById('userSearchInput'); if (!queryInput) return; const query = queryInput.value.toLowerCase().trim(); const rows = document.querySelectorAll('.user-row'); const cards = document.querySelectorAll('.user-card'); rows.forEach(r => { const text = r.getAttribute('data-search') || ''; r.style.display = text.includes(query) ? '' : 'none'; }); cards.forEach(c => { const text = c.getAttribute('data-search') || ''; c.style.display = text.includes(query) ? '' : 'none'; }); } globalThis.filterUsersList = filterUsersList; function showNotice(msg, isError) { const banner = document.getElementById('status-banner'); if (!banner) return; banner.textContent = msg; banner.style.display = 'block'; banner.style.background = isError ? 'var(--danger-bg)' : 'var(--success-bg)'; banner.style.color = isError ? 'var(--danger-text)' : 'var(--success-text)'; banner.style.border = isError ? '1px solid var(--danger-border)' : '1px solid var(--success-border)'; setTimeout(() => { banner.style.display = 'none'; }, 5000); } globalThis.showNotice = showNotice; async function updateStatus(userId, status, username) { if (!confirm('Set user @' + username + ' to ' + status.toUpperCase() + '?')) { return; } try { const res = await fetch('/api/admin/users/' + userId + '/status', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ status }) }); if (res.ok) { showNotice('User status updated to ' + status, false); setTimeout(() => globalThis.location.reload(), 600); } else { const data = await res.json(); showNotice(data.error || 'Failed to update status', true); } } catch (_err) { showNotice('Network error updating status', true); } } globalThis.updateStatus = updateStatus;