diff --git a/kontakt/contact-scrape.go b/kontakt/contact-scrape.go index 668c9e4..d04e2d1 100644 --- a/kontakt/contact-scrape.go +++ b/kontakt/contact-scrape.go @@ -301,10 +301,10 @@ func cleanPhoneNumber(phone string) string { func processContacts(contacts []Contact) *ContactData { var data ContactData + data.InternalContacts = []Contact{} // Initialize as empty array + for _, contact := range contacts { - // Check if name contains "Interní" (case sensitive) - isInternal := strings.Contains(contact.Name, "Interní") - if isInternal { + if strings.Contains(contact.Name, "Interní") { data.InternalContacts = append(data.InternalContacts, contact) } else { data.Contacts = append(data.Contacts, contact) diff --git a/kontakt/index.html b/kontakt/index.html index 9edbf6f..2891791 100644 --- a/kontakt/index.html +++ b/kontakt/index.html @@ -135,7 +135,7 @@ async function loadContacts() { try { showLoading(); - const response = await fetch('/contacts'); + const response = await fetch('http://localhost:8081/contacts'); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); @@ -240,14 +240,22 @@ const internalContainer = document.getElementById('internal-contacts'); const noResults = document.getElementById('noResults'); + // Clear previous results + container.innerHTML = ''; + internalContainer.innerHTML = ''; + if (!contacts || !contacts.length) { - container.innerHTML = ''; - internalContainer.innerHTML = ''; noResults.classList.remove('hidden'); + noResults.querySelector('h3').textContent = 'Žádné kontakty'; + noResults.querySelector('p').textContent = searchQuery + ? 'Nebyly nalezeny žádné odpovídající kontakty' + : 'Nebyly načteny žádné kontakty'; return; } noResults.classList.add('hidden'); + + // Always show both sections, even if empty container.innerHTML = contacts .filter(contact => !contact.internal) .map(contact => formatContactCard(contact, searchQuery)) @@ -257,6 +265,14 @@ .filter(contact => contact.internal) .map(contact => formatContactCard(contact, searchQuery)) .join(''); + + // Show empty state for individual sections if needed + if (!container.innerHTML) { + container.innerHTML = '
Žádné hlavní kontakty
'; + } + if (!internalContainer.innerHTML) { + internalContainer.innerHTML = 'Žádné interní kontakty
'; + } } function formatContactCard(contact, searchQuery) { @@ -318,7 +334,7 @@ `; try { - const response = await fetch('/reload', { method: 'POST' }); + const response = await fetch('http://localhost:8081/reload', { method: 'POST' }); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); }