diff --git a/src/components/dashboard/EventsSection/EventLoad.tsx b/src/components/dashboard/EventsSection/EventLoad.tsx index 1ea07e7..79b2a10 100644 --- a/src/components/dashboard/EventsSection/EventLoad.tsx +++ b/src/components/dashboard/EventsSection/EventLoad.tsx @@ -146,7 +146,7 @@ const EventLoad = () => { try { const get = Get.getInstance(); const attendees = await get.getList( - "event_attendees", + Collections.EVENT_ATTENDEES, 1, 1, `user="${currentUser.id}" && event="${event.id}"` @@ -154,12 +154,38 @@ const EventLoad = () => { const hasAttendedEvent = attendees.totalItems > 0; + // Store the attendance status in the window object with the event + const eventDataId = `event_${event.id}`; + if (window[eventDataId]) { + window[eventDataId].hasAttended = hasAttendedEvent; + } + // Update the card UI based on attendance status const cardElement = document.getElementById(`event-card-${event.id}`); - if (cardElement && hasAttendedEvent) { - const attendedBadge = cardElement.querySelector('.attended-badge'); - if (attendedBadge) { - (attendedBadge as HTMLElement).style.display = 'flex'; + if (cardElement) { + const attendedBadge = document.getElementById(`attendance-badge-${event.id}`); + if (attendedBadge && hasAttendedEvent) { + attendedBadge.classList.remove('badge-ghost'); + attendedBadge.classList.add('badge-success'); + + // Update the icon and text + const icon = attendedBadge.querySelector('svg'); + if (icon) { + icon.setAttribute('icon', 'heroicons:check-circle'); + } + + // Update the text content + attendedBadge.textContent = ''; + + // Recreate the icon + const iconElement = document.createElement('span'); + iconElement.className = 'h-3 w-3'; + iconElement.innerHTML = ''; + attendedBadge.appendChild(iconElement); + + // Add the text + const textNode = document.createTextNode(' Attended'); + attendedBadge.appendChild(textNode); } } } catch (error) { @@ -178,7 +204,7 @@ const EventLoad = () => { const isPastEvent = endDate < now; return ( -
+
@@ -217,7 +243,7 @@ const EventLoad = () => { )} {isPastEvent && ( -
+