// ===================== TAB SWITCHING ===================== const tabs = document.querySelectorAll('.tab-btn'); const tabContents = document.querySelectorAll('.tab-content'); tabs.forEach(tab => { tab.addEventListener('click', () => { const target = tab.dataset.tab; // Hide all tabs tabContents.forEach(content => content.classList.add('hidden')); // Show selected tab document.getElementById(target + '-tab').classList.remove('hidden'); // Active button style tabs.forEach(btn => btn.classList.remove('active')); tab.classList.add('active'); // Load content if (target === 'calendar') loadCalendar(); if (target === 'table') loadTable(); }); }); // ===================== CALENDAR VIEW ===================== let calendarLoaded = false; function loadCalendar() { if (calendarLoaded) return; fetch('../actions/fetch_meetings.php') .then(res => res.json()) .then(events => { const calendarEl = document.getElementById('calendar'); const calendar = new FullCalendar.Calendar(calendarEl, { initialView: 'dayGridMonth', height: 650, events: events.map(e => ({ title: e.title, start: e.meeting_date, description: e.description, })), eventClick: info => { alert(`📅 ${info.event.title}\n${info.event.start.toDateString()}\n${info.event.extendedProps.description || ''}`); } }); calendar.render(); calendarLoaded = true; }) .catch(err => console.error('Error loading calendar:', err)); } // ===================== TABLE VIEW ===================== function loadTable() { fetch('../actions/fetch_meetings.php') .then(res => res.json()) .then(data => { const tbody = document.getElementById('meetingsTable'); tbody.innerHTML = ''; data.forEach(row => { const tr = document.createElement('tr'); tr.classList.add('hover:bg-gray-100'); tr.innerHTML = `