Add event cancellation functionality for organizers

- Add Cancel Event button in event detail modal for organizers
- Show cancel button both before and after event date (if not completed)
- Add confirmation dialog before cancelling
- Update event status to 'cancelled' when cancelled
- Only organizers can cancel their events
This commit is contained in:
2025-11-16 20:28:21 +00:00
parent 529cdd0c05
commit 8ee17848a6
2 changed files with 56 additions and 12 deletions

View File

@@ -186,6 +186,27 @@ export function EventsPage() {
}
};
const handleCancelEvent = async () => {
if (!selectedEvent) return;
if (!confirm('Are you sure you want to cancel this event? This action cannot be undone.')) {
return;
}
try {
setIsSubmitting(true);
setError(null);
await eventService.updateEvent(selectedEvent.id, { status: 'cancelled' });
setSelectedEvent(null);
await loadEvents();
} catch (err: any) {
setError(err.message || 'Failed to cancel event. Please try again.');
console.error('Error cancelling event:', err);
} finally {
setIsSubmitting(false);
}
};
return (
<div className="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
{/* Header */}
@@ -279,6 +300,7 @@ export function EventsPage() {
onRegister={() => handleRegister(selectedEvent.id)}
onUnregister={handleUnregister}
onComplete={handleCompleteEvent}
onCancel={isOrganizer ? handleCancelEvent : undefined}
isLoading={isSubmitting}
/>
)}