Add user members section with full-text search
This commit is contained in:
+45
@@ -17,6 +17,7 @@ function setCookie(name, value, days) {
|
||||
|
||||
const API_URL = 'https://n8n.odoo4projects.com/webhook/paraguay/login';
|
||||
const NEWSLETTER_URL = 'https://n8n.odoo4projects.com/webhook/paraguay/newsletter';
|
||||
const USER_URL = 'https://n8n.odoo4projects.com/webhook/paraguay/user';
|
||||
|
||||
function checkSession() {
|
||||
const sessionid = getCookie('sessionid');
|
||||
@@ -55,6 +56,7 @@ document.querySelectorAll('.notebook .tab').forEach(tab => {
|
||||
const tabName = tab.dataset.tab;
|
||||
document.querySelectorAll('.notebook .tab-content').forEach(c => c.classList.add('hidden'));
|
||||
document.getElementById('tab-' + tabName).classList.remove('hidden');
|
||||
if (tabName === 'users') loadUsers();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -202,4 +204,47 @@ async function subscribeNewsletter() {
|
||||
btn.disabled = false;
|
||||
btn.textContent = document.body.dataset.lang === 'de' ? 'Abonnieren' : 'Subscribe';
|
||||
}
|
||||
}
|
||||
|
||||
async function loadUsers() {
|
||||
const usersContainer = document.getElementById('users-list');
|
||||
if (!usersContainer) return;
|
||||
try {
|
||||
const response = await fetch(USER_URL);
|
||||
if (!response.ok) throw new Error('Failed to fetch users');
|
||||
const data = await response.json();
|
||||
console.log('loadUsers response:', data);
|
||||
if (data.data && Array.isArray(data.data)) {
|
||||
usersContainer.innerHTML = '';
|
||||
data.data.forEach(user => {
|
||||
const card = document.createElement('div');
|
||||
card.className = 'user-card';
|
||||
card.innerHTML = `
|
||||
<div class="user-avatar">${(user.username || '').charAt(0).toUpperCase()}</div>
|
||||
<div class="user-info">
|
||||
<h4>${user.username || 'N/A'}</h4>
|
||||
<p class="user-company">${user.company || ''}</p>
|
||||
<p class="user-email">${user.email || ''}</p>
|
||||
</div>
|
||||
`;
|
||||
usersContainer.appendChild(card);
|
||||
});
|
||||
} else {
|
||||
usersContainer.innerHTML = '<p>No users found.</p>';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('loadUsers error:', error);
|
||||
usersContainer.innerHTML = '<p>Error loading users.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
function filterUsers(searchTerm) {
|
||||
const usersContainer = document.getElementById('users-list');
|
||||
if (!usersContainer) return;
|
||||
const cards = usersContainer.querySelectorAll('.user-card');
|
||||
const term = searchTerm.toLowerCase();
|
||||
cards.forEach(card => {
|
||||
const text = card.innerText.toLowerCase();
|
||||
card.style.display = text.includes(term) ? 'block' : 'none';
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user