From 09f4ffc3280ba0a5bdfeb0c81839d9092e93a7f2 Mon Sep 17 00:00:00 2001 From: Ryderjj89 Date: Sun, 4 May 2025 17:31:15 -0400 Subject: [PATCH] fix: robustly handle other_items as string, string[], or undefined in Other Items section --- frontend/src/components/EventAdmin.tsx | 8 +++++++- frontend/src/components/EventView.tsx | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/EventAdmin.tsx b/frontend/src/components/EventAdmin.tsx index ec6e30d..5af7763 100644 --- a/frontend/src/components/EventAdmin.tsx +++ b/frontend/src/components/EventAdmin.tsx @@ -770,7 +770,13 @@ const EventAdmin: React.FC = () => { {(() => { const allOtherItems = rsvps .map(r => r.other_items) - .filter((item): item is string => typeof item === 'string' && item.trim() !== ''); + .flatMap(item => + Array.isArray(item) + ? item.filter((s): s is string => typeof s === 'string' && s.trim() !== '') + : typeof item === 'string' && item.trim() !== '' + ? [item] + : [] + ); return allOtherItems.length > 0 ? allOtherItems.join(', ') : 'No other items have been brought'; diff --git a/frontend/src/components/EventView.tsx b/frontend/src/components/EventView.tsx index 0cf733c..cd0ab9f 100644 --- a/frontend/src/components/EventView.tsx +++ b/frontend/src/components/EventView.tsx @@ -247,7 +247,13 @@ const EventView: React.FC = () => { {(() => { const allOtherItems = rsvps .map(r => r.other_items) - .filter((item): item is string => typeof item === 'string' && item.trim() !== ''); + .flatMap(item => + Array.isArray(item) + ? item.filter((s): s is string => typeof s === 'string' && s.trim() !== '') + : typeof item === 'string' && item.trim() !== '' + ? [item] + : [] + ); return allOtherItems.length > 0 ? allOtherItems.join(', ') : 'No other items have been brought';