Add files via upload

This commit is contained in:
Tomáš Dvořák
2025-05-23 09:40:12 +02:00
committed by GitHub
parent 0cd9add08a
commit 1fd66641da
2 changed files with 24 additions and 29 deletions
+3 -8
View File
@@ -192,18 +192,13 @@ func parseExcelFile(filename string) ([]Contact, error) {
} }
sheetName := sheets[0] sheetName := sheets[0]
var contacts []Contact
// Parse first table (A-D columns)
contacts = append(contacts, parseTable(f, sheetName, "A", "D", 1)...)
// Parse second table (F-H columns)
contacts = append(contacts, parseTable(f, sheetName, "F", "H", 2)...)
// Parse the single table (columns A-E)
contacts := parseTable(f, sheetName, "A", "E")
return contacts, nil return contacts, nil
} }
func parseTable(f *excelize.File, sheetName, startCol, endCol string, tableNum int) []Contact { func parseTable(f *excelize.File, sheetName, startCol, endCol string) []Contact {
var contacts []Contact var contacts []Contact
var currentContact *Contact var currentContact *Contact
+20 -20
View File
@@ -230,9 +230,17 @@
function filterContacts() { function filterContacts() {
const query = document.getElementById('searchInput').value.toLowerCase().trim(); const query = document.getElementById('searchInput').value.toLowerCase().trim();
const activeTab = document.querySelector('.switcher-btn.active').dataset.type;
// Get contacts based on active tab
let contacts = [];
if (activeTab === 'main') {
contacts = [...allContacts.filter(c => !c.internal)];
} else if (activeTab === 'internal') {
contacts = [...allContacts.filter(c => c.internal)];
}
// Apply table filter // Apply table filter
let contacts = allContacts;
if (currentTableFilter !== 'all') { if (currentTableFilter !== 'all') {
contacts = contacts.filter(contact => contact.table == currentTableFilter); contacts = contacts.filter(contact => contact.table == currentTableFilter);
} }
@@ -315,26 +323,18 @@
} }
function showContacts(type) { function showContacts(type) {
const mainDiv = document.getElementById('contacts'); // Update switcher buttons
const internalDiv = document.getElementById('internal-contacts'); document.querySelectorAll('.switcher-btn').forEach(btn => {
const mainBtn = document.getElementById('showMainContacts'); btn.classList.remove('active', 'bg-blue-600', 'text-white');
const internalBtn = document.getElementById('showInternalContacts'); btn.classList.add('bg-gray-100', 'text-gray-700');
if (btn.dataset.type === type) {
if (type === 'main') { btn.classList.add('active', 'bg-blue-600', 'text-white');
mainDiv.classList.remove('hidden'); btn.classList.remove('bg-gray-100', 'text-gray-700');
internalDiv.classList.add('hidden');
mainBtn.classList.add('bg-blue-600', 'text-white');
mainBtn.classList.remove('bg-gray-100', 'text-gray-700');
internalBtn.classList.remove('bg-blue-600', 'text-white');
internalBtn.classList.add('bg-gray-100', 'text-gray-700');
} else {
mainDiv.classList.add('hidden');
internalDiv.classList.remove('hidden');
mainBtn.classList.remove('bg-blue-600', 'text-white');
mainBtn.classList.add('bg-gray-100', 'text-gray-700');
internalBtn.classList.add('bg-blue-600', 'text-white');
internalBtn.classList.remove('bg-gray-100', 'text-gray-700');
} }
});
// Filter contacts for the selected type
filterContacts();
} }
async function reloadContacts() { async function reloadContacts() {