diff --git a/frontend/src/components/RSVPForm.tsx b/frontend/src/components/RSVPForm.tsx index 69c0543..73b7ee4 100644 --- a/frontend/src/components/RSVPForm.tsx +++ b/frontend/src/components/RSVPForm.tsx @@ -168,8 +168,14 @@ const RSVPForm: React.FC = () => { // Get all claimed items from existing RSVPs including the new submission const claimed = new Set(); - const allRsvps = [...rsvpsResponse.data, response.data]; - allRsvps.forEach((rsvp: any) => { + + // First add items from the new submission + if (Array.isArray(response.data.items_bringing)) { + response.data.items_bringing.forEach(item => claimed.add(item)); + } + + // Then add items from existing RSVPs + rsvpsResponse.data.forEach((rsvp: any) => { try { let rsvpItems: string[] = []; if (typeof rsvp.items_bringing === 'string') { diff --git a/src/index.ts b/src/index.ts index c60cda1..42450dd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -131,9 +131,18 @@ app.post('/api/events/:slug/rsvp', async (req, res) => { [event.id, name, attending, bringing_guests, guest_count, guest_names, JSON.stringify(items_bringing || [])] ); - // Fetch the newly created RSVP to return in response - const newRsvp = await db.get('SELECT * FROM rsvps WHERE id = ?', result.lastID); - res.status(201).json(newRsvp); + // Return a complete response with the original items_bringing array + res.status(201).json({ + id: result.lastID, + event_id: event.id, + name, + attending, + bringing_guests, + guest_count, + guest_names, + items_bringing: items_bringing || [], + created_at: new Date().toISOString() + }); } catch (error) { console.error('Error creating RSVP:', error); res.status(500).json({