From 7c967d9209b2a5aaeee830c35940a9d8c9d9b362 Mon Sep 17 00:00:00 2001 From: Starstrike Date: Thu, 1 May 2025 17:50:57 -0400 Subject: [PATCH] Fix TypeScript error: Handle guest_names as both string and array in EventAdmin --- frontend/src/components/EventAdmin.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/EventAdmin.tsx b/frontend/src/components/EventAdmin.tsx index abee07e..74d2f51 100644 --- a/frontend/src/components/EventAdmin.tsx +++ b/frontend/src/components/EventAdmin.tsx @@ -211,13 +211,20 @@ const EventAdmin: React.FC = () => { }; const handleEditRsvp = (rsvp: RSVP) => { + let processedGuestNames: string[] = []; + if (Array.isArray(rsvp.guest_names)) { + processedGuestNames = rsvp.guest_names; + } else if (typeof rsvp.guest_names === 'string' && rsvp.guest_names) { + processedGuestNames = rsvp.guest_names.split(',').map(name => name.trim()); + } + setRsvpToEdit(rsvp); setEditForm({ name: rsvp.name, attending: rsvp.attending || 'yes', bringing_guests: rsvp.bringing_guests || 'no', guest_count: typeof rsvp.guest_count === 'number' ? rsvp.guest_count : 0, - guest_names: rsvp.guest_names ? rsvp.guest_names.split(',').map(name => name.trim()) : [], + guest_names: processedGuestNames, items_bringing: Array.isArray(rsvp.items_bringing) ? rsvp.items_bringing : typeof rsvp.items_bringing === 'string' ? (rsvp.items_bringing ? JSON.parse(rsvp.items_bringing) : []) : []