From 9eb1d3389f959dc2b1765424f5c77511bb405b24 Mon Sep 17 00:00:00 2001 From: Paul Bailey Date: Tue, 18 Nov 2025 19:08:34 +0000 Subject: [PATCH] Improve event list layout: prioritize upcoming events and compact card design - Sort events with upcoming first, then completed/cancelled at bottom - Redesign event cards with horizontal layout to reduce vertical space - Move event details (date, time, duration, location, participants) into single row - Improve mobile responsiveness with flex-wrap - Keep quick register button visible for upcoming events --- src/components/event/EventList.tsx | 93 ++++++++++++++++-------------- src/pages/EventsPage.tsx | 12 +++- 2 files changed, 60 insertions(+), 45 deletions(-) diff --git a/src/components/event/EventList.tsx b/src/components/event/EventList.tsx index 9799bbe..edeb50c 100644 --- a/src/components/event/EventList.tsx +++ b/src/components/event/EventList.tsx @@ -85,30 +85,41 @@ export function EventList({ events, onEventClick, onRegister, isLoading = false }; return ( -
+
{events.map((event) => (
onEventClick(event)} > -
-
-
-

{event.title}

-
+
+ {/* Header Row */} +
+
+
+

{event.title}

{getStatusBadge(event.status)} - - {event.participantCount} {event.participantCount === 1 ? 'participant' : 'participants'} -
+

{event.description}

+ {event.status === 'upcoming' && onRegister && ( + + )}
-
+ {/* Info Row - Horizontal Layout */} +
{/* Date and Time */} -
- +
+ - + {formatEventDate(event.scheduledDate)} at {formatEventTime(event.scheduledDate)}
{/* Duration */} -
- +
+ {/* Location */} -
- +
+ - {event.locationName} + {event.locationName}
-
- {/* Description Preview */} -

{event.description}

+ {/* Participants */} +
+ + + + {event.participantCount} {event.participantCount === 1 ? 'participant' : 'participants'} +
- {/* Completed Event Info */} - {event.status === 'completed' && event.litterCollected !== undefined && ( -
-
- + {/* Completed Event Info */} + {event.status === 'completed' && event.litterCollected !== undefined && ( +
+ - {event.litterCollected} kg of litter collected + {event.litterCollected} kg collected
-
- )} + )} - {/* Action Area */} -
+ {/* View Details Link */} - - {event.status === 'upcoming' && onRegister && ( - - )}
diff --git a/src/pages/EventsPage.tsx b/src/pages/EventsPage.tsx index 03cacd8..cd7383a 100644 --- a/src/pages/EventsPage.tsx +++ b/src/pages/EventsPage.tsx @@ -75,8 +75,18 @@ export function EventsPage() { filtered = filtered.filter(event => new Date(event.scheduledDate) <= endDate); } - // Sort by date (upcoming first, then by date) + // Sort: upcoming events first (by date), then completed/cancelled at bottom (by date) filtered.sort((a, b) => { + // Priority order: upcoming > completed > cancelled + const statusPriority = { upcoming: 0, completed: 1, cancelled: 2 }; + const priorityA = statusPriority[a.status]; + const priorityB = statusPriority[b.status]; + + if (priorityA !== priorityB) { + return priorityA - priorityB; + } + + // Within same status, sort by date const dateA = new Date(a.scheduledDate).getTime(); const dateB = new Date(b.scheduledDate).getTime(); return dateA - dateB;