Implement event completion workflow (Task 14)

- Add completeEvent endpoint to backend API
- Create EventCompletionForm component with litter quantity input and photo upload
- Update EventDetailModal to show completion form for organizers
- Add isOrganizer check in EventsPage
- Update event service to support completion
- Display completion data (litter collected, photos) for completed events
This commit is contained in:
2025-11-16 20:21:47 +00:00
parent ec70baa498
commit c1f362a604
9 changed files with 295 additions and 6 deletions

View File

@@ -324,4 +324,40 @@ export const eventService = {
return !!registration;
},
async completeEvent(eventId: string, data: { litterCollected: number; photos?: string[] }) {
const event = await prisma.event.update({
where: { id: eventId },
data: {
status: 'completed',
litterCollected: data.litterCollected,
photos: data.photos || [],
},
include: {
_count: {
select: {
registrations: true,
},
},
},
});
return {
id: event.id,
organizerId: event.organizerId,
title: event.title,
description: event.description,
latitude: parseFloat(event.latitude.toString()),
longitude: parseFloat(event.longitude.toString()),
locationName: event.locationName,
scheduledDate: event.scheduledDate,
duration: event.duration,
status: event.status || 'upcoming',
participantCount: event._count.registrations,
litterCollected: event.litterCollected ? parseFloat(event.litterCollected.toString()) : undefined,
photos: event.photos ? (Array.isArray(event.photos) ? event.photos : []) : undefined,
createdAt: event.createdAt,
updatedAt: event.updatedAt,
};
},
};