mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-05 04:52:58 +00:00
Add files via upload
This commit is contained in:
@@ -301,10 +301,10 @@ func cleanPhoneNumber(phone string) string {
|
|||||||
|
|
||||||
func processContacts(contacts []Contact) *ContactData {
|
func processContacts(contacts []Contact) *ContactData {
|
||||||
var data ContactData
|
var data ContactData
|
||||||
|
data.InternalContacts = []Contact{} // Initialize as empty array
|
||||||
|
|
||||||
for _, contact := range contacts {
|
for _, contact := range contacts {
|
||||||
// Check if name contains "Interní" (case sensitive)
|
if strings.Contains(contact.Name, "Interní") {
|
||||||
isInternal := strings.Contains(contact.Name, "Interní")
|
|
||||||
if isInternal {
|
|
||||||
data.InternalContacts = append(data.InternalContacts, contact)
|
data.InternalContacts = append(data.InternalContacts, contact)
|
||||||
} else {
|
} else {
|
||||||
data.Contacts = append(data.Contacts, contact)
|
data.Contacts = append(data.Contacts, contact)
|
||||||
|
|||||||
+20
-4
@@ -135,7 +135,7 @@
|
|||||||
async function loadContacts() {
|
async function loadContacts() {
|
||||||
try {
|
try {
|
||||||
showLoading();
|
showLoading();
|
||||||
const response = await fetch('/contacts');
|
const response = await fetch('http://localhost:8081/contacts');
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||||
@@ -240,14 +240,22 @@
|
|||||||
const internalContainer = document.getElementById('internal-contacts');
|
const internalContainer = document.getElementById('internal-contacts');
|
||||||
const noResults = document.getElementById('noResults');
|
const noResults = document.getElementById('noResults');
|
||||||
|
|
||||||
|
// Clear previous results
|
||||||
|
container.innerHTML = '';
|
||||||
|
internalContainer.innerHTML = '';
|
||||||
|
|
||||||
if (!contacts || !contacts.length) {
|
if (!contacts || !contacts.length) {
|
||||||
container.innerHTML = '';
|
|
||||||
internalContainer.innerHTML = '';
|
|
||||||
noResults.classList.remove('hidden');
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
noResults.classList.add('hidden');
|
noResults.classList.add('hidden');
|
||||||
|
|
||||||
|
// Always show both sections, even if empty
|
||||||
container.innerHTML = contacts
|
container.innerHTML = contacts
|
||||||
.filter(contact => !contact.internal)
|
.filter(contact => !contact.internal)
|
||||||
.map(contact => formatContactCard(contact, searchQuery))
|
.map(contact => formatContactCard(contact, searchQuery))
|
||||||
@@ -257,6 +265,14 @@
|
|||||||
.filter(contact => contact.internal)
|
.filter(contact => contact.internal)
|
||||||
.map(contact => formatContactCard(contact, searchQuery))
|
.map(contact => formatContactCard(contact, searchQuery))
|
||||||
.join('');
|
.join('');
|
||||||
|
|
||||||
|
// Show empty state for individual sections if needed
|
||||||
|
if (!container.innerHTML) {
|
||||||
|
container.innerHTML = '<p class="text-gray-500 py-4">Žádné hlavní kontakty</p>';
|
||||||
|
}
|
||||||
|
if (!internalContainer.innerHTML) {
|
||||||
|
internalContainer.innerHTML = '<p class="text-gray-500 py-4">Žádné interní kontakty</p>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatContactCard(contact, searchQuery) {
|
function formatContactCard(contact, searchQuery) {
|
||||||
@@ -318,7 +334,7 @@
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/reload', { method: 'POST' });
|
const response = await fetch('http://localhost:8081/reload', { method: 'POST' });
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user