From e3611c8300ccee3c22782f8fc69f53108caf8291 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 8 Sep 2025 16:14:29 -0600 Subject: [PATCH] fixed a bug for manage volunteers --- map/app/public/admin.html | 20 +-- map/app/public/js/admin-shift-volunteers.js | 145 ++++++++++++++++++-- map/app/public/js/admin-shifts.js | 84 +++++++++++- map/app/public/js/admin.js | 69 +++++++++- 4 files changed, 294 insertions(+), 24 deletions(-) diff --git a/map/app/public/admin.html b/map/app/public/admin.html index 0c77845..0f7c240 100644 --- a/map/app/public/admin.html +++ b/map/app/public/admin.html @@ -1406,17 +1406,17 @@ - - - - - - - - - + + + + + + + + + - + diff --git a/map/app/public/js/admin-shift-volunteers.js b/map/app/public/js/admin-shift-volunteers.js index dd6ab71..c264433 100644 --- a/map/app/public/js/admin-shift-volunteers.js +++ b/map/app/public/js/admin-shift-volunteers.js @@ -3,10 +3,35 @@ * Handles volunteer management modals and shift email functionality */ +// Prevent double loading +if (window.adminShiftVolunteersLoading) { + console.warn('admin-shift-volunteers.js already loading, skipping...'); +} else { + window.adminShiftVolunteersLoading = true; + + // Check if adminCore module is available + console.log('🔄 Loading admin-shift-volunteers.js...'); + console.log('📦 adminCore available:', !!window.adminCore); + +if (!window.adminCore) { + console.error('adminCore module not found - admin-shift-volunteers.js depends on admin-core.js'); + // Don't stop loading, just note the dependency issue +} + // Volunteer management state let currentShiftData = null; let allUsers = []; +// Safe wrapper for adminCore functions +function safeAdminCore(funcName, ...args) { + if (window.adminCore && typeof window.adminCore[funcName] === 'function') { + return window.adminCore[funcName](...args); + } else { + console.error(`adminCore.${funcName} not available`); + return null; + } +} + // Load all users for the dropdown async function loadAllUsers() { try { @@ -51,7 +76,7 @@ async function showShiftUserModal(shiftId, shiftData) { if (modalTitle) modalTitle.textContent = shiftData.Title; if (modalDetails) { - const shiftDate = window.adminCore.createLocalDate(shiftData.Date); + const shiftDate = safeAdminCore('createLocalDate', shiftData.Date) || new Date(shiftData.Date); modalDetails.textContent = `${shiftDate.toLocaleDateString()} | ${shiftData['Start Time']} - ${shiftData['End Time']} | ${shiftData.Location || 'TBD'}`; } @@ -85,8 +110,8 @@ function displayCurrentVolunteers(volunteers) { container.innerHTML = volunteers.map(volunteer => `
-
${window.adminCore.escapeHtml(volunteer['User Name'] || volunteer['User Email'] || 'Unknown')}
-
${window.adminCore.escapeHtml(volunteer['User Email'])}
+
${safeAdminCore('escapeHtml', volunteer['User Name'] || volunteer['User Email'] || 'Unknown') || 'Unknown'}
+
${safeAdminCore('escapeHtml', volunteer['User Email']) || volunteer['User Email'] || ''}